Posts

Showing posts from September, 2014

dynamic programming - Divide an array into k or less subparts to minimize the maximum sum of each part -

i need divide array k or less subparts minimize maximum sum of each part. for example array has elements: 5,10,21,20 if k=2 , array can divided in 2 sub-arrays: {5,10,21} , {20} . have return maximum sum of subarray ( 36 in above example). when k>=4 , answer largest element of array. also, order in array elements chosen cannot changed, can't sort array , proceed. you use greedy solution if want good-enough solution: def minmax(lst, k): lst = sorted(lst, reverse=true) # biggest numbers first better subs = [[] _ in xrange(k)] # create lists subarrays while lst: subs[0].append(lst.pop(0)) # append 1 lowest sum subs.sort(key=sum) # sort sum (lowest first) print subs # print subarrays while creating them return sum(subs[-1]) # have sorted sums, last has biggest sum this not guarantee produce best result, works pretty well. k = 2 this example: print 'result %d

c - memory allocate string for fgets with null terminating char -

i'm sorry if question seems "easy" couldn't find answer anywhere. tried use fgets() read line file. make sure no space wasted, first of found line's length: do { c= getc(file); words++; }while (c!=eof && c!='\n'); then allocated memory exacly number of words: char* line = (char*)malloc(sizeof(char)*(words)); and then, use fgets() read line line buffer. problem is, working. thought should allocate memory null terminating char too. happened here? you do need allocate space null terminator . fact working doesn't mean (at least in c). plus, fgets returns \n character. need 2 characters. 1 \n , 1 \0 . i recommend approach though: char buffer [1024]; if ( fgets (buffer, 1024, f) != null ) { // buffer }

How to resize layout with displaying keyboard in Android? -

i have activity inside of displaying fragment .i want when keyboard displaying activity resize try android:windowsoftinputmode="adjustresize" in manifest doesn't resize layout.my layout inside scrollview also. introduced following property activity tag in manifest file: android:windowsoftinputmode="statevisible|adjustresize|adjustpan" also needed add following code in activity's oncreate function: this.getwindow().setsoftinputmode(windowmanager.layoutparams.soft_input_state_always_hidden);

katana - OWIN WS-FED Passive signout of identity provider -

so have solution using microsoft.owin.security.wsfederation 3.0.0-rc2 , i'm trying passive sign-out calling identity provider log out of there application (so don't redirect loop logging in). i'm using waad ws-fed endpoint. app.usecookieauthentication(new cookieauthenticationoptions { authenticationtype = defaultauthenticationtypes.applicationcookie, loginpath = new pathstring("/login") }); app.setdefaultsigninasauthenticationtype(defaultauthenticationtypes.applicationcookie); app.useexternalsignincookie(defaultauthenticationtypes.externalcookie); app.usewsfederationauthentication(new wsfederationauthenticationoptions { authenticationmode = microsoft.owin.security.authenticationmode.passive, authenticationtype = wsfederationauthenticationdefaults.authenticationtype, wtrealm = configurationmanager.appsettings["wsfedrealm"], metadataaddress = configurationmanager.appsettings["wsfedmetadataaddress"] }); i can w

c# - Want to add a validation using regular expression the format should be like this xxxxx-xxxxxxx-x -

i trying put validation using regular expression value text box xxxxx-xxxxxxx-x here trying [required] [display(name = "cnic")] [regularexpression(@"^\(([0-9]{5})[-]([0-9]{7})[-][0-9]{1}\)$", errormessage = "entered cnic format not valid.")] public string cnic { get; set; } but shows cnic format not valid [regularexpression(@"^[0-9+]{5}-[0-9+]{7}-[0-9]{1}$", errormessage = "entered cnic format not valid.")]

How to change programmatically the primary color in Android L -

is there way change programmatically primary colors. in code depending screen/state of app. currently can set colors in theme (static) : <item name="android:colorprimary">@color/primary_color</item> <item name="android:colorprimarydark">@color/dark_color</item> <item name="android:colorbackground">@android:color/white</item> <item name="android:coloraccent">@color/primary_color</item> <item name="android:colorcontrolhighlight">@color/primary_color</item> thanks you can, of course, implement custom subclasses of view have methods setting colors. you can define multiple themes various color schemes. views theme information context when created. change styles applied theme have recreate view hierarchy context uses right theme. one way that, create new contextthemewrapper , layoutinflator uses theme wrapper, remove old version of layou

batch file - robocopy /copyall but not empty folders (/e) -

i'm looking modify robocopy script taking way long complete. directory copying has thousand's of empty folders, i'm told cannot rid of. robocopy script switches this: robocopy /copyall /sec /mir /r:1 /w:1 /mt:24 the log file produces this: robocopy /s /e /copy:dats /purge /mir /mt:24 /r:1 /w:1 i think improve time takes backup directory if t can remove /e switch. assume comes /copyall . question how can still use /copyall remove /e ? simple manually adding below switches, , removing /e ? or there better way? /s /copy:dats /purge /mir /mt:24 /r:1 /w:1 below results yesterday. going file/print server nas box across 10gb link. ------------------------------------------------------------------------------ total copied skipped mismatch failed extras dirs : 188548 35 188513 0 0 0 files : 1144788 1633 1143155 0 0 26 bytes : 397.981 g 1.033 g 396.94

mysql - Collating data from two tables -

i'm using following statement try , collect , display data correctly. necessary to 'left join' 1 table collect more information, should it's not necessary second case (but such work-around). select coalesce(building.campus_id, campus.campus_id) campus member.* location left join cu_member member on (member.member_id = location.member_id) left join cu_building building on (location.params 'building_id=%' = building.id) left join cu_campus campus on (location.params 'campus_id=%' = campus.id) i'm above query, want use wildcard value. left join cu_building building on ('39' = building.id) below how location table looks. i'm trying use data params column resulting campus table ( building ). need fields containing building_id tag, not 'campus_id`, because known. ----------------------------- member_id | params ----------------------------- 1 | building_id=39 2 | building_

javascript - Bootstrap Navbar Toggle not rendering properly -

Image
i'm building wordpress theme using bootstrap 3. when decrease screen width test navbar toggle, shown on image. figure it's wordpress problem since haven't touched bootstrap 3 files, i'm not sure. i load css/js files using wp_enqueue_style , wp_enqueue_script wp_register_script( 'custom-script', get_template_directory_uri() . '/bootstrap/js/bootstrap.js'); wp_register_script( 'full-calendar', get_template_directory_uri() . '/js/fullcalendar.js'); wp_register_script( 'google-calendar', get_template_directory_uri() . '/js/gcal.js'); wp_register_script( 'main', get_template_directory_uri() . '/js/main.js'); wp_register_style( 'style', get_template_directory_uri() . '/style.css'); wp_register_style( 'bootstrap', get_template_directory_uri() . '/css/bootstrap.css'); wp_register_style( 'fullcalendar', get_template_directory_uri() . '/css/f

How to get the path to a Nancy Razor view inside a view? -

i trying write extension method used inside razor view file path said view. i have tried putting extension method on htmlhelpers<t> , nancyrazorviewbase cannot seem correct information view or render context e.g. public static string getpath(this nancyrazorviewbase view) { //is null, expecting c:\app\views\index.cshtml return view.path; } <input type="hidden" value="@this.getpath()"/> is possible path current view inside view? i using nancy 0.23. i had overlooked properties on negotiationcontext e.g. view.rendercontext.context.negotiationcontext.viewname .

android - How to create private Calendar events that only my app can read & write? -

this not calendar app, else requires calendar event functionality. is there way in android use android calendar api create events that: only app can see (i.e. other apps cannot see these events). i can read events created app only, dont want read events created other apps.

ruby on rails - How do I use the command "heroku pg:transfer"? -

i new heroku/ruby on rails , git. went through michael hartl's ruby on rails tutorial , want push local database heroku having trouble. after doing research found article: pg transfer new taps it seems should work, not understand how set env var database_url : $ env database_url=postgres://localhost/someapp-dev heroku pg:transfer specifically have no idea supposed directly copy , change. believe need enter own local host , own database name. is correct? if how find localhost , how find database name? my database.yml file looks this: development: adapter: sqlite3 database: db/development.sqlite3 pool: 5 timeout: 5000 my understanding - must use postgresql database on heroku. when pushed application heroku changed databases postgresq al part of push - including in dev. looking @ link provided impression means database copying postgresql (as opposed sqlite).

python - PIL ImportError with Image -

i having trouble pil import image. have pillow installed. when try pil import image gives following error. >>> pil import image traceback (most recent call last): file "<stdin>", line 1, in <module> file "/library/frameworks/python.framework/versions/7.1/lib/python2.7/site-packages/pillow-2.5.2-py2.7-macosx-10.5-i386.egg/pil/image.py", line 61, in <module> pil import _imaging core importerror: dlopen(/library/frameworks/python.framework/versions/7.1/lib/python2.7/site-packages/pillow-2.5.2-py2.7-macosx-10.5-i386.egg/pil/_imaging.so, 2): symbol not found: _tiffclientopen referenced from: /library/frameworks/python.framework/versions/7.1/lib/python2.7/site-packages/pillow-2.5.2-py2.7-macosx-10.5-i386.egg/pil/_imaging.so expected in: flat namespace in /library/frameworks/python.framework/versions/7.1/lib/python2.7/site-packages/pillow-2.5.2-py2.7-macosx-10.5-i386.egg/pil/_imaging.so

r - Conditional `echo` (or eval or include) in rmarkdown chunks -

i create rmarkdown document (pdf or html) has chunks "executed" conditionally. particular case have in mind might want more verbose , documented version of output internal review colleagues, , shorter version external consumers. may not want or need show data manipulation steps client, key graphs , tables. not want make 2 separate documents or have manually indicate show or not. is there way set switch @ beginning of rmd indicates, e.g., verbose=t run chunks or verbose=f toggles echo=f (or include=f)? thank you. knitr options can stated r expressions. per the "output" documentation on knitr webpage : note options in knitr can take values r expressions, brings feature of conditional evaluation introduced in main manual. in short, eval=dothis means real value of eval taken variable named dothis in global environment; manipulating variable, can turn on/off evaluation of batch of chunks. in other words if write chunks like: ```{r label} d

javascript - multiple canvas as buttons with onclick event -

i'm having big problems canvas code i'm using 1 time in page (in logo) working fine, , i'm trying use buttons menu , here problem, don't know what's im doing wrong, hope of u me. it's code i'm using logo , working fine: html code: <html> <head> <title>canvas</title> </head> <body> <div id="container"> <div id="logo"> <canvas style="" width="800" id="broken-glass"></canvas> <h1 style="color: rgba(250, 250, 250, 0.95);" id="logo-title">canvas</h1> </div> <script type="text/javascript"> (function() { var iscanvassupported = function () { var elem = document.createelement('canvas'); return !!(elem.getconte

java - Are additional IRC commands possible by using common IRC clients? -

i wanna implement irc protocols in java. in general, have question additional commands not exist in protocols. for example, adding "dice" command random number generation. implement dice command using privmsg ("* user_x dices 5"). same when user writes "/me dices 5". not way because user can cheat ;-). is there better way implement additional commands irc? how can these commands used common irc clients?

Optimizing a prime number generator in Python -

i looking suggestions on optimizing prime number generator. please include correction , little comment on why faster in response. def primelist ( highestnumber ): """ function takes integer , returns list of primes less or equal integer""" numbers = range( 2, highestnumber + 1 ) # creates inclusive list of numbers between 2 , highestnumber isprime = [ true ] * len( numbers ) # each element corresponds element in numbers , keeps track of whether or not prime primes = [] # i'll build list of prime numbers in range( len( numbers ) ): if ( isprime[i] == true ): increment = numbers[i] position = + increment primes.append( numbers[ ] ) while ( position < len( numbers )): # execute if above if statement true because position still greater len( number ) isprime[position] = false # sets element of isprime false if multiple of lower number positi

SQL join data from two tables with multiple data from one table -

i have 2 tables, first 1 set this: name(pk), height, width, age the second tables set this: name1, name2 how go joining 2 tables 2 eachother output data in following way: name1, name2, height1, height2, width1, width2, age1, age2 name in first table can joined on name in second table. you place table1 (with name, height, width, age values in each row) query twice different alias names. i'm sure analysis of performance in order possible outer joins both table1 references (t11 , t12) in case name1 or name2 values in table2 (t2) not exist in table1 (t11 , t12). select t2.name1, t2.name2, t11.height height1, t12.height height2, t11.width width1, t12.width width2, t11.age age1, t12.age age2 table2 t2, -- contains rows name1, name2 table1 t11, -- contains rows name, height, width, age table1 t12 -- contains same rows t11 name, height, width, age t12.name = t2.name2 , t11.name = t2.name1

Play video in Vaadin -

i'm beginner vaadin, , have problem when play video. video plays file size of video although set fixed dimensions. can me? much! my code : public class videopreview extends csslayout{ video video; public videopreview(string uri) { video = new video(null, new externalresource(uri, "video/mp4")); video.setalttext("can't play video"); video.setautoplay(true); video.setwidth("320px"); video.setheight("265px"); addcomponent(video); } } can check code vaadin sampler : embedded e = new embedded(null, new externalresource( "http://www.youtube.com/v/mexvxkn1y_8&hl=en_us&fs=1&")); e.setalternatetext("vaadin eclipse quickstart video"); e.setmimetype("application/x-shockwave-flash"); e.setparameter("allowfullscreen", "true"); e.setwidth("320px"); e.setheight("265p

How to generate PDF from currently submitted InfoPath form from a Sharepoint Library -

i have sharepoint library , want generate , send pdf of infopath form in email when form submitted sharepoint library. is there way using workflow or other way achieve this? thanks i've done before, used open source dll, unfortunately forgot name of dll. yes, can using workflow or event receiver. infopath form not converted directly pdf, first, infopath converted html, html converted pdf. that's how achieved convert infopath pdf

Powershell script to Upload log file from local system to http URL -

how upload log file local system webpage ( http://abc. .) using powershell script? in advance if using http, try this: $sourcefilepath = "c:\mylocalfolder\locallogfilename.log" $siteaddress = "http://192.168.15.12/destinationfolder" $urldest = "{0}/{1}" -f ($siteaddress, "destinationlogfilename.log"; $webclient = new-object system.net.webclient; $webclient.credentials = new-object system.net.networkcredential("myusername", "mypassword"); ("*** uploading {0} file {1} ***" -f ($sourcefilepath, $siteaddress) ) | write-host -foregroundcolor green -backgroundcolor yellow $webclient.uploadfile($urldest, "put", $sourcefilepath);

Best way to handle switching ViewControllers with Rotation, iOS -

my current view portrait, displaying particular design. when rotate landscape wise, want switch new design, , in particular new viewcontroller, new .h/.m files. should approaching way? can point me in right direction? can rotation trigger segue? -(void) willrotatetointerfaceorientation:(uiinterfaceorientation)tointerfaceorientation duration:(nstimeinterval)duration { if (tointerfaceorientation == uiinterfaceorientationlandscapeleft) { nslog(@"landscape left"); //present or dismiss new view controller accordingly } else if (tointerfaceorientation == uiinterfaceorientationlandscaperight) { nslog(@"landscape right"); //present or dismiss new view controller accordingly } else if (tointerfaceorientation == uiinterfaceorientationportrait) { nslog(@"portrait"); //present or dismiss new view controller accordingly } else if (tointerfaceorientation == uiinterfaceorientationportraitupsidedown) { nslog(@"upside down&

python - pandas - DataFrame expansion with outer join -

first of new @ pandas , trying lean thorough answers appreciated. i want generate pandas dataframe representing map witter tag subtoken -> poster tag subtoken means in set {hashtaga} u {i | in split('_', hashtaga)} table matching poster -> tweet for example: in [1]: df = pd.dataframe([["jim", "i #yolo_omg her"], ["jack", "you #yes_omg #best_place_ever"], ["neil", "yo #rofl_so_funny"]]) in [2]: df out[2]: 0 1 0 jim #yolo_omg 1 jack #yes_omg #best_place_ever 2 neil yo #rofl_so_funny and want like 0 1 0 jim yolo_omg 1 jim yolo 2 jim omg 3 jack yes_omg 4 jack yes 5 jack omg 6 jack best_place_ever 7 jack best 8 jack place 9 jack ever 10 neil rofl_so_funny 11 neil rofl 12 neil 13 nei

java - Get groups and users from LDAP -

hi trying fetch posixgroup ldap , users in group. code below have done far, returns me groups not sure how users these groups. please guide me approach good? or should go first getting users , based on gid group name? public static void main(string[] args) { hashtable env = new hashtable(); env.put(context.initial_context_factory,"com.sun.jndi.ldap.ldapctxfactory"); env.put(context.provider_url,"ldap://192.168.*.*:389"); env.put(context.url_pkg_prefixes, "com.sun.jndi.url"); env.put(context.referral, "ignore"); env.put(context.security_authentication, "simple"); env.put(context.security_principal, "cn=manager,dc=*,dc=*"); env.put(context.security_credentials, "****"); dircontext ctx; try { ctx = new initialdircontext(env); } catch (namingexception e) { throw new runtimeexception(e); }

How can i select language in Visual Studio auto-generated comments? -

i'm wondering because in visual studio auto generated comments not english. for example, when create atl project, // dll이 ole에 의해 언로드될 수 있는지 결정하는 데 사용됩니다. stdapi dllcanunloadnow(void) { return _atlmodule.dllcanunloadnow(); } yes, i'm using visual studio korean language pack. so, visual studio auto-generated comments korean. how can change comments language? i installed english language pack. , vs generated comment in english!

ruby on rails - Error trying to deploy to heroku (following ror tutorial) PG::Error: ERROR: column "password_digest" of relation "users" already exists -

so i'm following http://www.railstutorial.org/book , , evrything works fine locally (running sqlight3). i following error when try heroku run rake db:migrate this error message looks like running rake db:migrate attached terminal... up, run.4049 migrating addpassworddigesttousers (20140817014655) == 20140817014655 addpassworddigesttousers: migrating ========================= -- add_column(:users, :password_digest, :string) pg::error: error: column "password_digest" of relation "users" exists : alter table "users" add column "password_digest" character varying(255) rake aborted! standarderror: error has occurred, , later migrations canceled: pg::error: error: column "password_digest" of relation "users" exists : alter table "users" add column "password_digest" character varying(255)/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.8/lib/active_record/connec

mouseover - Mouse Over Event In Selenium webdriver -

i unable reveal sub menu menu i tried following methods 1) tried mouse on action (obvious one) 2)i tried javascript executor problem html component loaded on mouse on unable set attribute of element not present in html using java https://www.milonic.com/index.php the hover action works great, i've written little testing code can modify needs, here clicks on link "about us" in tab "about milonic" what needed wait object expectedconditions . here wait element in menu clickable. driver.get("https://www.milonic.com/index.php"); actions action = new actions(driver); webelement hover = driver.findelement(by.id("el136")); action.movetoelement(hover).build().perform(); webdriverwait wait = new webdriverwait(driver, 5); webelement element = wait.until(expectedconditions.visibilityofelementlocated(by.cssselector("#tbl0 #ptr0 a"))); element.click();

android - Custom array adapter doesn't work in DialogFragment -

i want populate list view custom array adapter, looks getview() never called. below code, part creates dialog: @override public dialog oncreatedialog(bundle savedinstancestate) { // use builder class convenient dialog construction alertdialog.builder builder = new alertdialog.builder(getactivity()); builder.setpositivebutton("delete", new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int id) { //do deletion } }) .setnegativebutton(r.string.cancel, new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int id) { // user cancelled dialog } }); builder.settitle("dialog title").setview(getcustomview()); return builder.create(); } this part creates view, commented on works, doesn't public view getcustomview(){ layoutinflater inflater = (layoutinflater) getactivity()

Write higher resolution (DPI) Images to PDF -

i have seen code extract images based on image dpi using pdfbox below pddocument document = pddocument.load(path); pdfimagewriter writer = new pdfimagewriter(); boolean success = writer.writeimage(document, "jpg", "", 1, 1, "c:\\image quality\\150", bufferedimage.type_int_rgb, 150); return document; in above code can specify image resolution(150) while extracting image pdf. higher resolution larger image in return. now want reverse of means specify resolution/dpi of image while writing image pdf, following code not providing such options specify dpi ? can guide me missing pdpagecontentstream contentstream = null; contentstream = new pdpagecontentstream(document, userpage); contentstream.drawimage(img, 60, 60); contentstream.close(); please guide me can pass parameter of resolution/dpi (as image larger pdf page size) while writing image pdf ? thanks, you have been told in answer previous ques

php - How can I send a parameter into custom repository method in Symfony2? -

ok, want send logged in user custom method in productrepository, filter products ones assigned user. product.yml route listing of products: sylius_backend_product_index: pattern: / methods: [get] defaults: _controller: sylius.controller.product:indexaction _sylius: template: syliuswebbundle:backend/product:index.html.twig method: createfilterpaginator2 arguments: [$criteria, $sorting, $deleted, $user] next go controller, productcontroller not have indexaction method, extension resourcecontroller has, index action: public function indexaction(request $request) { $criteria = $this->config->getcriteria(); $sorting = $this->config->getsorting(); $user = $this->get('security.context')->gettoken()->getuser(); $repository = $this->getrepository(); if ($this->config->ispaginated()) { $resources = $this->resourceresolver->getresource( $repository, 'cre

sql server - SQL query error from case when statement with subquery -

my stored procedure: create procedure test_template @template_type int=null begin select template_id, template_name bdc_templates template_can_be_applied_to in ( case when @template_type=0 or @template_type=1 @template_type -- 0:email & letter , 1: email when @template_type=2 (select data udf_dp_split_string('0,2', ',')) -- 2: letter else template_can_be_applied_to end) end above stored procedure returns following error: msg 512, level 16, state 1, procedure test_template, line 6 subquery returned more 1 value. not permitted when subquery follows =, !=, <, <= , >, >= or when subquery used expression. when executed following inputs: exec test_template 2 i using in clause in where condition because when @template_type '2', template_can_be_applied_to column can 1 of values 0 , 2.

c# - How to partial update DataGrid - only for one column -

how partial update of datagrid in wpf ? want update 1 column , values inside of datagrid without refreshing whole grid. using timer reload grid latest data every xx seconds. how can that? there double click event on grid row, when whole grid refreshes if user clicks @ moment won't handle double click . same if have hyperlink column. believe if partial update can handle such case? binding is: datagrid.datacontext = mycollection; datagrid.items.refresh(); and idea refreshing of grids , have similar issue: refresh datagrid on timer tick event when value of mycollection has changed. in wpf work data elements rather ui elements... instead of trying manipulate column value of each row in datagrid , should think data binding collection of custom class instances datagrid.itemssource property , update whichever property of classes data bound column. see example: <datagrid itemssource="{binding items}" ... /> ... foreach (yourclass item in ite

jquery - Loading multiple slideshows one at a time -

i have used wordpress slideshow plugin called cyclone slider. have built website 1 page only, pages along slideshows stacked display: none , visibility: hidden , on click z-index , visibility: visible , display: block . the site loads extremely slow there lot of slideshows images averaging 100kb in size, photographers website , not want optimize images anymore. how use jquery load images on every slideshow once parent goes display: none display: block or visibility: hidden visible. or using z-index . the best option if click on category, starts loading catagory or section slideshow , stops loading slideshow on. some layout code: <div id="togglelinks" class="gallery-toggle"> <ul> <li class="people"><a class="switch" href="#" data-toggle="#people"><i>people</i></a></li> <li class="business"><a class="switch" href="#"

How to properly represent permissions in use case diagram -

Image
if have user, can let's ... edit profile. a customer user confirmed email (just example) a customer has customer permissions , can view customer pages. how represent in use case diagram? uml use case diagrams offer concept of generalization. applies both use cases themselves, actors (see image): if need more detailed permissions, write them down in use case scenario – or separate permission concept.

sql - How to get a specific column when queried with certain data. (There are 'n' similar columns) -

i have n similar columns (x1, x2, x3,... xn) in record. want columns have value '5'. how done? in advance! from vague description, think need simple clause. select column_name(s) table_name column_name(s) =5;

android - Developing cross platform app -

i have developed phonegap app (android) using eclipse ide. there way can use same html, css , js develop ios app? not have mac system that. need mac system or can done on windows? need have developer account? can done without having developer account? how can create .ipa file without using mac system? you can put code on generate ipa you https://build.phonegap.com/

python 2.7 - Get row-index of the last non-NaN value in each column of a pandas data frame -

how can return row index location of last non-nan value each column of pandas data frame , return locations pandas dataframe? use notnull , idxmax index values of non nan values in [22]: df = pd.dataframe({'a':[0,1,2,nan], 'b':[nan, 1,nan, 3]}) df out[22]: b 0 0 nan 1 1 1 2 2 nan 3 nan 3 in [29]: df[pd.notnull(df)].idxmax() out[29]: 2 b 3 dtype: int64 edit actually correctly pointed out @caleb can use last_valid_index designed this: in [3]: df = pd.dataframe({'a':[3,1,2,np.nan], 'b':[np.nan, 1,np.nan, -1]}) df out[3]: b 0 3 nan 1 1 1 2 2 nan 3 nan -1 in [6]: df.apply(pd.series.last_valid_index) out[6]: 2 b 3 dtype: int64

php - Cannot upload files bigger than 10MB -

i'm trying let user upload 30mb max server hangs not produce error. not error in browser network bar in inspection. did changes below after reading whole lot of info on internet no luck far. knows else can do? thanks in advance .htaccess: <ifmodule mod_php5.c> php_value post_max_size 40m php_value upload_max_filesize 350m php_value max_execution_time 1200 php_value max_input_time 1200 </ifmodule> /etc/php5/{cli,fpm}/php.ini post_max_size 40m upload_max_filesize 35m max_execution_time 1200 max_input_time 1200 restart: sudo service php5-fpm restart sudo service apache2 restart one thing check maximum post size set in php suhosin security patch. complements settings in php.ini , might cause issues you're seeing. similar question here: https://serverfault.com/questions/486134/php-cant-increase-maximum-upload-limit let me know if worked.

angularjs - Third party library not working with angular js -

i using navgoco.js , angular js in application , have following html <div id="demo"> <ul > <li ng-repeat ... > <a href="#"> ... </a> ...... </li> </ul> </div> js code $j("#demo1").navgoco({accordion: false}); it supposed expand-collapse of menus. the problem navgoco events not performing on clicking on anchor. adds # url. in rendered html of anchor tag, anuglar adding ng-binding may problem. please help. the <a> tag directive in angularjs. see https://docs.angularjs.org/api/ng/directive/a

c# - AutoCompleteBox navigate to tapped result -

i have autocompletebox: <toolkit:autocompletebox itemssource="{binding people}" valuememberbinding="{binding name}" style="{staticresource autocompleteboxstyle1}"> <toolkit:autocompletebox.itemtemplate> <datatemplate> <stackpanel margin="10,10,10,20" height="66"> <textblock text="{binding name}"/> <textblock text="{binding surname}"/> </stackpanel> </datatemplate> </toolkit:autocompletebox.itemtemplate> </toolkit:autocompletebox> when type gives me suggestions, when click suggestion want navigate page details, how can make this? possible make invokecommandaction?

c# - jquery how to get data from this array -

Image
this c# code: dictionary<string, double[][]> dictionary = new dictionary<string, double[][]>(); dictionary.add("servicelevel", finalarray); dictionary.add("numberofcalls", numberofcallsarray); where finalarray , numberofcallsarray double[][] full of data. i send jquery this: string jsonformatstring = jsonconvert.serializeobject(dictionary, formatting.indented); httpcontext.current.response.clear(); httpcontext.current.response.contenttype = "application/json; charset=utf-8"; httpcontext.current.response.write(jsonformatstring); httpcontext.current.response.end(); then in jquery after doing json request , data successfully. this: var data = $.map(result, function (arr, key) { return { label: key, data: arr }; }); console.log(data["servicelevel"] + "--"); my problem i got undefined in console when tried this: console.log(data["servicelevel"] + "--"); mayb

Android Manifest ActiviyNotFoundException -

i working on university project , have app 50+ activities. of app existed , added it. of pages had content fit small devices locked large screens. when added code limit screen sizes, getting error of duplicate activites in manifest. when had saw following repeated 3 times: <activity android:name="com.ucl.pga.db.objective.objective" android:label="@string/title_activity_objective" > </activity> however, there 1 activity in project name. after removing this, app worked fine , limited large screen sizes. however, have attempted reload on emulator , getting following error: 08-18 09:34:00.589: e/androidruntime(1729): caused by: android.content.activitynotfoundexception: unable find explicit activity class {com.ucl.pga/com.ucl.pga.db.objective.observation}; have declared activity in androidmanifest.xml? i understand saying activity not exist, sure does. sure 3 instances removed. the activity trying load is: c

python - Keep getting some permission denied error -

i keep getting permission denied error, that? every time when trying install anything, same permission denied error message in python, in nltk tool error: not create '/usr/local/lib/python2.7/dist-packages/nameparser': permission denied ---------------------------------------- cleaning up... command /usr/bin/python -c "import setuptools, tokenize; file ='/tmp/pip_build_vandana/nameparser/setup.py';exec(compile(getatt‌​r(tokenize, 'open', open)(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record /tmp/pip-4rd7ge-record/install-record.txt --single-version-externally-managed --compile failed error code 1 in /tmp/pip_build_vandana/nameparser storing debug log failure in /home/vandana/.pip/pip.log you doing python setup.py install something or pip install something , trying install global python package location, user not have access. need use virtual environments .

Comparing two strings in c++ in ROS -

i trying compare 2 strings in following method on ros std::string line_eval_str = std::string(line_eval)+""; std::string check ("checking condition"); while(/*some condtion*/) { if(check.compare(line_eval_str) == 1) { ros_error("breaking loop!!!!! %s",line_eval); break; } else { /*execute part*/ } } here though line_eval_str , check have same string in them else part executed. tried other method while(/*some condtion*/) { if(strcmp(line_eval_str,check) == 1) { ros_error("breaking loop!!!!! %s",line_eval); break; } else { /*execute part*/ } } even code provides same result ( ie,. strings have same value else part executed). don't understand problem. have ros? here though line_eval_str , check have same string in them else part executed this expected behaviour: both string::compare() , strcmp() return 0 (an

java - sqlserver jdbc batchsize limit -

is there limit on number of records in jdbc batch? i using sqljdbc4-4.0 connect sql server 2012 db. please point me reference documentation this, if available. thanks, found reference per jdbc seems there no such limit on records in batch insert, governed memory available.

How do I catch a static java.lang.UnsatisfiedLinkError from Android and show the user a better error message? -

my application loads various shared objects when created. catch errors thrown because of shared objects not being present on device , show better error message user. how achieve this? i can catch java.lang.unsatisfiedlinkerror so static { try { system.loadlibrary("myapplication"); } catch(java.lang.unsatisfiedlinkerror e) { if(e.getmessage().contains("libsharedobject")) { log.e( tag, "this device not support ..." ); } else { throw e; } } } but toast.maketext(...).show() , other application message boxes won't work because application die in oncreate() because of previous error. is there way of changing systems default error message of "unfortunately there error.."? or way of displaying error message process or android os? i found answer using this answer . catch exception in static {} block, set member variable ther