Posts

Showing posts from August, 2011

Plotting cone of influence in Morlet wavelet power spectrum in MATLAB -

i tried generating cone of influence morlet wavelet power spectrum using following matlab code: cone = conofinf('morl',1:365,lensig,[],'plot'); however, strange looking shaded area bounded 2 linear lines. doesn't cone of influence morlet wavelet power spectrum. what did wrong? i guess wanted output coi @ borders of wavelet transform. in case have specify last parameter non-empty vector, coordinates, need coi computed, e.g. cone = conofinf('morl',1:365,lensig,[1 lensig],'plot'); i had similar task , here's did: figure; % plot wavelet transform / scalogram imagesc(t,scales,wt); axis square; colorbar; % annotate axes , title title('coefficients of continuous wavelet transform'); xlabel('time (or space) b'); ylabel('scales a'); % cone of influence % here, have specify points @ want calculate coi % last parameter: cone = conofinf(wname,scales,lensig,[1 lensig]); % combine left , right edges cone =

ios - Swift Array Issues -

i have code: let posstate = positionstate(pos) if posstate != .none { if posstate == .off { boardarray[pos.row][pos.column] == .on } else { boardarray[pos.row][pos.column] == .off } } the issue i'm having when attempt change value of element in boardarray , nothing happens. why boardarray's element stay same? you using == rather = assigning let posstate = positionstate(pos) if posstate != .none { if posstate == .off { boardarray[pos.row][pos.column] = .on } else { boardarray[pos.row][pos.column] = .off } }

html - How to get Bootstrap Carousel to fit 100% to screen? -

i wondering how carousel in bootstrap's carousel example fit 100% screen, opposed way it's displaying allows blank circular images included in main landing page when loaded. here's simple illustration of i'm trying working. page source (relevant bit): <!-- carousel ================================================== --> <div id="mycarousel" class="carousel slide" data-ride="carousel"> <!-- indicators --> <ol class="carousel-indicators"> <li data-target="#mycarousel" data-slide-to="0" class="active"></li> <li data-target="#mycarousel" data-slide-to="1"></li> <li data-target="#mycarousel" data-slide-to="2"></li> </ol> <div class="carousel-inner" role="listbox"> <div class="item active"> <img class="first-slid

php check if remote image cant be displayed -

i have script gets images external website , display on mine. need show different image if external image 404 or can't displayed. tried various approaches couldnt find works :( this example of image cant displayed on remote server (it show text error instead of displaying image) http://image.spreadshirtmedia.com/image-server/v1/compositions/1112876576765766798/views/1,width=1000,height=1000,appearanceid=95/ and here's code $path = "http://image.spreadshirtmedia.com/image-server/v1/compositions/111286798/views/1,width=1000,height=1000,appearanceid=95/t.jpg"; // load requested image $image = imagecreatefromstring(file_get_contents($path.'?'.mt_rand())); // send image header('content-type: image/png'); function get_http_response_code($path) { $headers = get_headers($path); return substr($headers[0], 9, 3); } if(get_http_response_code($path) != "404"){ imagepng($image); }else{ imagepng("notfound.png"); }

twitter bootstrap 3 - nav doesnt work properly inside accordion -

as can see in picture. nav doesn't response on screen size when place inside accordion. i try resized using jquery when accordion collapse doesn't work also. does have solution problem? image link

android - Getting error for creating and populating ListView -

i trying list of installed applications on device , display names in list. when run code shows unfortunately,lister has been stopped . code in oncreate method is:- packagemanager pm=this.getpackagemanager(); list<applicationinfo> list=pm.getinstalledapplications(0); listview lv=(listview)findviewbyid(r.id.listview1); arraylist<string> al=new arraylist<string>(); for(applicationinfo app:list) { string appn=pm.getapplicationlabel(app).tostring(); al.add(appn); } arrayadapter<string> arr=new arrayadapter<string>(this, android.r.layout.simple_list_item_1,android.r.id.text1,al); lv.setadapter(arr); setcontentview(r.layout.activity_sec); and activity_sec.xml code is:- <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_par

Calculate percentage between two dates in JavaScript -

i've been trying calculate percentage between 2 dates given code questions here in stackoverflow code doesn't work correctly. question: get percent of time elapsed between 2 javascript dates var start = new date(2015,6,1), end = new date(2015,12,1), today = new date(); alert(math.round(( ( today - start ) / ( end - start ) ) * 100) + "%"); i want calculate progress 1rst of june 1rst of december , "-7" please help! thanks javascript counts months 0 11. january 0 , december 11. specified june december, entered 6 , 12.

Can't Click button in Transparent Activty Android -

i trying add transparent activity in front of activity. added transparent activity. want both transparent & behind activity button's clickable. can click behind activity's button. in transparent activity's button cant click because added 1 line in transparent activity below getwindow().addflags( windowmanager.layoutparams.flag_not_focusable | windowmanager.layoutparams.flag_not_touch_modal | windowmanager.layoutparams.flag_not_touchable ); if remove above line transparent activity can't click button in behind activity. need both behind & transparent activity's button clickable. please post suggestion. thanks...

ios - UITabBar / UITabBarController Blocking Touches When Scrolled Away -

i have custom subclass of uitabbarcontroller adapts delegate has function shift tabbar's frame (specifically frame.origin.y ). when offset equal height of screen (that is, hidden off-screen) have uiscrollview extending bottom of screen. within uiscrollview , cannot receive touches in initial frame of tabbar view. i have seen recommendations add intractable subviews uitabbar or controller's view. far elegant, , creates multitude of design issues when working views possibly take whole screen. have checked out little public implementation code of uitabbarcontroller , uitabbar nothing saw there shows how blocking touches. i'm aware of recursive nature of hit tests, short of overriding hit test , rerouting touch in uitabbarcontroller subclass, seems rather unclean, can't think of generic way handle this. question dives apple's uitabbarcontroller / uitabbar implementation, have included relevant code clarity: class tab_bar_controller: uitabbarcontroller,

python - from raw sql to flask-sqlalchemy -

hello im trying achieve raw query sqlalchemy: select m.*, sum(case when f.monkey = m.id 1 else 0 end) friends monkey m left join friendship f on m.id = f.monkey group m.id, m.name order friends desc so far result want raw query want able .paginate them keep working properly with other queries did this: monkeys = models.monkey.query.order_by(models.monkey.name).paginate(page, 5, false) fairly simple , got wanted, belive have like monkeys = models.monkey.query.join(models.friendship, db.func.count(models.monkey.id == models.friendship.monkey)) but im not getting want, know im missing sum() part tried func.c.count()but dont know how work, posible achieve in sqlalchemy? im using postgres btw looks accomplish need monkeys = models.monkey.query.outerjoin(models.friendship, db.func.count(models.monkey.id == models.friendship.monkey)) #or if want stick above query monkeys = models.monkey.query.outerjoin(models.friendship, db.func.sum(func.if(models.monkey.id =

java - Sorting Polymorphic Arrays -

lets have 3 classes (passenger,pilot,stewardess) inherit abstract class called persons, , in array of persons save many of these objects 3 classes defined, want sort objects inside array of persons in following order: -all objects class passenger -all objects class pilot -all objects class stewardess is there way achieve without arraylists? arrays.sort(personarray, new comparator<person>() { @override public int compare(person p1, person p2) { int person1index = getorderindex(p1); int person2index = getorderindex(p2); if (person1index < person2index) { return -1; } else if (person1index > person2index) { return 1; } else { return 0; } } private int getorderindex(person p) { if (p == null) { return 0; } else if (p instanceof passenger) { return 1; } else if (p instanceof pilot) { return 2;

r - how to select previous rows in data frame? -

let's have data frame: df <- data.frame(a=1:5, b=4:8) how can subset previous rows? example, if @ row 3, want values of row 1 , row 2, if @ row 4, want values row 2 , row 3. how can in r? using zoo library (be careful, base lag works differently): library(zoo) df <- zoo(df) df[lag(df$b, -1) == 4, ] b 2 2 5 df[lag(df$b, -2) == 4, ] b 3 3 6

javascript - No call function of parent in Reactjs -

i have 2 function in reactjs. when function 1 call function of function two. there have error same "uncaught typeerror: this.props.onbutonshowclick not function" this function 1 : var hiddenedit = react.createclass({ _handleonclick: function(e) { e.preventdefault(), this.props.onbutonshowclick(true); }, render: function() { return (<span classname="col-lg-2 btn-action-group"> <a classname="add btn-for-view" href={this.props.url_detail} id="btn-add-chapter-123" title="add"></a> <a classname="edit btn-for-view" onclick={this._handleonclick} id={this.props.id_chapter} title="edit"></a> <a classname="trash btn-for-delete btn-delete-episode" data-confirm="are sure?" rel="nofollow" data-method="delete" href=""></a> </span>); } });

Trying to push Rails 4.2.1 app to Heroku sqlite error -

so read thread on similar question, still confused. gem file. i changed sqlite3 gems in gemfile gem 'pg', '0.7.0' changed sqlite3 in database.yml file postgresql. did bundle install, , heroku create, , git push heroku master , had multiple problems trying install sqlite3. it common run sqlite in development , test , different database postgresql in production. rails makes easy this. in gemfile, can use groups specify gems should installed in each environment. so, in scenario, gemfile contain like: group :development, :test gem 'sqlite3', '1.3.9' end group :production gem 'pg', '0.17.1' end the first time add production gems, should run: bundle install --without production to update gemfile.lock . similarly, in database.yml , should define sqlite development , test , postgresql production. here example: default: &default adapter: sqlite3 pool: 5 timeout: 5000 development:

c# - DotNetZip Extract Folder & Contents based on folder comment -

i have code adds different directories zip file. important know each folder based on comment, during extraction process. here zip sample code: foreach (string folder in backupdirs) { string source = path.combine(environment.getfolderpath(environment.specialfolder.applicationdata), folder); string folder = path.getfilename(path.getdirectoryname(source)); zipentry e = zip.adddirectory(source, folder); e.comment = "comment here"; } here code unzipping: using (zipfile zip1 = zipfile.read(src)) { foreach (zipentry e in zip1.entries) { // e.comment null on actual files. } } the actual entry points folder have comments files dont, presents problem since cause entries have null comments. how make files have same comment folder, or dotnetzip extract directory files sequentially, me

css - How do I apply a style to every nth set of size m? -

in css, can apply style every nth item using :nth-child : li:nth-child(3) { background: green; } this make every 3rd row green. if want have rows styled in pattern of 3 white, 3 green, repeating? 1 2 3 [4][5][6] 7 8 9 [10][11][12] more complex: if wanted have rows styled in pattern of 3 white, 2 green, repeating? 1 2 3 [4][5] 6 7 8 [9][10] 11 12 and finally: if wanted highlight remainder of total length/3 (the positions in brackets)? [1] [1][2] [1][2][3] 1 2 3 [4] 1 2 3 [4][5] 1 2 3 [4][5][6] 1 2 3 4 5 6 [7] 1 2 3 4 5 6 [7][8] 1 2 3 4 5 6 [7][8][9] is there way these patterns in css? you can use comma operator this: :nth-child(6n-2), /* 4, 10, 16, 22, ... */ :nth-child(6n-1), /* 5, 11, 17, 23, ... */ :nth-child(6n) /* 6, 12, 18, 24, ... */ ul { list-style: none; padding: 0; margin: 0; } li { display: inline-block; padding: 5px; } li:nth-child(6n-2), li:nth-child(6n-1), li:nth-child(6n)

delphi - Firemonkey TNumberBox - new value not available until losing focus -

using tnumberbox control (at least in windows, other platforms too), when type in new value, , press button ( tbutton ) save changes, upon reading tnumberbox.value property, it's returning original value before edit made. turns out, value not accessible until after control loses focus. now button used save changes, have deliberately disabled canfocus property, along buttons in app. because style use (jet), focused button looks horrible (black text on dark gray background). not mention, on mobile platforms, focus practically useless in case. otherwise, if don't disable canfocus on save button, focus taken off of tnumberbox , value property okay. but, when disabling canfocus on save button, focus never taken off of control, , therefore reading value property returns old value. how can ensure value property returns correct new value without changing save button canfocus ? enabling killfocusonreturn not useful, because users have aware need press "return&

Python Requests Removing __ (Double Underscore) From URL -

i'm using python requests send request. request parameters have variables contain double underscores. example: example.com/index.php?__action=login&__location=hub but, when using requests.get() , checking url used strips off variables contain double underscores. here's example: jsondata = json.dumps({ 'foo': 'bar' }) params = { 'data': urllib.quote_plus(jsondata), '__action': 'login', '__location': 'hub' } url = 'http://example.com/p/' resp = request.get(url, params=params) print resp.url the url isn't sending correctly, it's missing params contain double underscores. any ideas why? figured out. in fact not showing params in url (thought going mad). problem wasn't obvious though. resp.url showing url after page had redirected. redirecting because wasn't using https , server responded https requests. typo caused many headaches. allow_redirects=fal

AngularJS scope values undefined in link -

i'm trying figure out scope , link when directive initialized. have directive in tree controller display details @ branch point: <typelists sub="branch.subbranches[0]"></typelists> the (relevant parts of the) directive handles branch info below: listsapp.directive( 'typelists', function($rootscope) { return { restrict: 'ea', replace: true, scope: { branch : '=sub' }, templateurl: templatedir + '/typelists.html', link: function (scope, element, attrs) { console.log(scope,scope.branch); // debug // other stuff // (including working reload() , refresh() methods) scope.subject = 'type' + scope.branch.model.getfilter() + 'lists'; // catch $rootscope.$broadcasts branch $rootscope.$on( scope.subject+'refre

Extend Repository of a foreign TYPO3 extbase extension -

i have installed extension 'femanager' on typo3 6.2 installation , extended own fields stored , read database. now there action in controller calls upon userrepository findbyusergroup() method render list of fe_users filter. i want extend search filter, , therefore must alter method findbyusergroup() extension. possible, , if so, how? i have been developing lot typo3, not extbase. familiar hooks , signal/slots , these kinds, don't running. hints how make typo3 use repository extends 1 femanager? <?php namespace ngib\ngibmembers\domain\repository; use in2\femanager\domain\repository\userrepository; /*************************************************************** * copyright notice * * (c) 2013 alex kellner <alexander.kellner@in2code.de>, in2code * * rights reserved * * script part of typo3 project. typo3 project * free software; can redistribute and/or modify * under terms of gnu general public license published * free software fou

How to calculate RAM usage of a image when decoded -

how can determine ammount of ram used image when loaded? for standard think image size on ram width * height * pixel_format, pixel_format rgb (3 bits) or argb (4 bits) but calc, 64*64(argb) image have 2mb of memory usage, i'm pretty sure wrong result. is decoded image loaded compressed image , decompressed drawing/drawed compressed through decompressers algorithms?

regex - grep first n rows, return file name only -

i can following search need , return file name: grep -l "mysearchstring" ./*.xml files searching huge takes forever. string searching appear in first 200 rows how can search first 200 rows , still return file name? you can do: for file in *.xml; head -200 "$file" | grep -q "mysearchstring" && echo "$file" done

PHP MYSQL: User Delete his own post -

i have created forum people can register/login post topics , replies. now added delete link next each topic if pressed go deletetopic.php , if user has created topic deleted, if not, didn't create topic. this deletetopic.php <?php session_start(); include("config.php"); if(!isset($_session['uid'])){ echo "<p><b>error: please log in delete topic."; } if(isset($_session['username'])) { $uid = $_session['uid']; $id=$_get['id']; $query1=mysql_query("delete topics id='$id' , uid='$uid'"); if($query1){ header('location:index.php'); } else{ echo "<p><b>error: didnt make topic."; } } it doesnt work, gives me else {error} here tables: create table `users` ( `id` int(11) not null auto_increment, `firstname` varchar(255) not null, `lastname` varchar(255) not null, `email` varchar(2

Checking sudoku solution (reading matrix from file) Python -

need make program reads matrix .txt file , checks if sudoku solved correctly. .txt file name inserted in command line. has return either true or false. the sudoku checking part works, there trouble reading matrix file inserted in command line.

csv - Splitting a Dataframe Column in Python -

i trying drop rows pandas dataframe df . looks , has 180 rows , 2745 columns. want rid of rows have curv_typ of pyc_rt , ycif_rt . want rid of geo\time column. extracting data csv file , have realize curv_typ,maturity,bonds,geo\time , characters below pyc_rt,y1,gbaaa,ea in 1 column: curv_typ,maturity,bonds,geo\time 2015m06d16 2015m06d15 2015m06d11 \ 0 pyc_rt,y1,gbaaa,ea -0.24 -0.24 -0.24 1 pyc_rt,y1,gba_aaa,ea -0.02 -0.03 -0.10 2 pyc_rt,y10,gbaaa,ea 0.94 0.92 0.99 3 pyc_rt,y10,gba_aaa,ea 1.67 1.70 1.60 4 pyc_rt,y11,gbaaa,ea 1.03 1.01 1.09 i decided try , split column , drop resulting individual columns, getting error keyerror: 'curv_typ,maturity,bonds,geo\time' in last line of code df_new = pd.dataframe(df['curv_typ,maturity,bonds,geo\time'].str.split(

Getting variable encryption results with VB.Net and DES -

i'm working on semi-internal encryption process sensitive information. email addresses , like. i'm working few other developers @ sister companies on project, , requirements everyone's encryption can talk else's. use global password, encrypt , decrypt information onsite, , that's it. my problem encryption procedure, while matching theirs, giving me variable results. i'm polling our sql server strings encrypted in question, iterating through array of results, , updating server encrypted strings. the problem first string different subsequent strings, , isn't recognized valid testing software we're supposed basing our solution off of. second , subsequent strings come through fine. example: test@test.com - brpurplww7+vyrr5puj/jhxoip/mv5wr test@test.com - brpurplww79h+n4tgot0xrmm7sdwqqsy test@test.com - brpurplww79h+n4tgot0xrmm7sdwqqsy i can't quite figure out what's going on, because can encrypt , decrypt , forth on own machine no issue

excel - return time since last occurrence of a string for certain days of the week only -

Image
i working on scheduling sheet. want calculate distance in weeks since person last scheduled on 1 of 3 different 'jobs'. want @ time since last scheduled on weekend, , individuals may scheduled on weekdays intervening between last weekends. for example: date day_of_week task_a task_b task_c distance_a distance_b distance_c 7/1/2015 wednesday ed mary amy 0 0 0 7/2/2015 thursday bill judy bob 0 0 0 7/3/2015 friday ed mary amy 0 0 0 7/4/2015 saturday ed mary amy 0 0 0 7/5/2015 sunday ed mary amy 0 0 0 7/6/2015 monday bill mary bob 0 0 0 7/7/2015 tuesday ed judy amy 0 0 0 7/8/2015 wednesday ed amy bob 0 0 0 7/9/2015 thursday bob ed judy 0 0 0 7/10/2015 friday ed bob judy 0 0 0 7/11/2015 saturday ed bob judy 7 0 0 7/12/2015 su

scala - How to change HTTP status code of AsyncResult using Scalatra -

i have created simple controller (the code below obfuscated , simplified, assume ask returns future message). trying change http code other 200 (based on actor result). when executing code below see result come expected, 200 instead of 404 get("/:id") { new asyncresult() { val is: future[_] = ask(actor, message)(timeout.tomillis) is.oncomplete { res => res match { case success(result:any) => notfound(result) //not found example of different http code other 200 } } } another attempt was case success(result:any) => { this.status_ = (404) result } in case, receive nullpointerexception because response (httpservletresponse) null, due fact response on separate thread. tl;dr how can 1 conditionally change http code of asyncresult/future in scalatra? details scala 2.11.6 scalatra 2.3.0 akka 2.3.9 after digging in scalatra futuresupport mixin, found:

javascript - bootstrap datetimepicker disabling other fields -

i wondering bootstrap datetimepicker used storing date? want know how can use object/text/whatever may disable other textbox fields have on web page. i have 1 page setup querying against multiple gridviews, don't want user enter information multiple fields otherwise more 1 gridview returned. have gotten other textbox fields become disabled, including datetimepicker textbox fields, using below javascript (jquery): $("#tasknametext").keyup(function (e) { if ($(this).val() != '') { $("#textdate").attr('disabled', 'disabled'); $("#begindate").attr('disabled', 'disabled'); //datetimepicker field $("#enddate").attr('disabled', 'disabled'); //datetimepicker field2 $("#begindate2").attr('disabled', 'disabled'); //datetimepicker field3 $("#enddate2").attr('d

javascript - What is the best way to determine if a given number is a power of two? -

i need return true if n power of 2 , false otherwise. should go like: function poweroftwo(n){ //code here } this way : function ispoweroftwo(n){ var x = math.pow(2, math.round(math.log(n) / math.log(2))); return x; } are there more effective ways ? you can use ecmascript5 math.log : function poweroftwo(x) { return (math.log(x)/math.log(2)) % 1 === 0; } remember, in math, logarithm arbitrary base, can divide log 10 of operand ( x in case) log 10 of base. , see if number regular integer (and not floating point), check if remainder 0 using modulus % operator. in ecmascript6 can this: function poweroftwo(x) { return math.log2(x) % 1 === 0; } see mdn docs math.log2 .

localization - Loading of Java message properties for internalization -

i have following java i18n message class.: public class messages { private static final string bundle_name = "languages.message"; private static final resourcebundle resource_bundle = resourcebundle.getbundle(bundle_name); private messages() { } public static string geti18n(string key) { try { return resource_bundle.getstring(key); } catch (missingresourceexception e) { return '!' + key + '!'; } } public static string geti18n(string key, object... params ) { try { return messageformat.format(resource_bundle.getstring(key), params); } catch (missingresourceexception e) { return '!' + key + '!'; } } } i have created following message properties files.: message.properties message_de.properties message_de_de.properties in program translation according default locale of system. if de_de , german message pr

python - How to subclass a class that has a __new__ and relies on the value of cls? -

my specific use case i'm trying subclass pathlib.path . want able add or override functionality, want inherit of path. path has __new__ , in has: if cls path: cls = windowspath if os.name == 'nt' else posixpath in other words, path requires passing proper class it. problem don't know how both create class , call path.__new__ cls == path . i've tried many things , each 1 gives me different problem. 1 gives me attributeerror: type object 'rpath' has no attribute '_flavour' because i'm trying override parent class. python3: class rpath(path): def __new__(cls, basedir, *args, **kwargs): return path.__new__(cls, *args, **kwargs) def __init__(self, basedir, *pathsegs): super().__init__() self.basedir = basedir def newfunction(self): print('something new') and 1 gives returns path object, , hence doesn't allow me overrides. def __new__(cls, basedir, *args, **kwargs):

xml - xslt condition output one by one -

hope has suggestion this: i need have in each 'a', 'b' have @n equal or bigger @n of 'a' in are. i using xslt 2.0 , saxon-he 9.6.0.5 xml source: <blabla> <a n="2"></a> <a n="6"></a> <b n="6"></b> <b n="1"></b> <b n="4"></b> </blabla> xslt: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/xsl/transform" xmlns:xs="http://www.w3.org/2001/xmlschema" exclude-result-prefixes="xs" version="2.0"> <xsl:template match="blabla"> <all> <xsl:for-each select="//a"> <a> <xsl:attribute name="n" select="./@n"/> <xsl:for-each select="//b"> <xsl:if test="./@n[. >= //a/@n]">

compiler construction - Computing the FOLLOW() set of a grammar -

i'm reading compilers: principles, techniques, , tools (2nd edition) , i'm trying compute follow() sets of following grammar: s → ietss' | s' → es | ε e → b where s, s', e non-terminal symbols, s start symbol, i, t, a, e, b terminal symbols, , ε empty string. what i've done far follow(s) = {$} ∪ follow(s') follow(s') = follow(s) follow(e) = first(tss') - {ε} = first(t) - {ε} = {t} - {ε} = {t} where $ input right endmaker . explanation $ ∈ follow(s) , since s start symbol. know s' → es , in follow(s') in follow(s) . therefore, follow(s) = {$} ∪ follow(s') . we know s → ietss' , in follow(s) in follow(s') . therefore, follow(s') = follow(s) . the problem can't compute follow(s) , since don't know follow(s') . ideas? the simple algorithm, described in text, least fixed-point computation. cycle through nonterminals, putting terminals follow sets, until through entire

python - pandas dataframe drop columns by number of nan -

i have dataframe columns containing nan. i'd drop columns number of nan. example, in following code, i'd drop column 2 or more nan. in case, column 'c' dropped , 'a' , 'b' kept. how can implement it? import pandas pd import numpy np dff = pd.dataframe(np.random.randn(10,3), columns=list('abc')) dff.iloc[3,0] = np.nan dff.iloc[6,1] = np.nan dff.iloc[5:8,2] = np.nan print dff there thresh param dropna , need pass length of df - number of nan values want threshold: in [13]: dff.dropna(thresh=len(dff) - 2, axis=1) out[13]: b 0 0.517199 -0.806304 1 -0.643074 0.229602 2 0.656728 0.535155 3 nan -0.162345 4 -0.309663 -0.783539 5 1.244725 -0.274514 6 -0.254232 nan 7 -1.242430 0.228660 8 -0.311874 -0.448886 9 -0.984453 -0.755416 so above drop column not meet criteria of length of df (number of rows) - 2 number of non-na values.

python - KeyError when using melt to restructure Dataframe -

i have dataframe looks follows , has 2628 rows , 101 columns. want convert years row associated numbers 0.08333 0.16666 0.249999 , on, column: years currency 0.08333333 0.16666666 0.24999999 0.33333332 \ 2005-01-04 gbp 4.709456 4.633861 4.586271 4.567017 2005-01-05 gbp 4.713099 4.649220 4.606802 4.588313 2005-01-06 gbp 4.707237 4.646861 4.609294 4.593076 the code follows, combined_data dataframe. used melt error keyerror: 'years' , don't know how handle this: from pandas.io.excel import read_excel import pandas pd import numpy np url = 'http://www.bankofengland.co.uk/statistics/documents/yieldcurve/uknom05_mdaily.xls' # check sheet number, spot: 9/9, short end 7/9 spot_curve = read_excel(url, sheetname=8) short_end_spot_curve = read_excel(url, sheetname=6) # cleaning, keep nan now, forward fill nan not recommended yield curve spot_curve.columns = spot_curve.loc['years:'] spo

vb.net - Replacing string at certain index of Split -

using streamreader read line line of text file. when line (i.e., 123|abc|99999||ded||789), want replace first empty area text. so far, i've been toying with if sline.split("|")(3) = "" 'this i'm stuck, want replace index mmm end if i want output this: 123|abc|99999|mmm|ded||789 you split string, modify array , rejoin recreate string: dim sline = "123|abc|99999||ded||789" dim parts = sline.split("|") if parts(3) = "" parts(3) = "mmm" sline = string.join("|", parts) end if

java - Android RecyclerView OnClickListener not reacting -

ok, i'm using recyclerview in project , need implement click listener each list item , icon in each of items. what tried solution: https://stackoverflow.com/a/24933117/722462 cause looks pretty nice me. couldn't click listener react click events. ideas wrong implementation? files listed below. fragment_search.xml: <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" android:paddingbottom="@dimen/activity_vertical_margin" tools:context=".mainactivityfragment"> <android.support.v7.widget.recyclerview android:id="@+id/sea

linux - What is the difference between .so.3.0 and .so in opencv? -

after installing opencv 3 on linux system noticed every .so file there corresponding .so.3.0 file. extension differentiate between 2 different files, or .so.3.0 different kind of shared library? haven't seen convention used anywhere else thought little odd. a detailed explanation provided here https://serverfault.com/questions/401762/solaris-what-is-the-difference-between-so-and-so-1-files/402595#402595 essentially, .so file symbolic link .so.3.0, actual shared library file. .so specifies version of library file should used.

c# - In my model, what element type do I use for a SQL table column of type smalldatetime? -

i have table dates columns fileid of type int , dtime of time smalldatetime . meant keep track of date , time file uploaded. should ??? in following piece of model? should string, , if so, have parse string use (e.g. if have functionality in server deleting files on 30 days old)? [table(name = "dates")] public class date { public date() { } [column] public int fileid { get; set; } [column] public ??? dtime { get; set; } } just use datetime. source: msdn official data type mappings list

javascript - Performing ajax with Python Flask -

i'm trying simple yet not able figure out because of no experience working scripting languages , after going through tutorials. closest match want kind of found @ link . when clicks on following link want value attribute returned same template link i'm creating in can use array's index argument. <a href="/disable?server={{count + loop.index0}}" id="servercount" value="{{ count + loop.index0 }}"> click disable </a> the javascript/json/ajax have is: {% block scripts %} {{ super() }} <script type=text/javascript> $(function() { $('a#servercount').bind('click', function() { $.getjson('/disable', { a: document.getelementbyid("servercount").getattribute("value") }, function(data) { $("#result").text(data.result); }); return false; }); }); </script> {% endblock %} i'm sure able realize have not work. i'm po

c# - Get parameters outside of Grouping Linq -

i need field's out of group using linq example, code: (from paymenttypes in paymenttypes_datatable.asenumerable() join cashtransactions in cashtransactions_datatable.asenumerable() on paymenttypes.field<int32>("cashpaymenttype_id") equals cashtransactions.field<int32>("cashpaymenttype_id") joinedcashtransactions cashtransactions in joinedcashtransactions.defaultifempty() group cashtransactions paymenttypes.field<int32>("cashpaymenttype_id") grouppaymenttypes select new { cashpaymenttype_id = 0, // paymenttypeid cashpaymenttype_name = "", // paymenttypename cashtransaction_amount = grouppaymenttypes.sum(a => != null ? (a.field<int32>("cashtransactionstatus_id") == 1 || a.field<int32>("cashtransactionstatus_id") == 3 ? 1 : -1) * a.field<double>("cashtransaction_amount") : 0.00), }).aggregate(paym

mocking - Using Mockito, how do I test a 'finite loop' with a boolean condition? -

using mockito, how test 'finite loop' ? i have method want test looks this: public void dismisssearchareasuggestions() { while (aresearchareasuggestionsvisible()) { clicksearchareafield(); sleeper.sleeptight(costtestbase.half_second); } } and, want test first 2 calls 'aresearchareasuggestionsvisible' return true, so: mockito.when(mockelementstate.iselementfoundandvisible(landingpage.address_suggestions, testbase.one_second)).thenreturn(boolean.true); but, third call false. mockito.when(mockelementstate.iselementfoundandvisible(landingpage.address_suggestions, testbase.one_second)).thenreturn(boolean.false); how mockito in 1 single test method? here test class far: @test public void testdismisssearchareasuggestionswhenvisible() { mockito.when(mockelementstate.iselementfoundandvisible(landingpage.address_suggestions, costtestbase.one_second)).thenreturn(boolean.true); landingpage.dismisssearchareasuggestio