Posts

Showing posts from January, 2014

python - Looping over groups in a grouped dataframe -

consider small example: data={"x":[1, 2, 3, 4, 5], "y":[6, 7, 8, 9, 10], "z": [11, 12, 13, 14, 15]) frame=pd.dataframe(data,columns=["x","y","z"],index=["a","a","a","b","b"]) i want group "frame" with grouped=frame.groupby(frame.index) now want loop on groups by: for group in grouped: but next step not manage: how can extract group in each loop pandas data frame, can further process it? df.groupby returns list of 2-tuples: index, , group. can iterate on each group this: for _, g in frame.groupby(frame.index): .... # `g` however, if want perform operation on groups, there better ways iteration. wiki

html - Navbar - Trying to get nav bar to appear on top of page -

Image
currently navbar appearing on left side of page instead of on top of page. have included codepen of site looks , picture of how nav bar displayed. nav bar appear @ top of page, survey on left, , results on right side. if appreciated! codepen <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>survey</title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <link rel="stylesheet" href="style.css"> <!-- <link rel="stylesheet" href="flexbox.css"> --> </head> <body> <main class="content" role="main"> <header class="main-header"> <h1 class="name"><a href="#">keypath survey</a></h1> <ul class="mai

c# - How can i shorten this new object code? -

i know silly question , easy i'm staring screen 3 hours , still can't seem figure out. idea how shorten code? have public enum type , public enum size in class car.cs. car car1 = new car((cartype)0, (size)0); car car2 = new car((cartype)0, (size)1); car car3 = new car((cartype)0, (size)2); car car4 = new car((cartype)1, (size)0); car car5 = new car((cartype)1, (size)1); car car6 = new car((cartype)1, (size)2); car car7 = new car((cartype)2, (size)0); car car8 = new car((cartype)2, (size)1); car car9 = new car((cartype)2, (size)2); edit: print them method this group1print(car1, car2, car3); group2print(car4, car5, car6); group3print(car7, car8, car9); try this: var cars = new list<car>(); foreach (type type in enum.getvalues(typeof(type))) { foreach (size size in enum.getvalues(typeof(size))) {

Can I retrieve a specific script src from multiple websites using Excel VBA -

<script src="blah blah blah" type="text/javascript"></script> so code above present in body part of html code. need retrieve url queries multiple web sites. possible use excel macro make automation retrieves specific src? wiki

asp.net mvc - How could I render a view containing custom display templates into a compiled view? -

my mvc view makes calls html.displayfor() , display templates within make calls other html.displayfor(). i need render type of view contains custom display templates string , wrote method this: public static string renderrazorview(dynamic model, string viewpath, httpcontextbase httpcontextbase) { using (var sw = new stringwriter()) { viewdatadictionary viewdata = new viewdatadictionary(); viewdata.model = model; controllercontext controllercontext = new controllercontext(new requestcontext(httpcontextbase, routetable.routes.getroutedata(httpcontextbase)), new tempcontroller()); razorview view = new razorview(controllercontext, viewpath, null, false, null); view.render(new viewcontext(controllercontext, view, viewdata, new tempdatadictionary(), sw), sw); return sw.getstringbuilder().tostring(); } } and called in way: var bookdisplay = new bookdisplaymodel(model); var data = renderrazorview(bookd

linux - Hadoop No space left on device erro when there is space available -

i have 5 linux machines cluster. there 3 data nodes , 1 master. @ 50% hdfs storage available on each data nodes. run mapreduce job, failed following error 2017-08-21 17:58:47,627 warn org.apache.hadoop.hdfs.dfsclient: error recovery blk_6835454799524976171_3615612 bad datanode[0] 10.11.1.42:50010 2017-08-21 17:58:47,628 warn org.apache.hadoop.hdfs.dfsclient: error recovery block blk_6835454799524976171_3615612 in pipeline 10.11.1.42:50010, 10.11.1.43:50010: bad datanode 10.11.1.42:50010 2017-08-21 17:58:51,785 error org.apache.hadoop.mapred.child: error in synclogs: java.io.ioexception: no space left on device while on each system df -h gives following information filesystem size used avail use% mounted on devtmpfs 5.9g 0 5.9g 0% /dev tmpfs 5.9g 84k 5.9g 1% /dev/shm tmpfs 5.9g 9.1m 5.9g 1% /run tmpfs 5.9g 0 5.9g 0% /sys/fs/cgroup /dev/mapper/centos-root 50g 6.8g

c# - Xamarin Forms ListView for iOS: Always Show ScrollBar -

Image
i have productlist of type observablecollection<product> product class given below: public class product { public int id { get; set; } public string name { get; set; } public string path { get; set; } } in xamarin forms ios application, have listview itemsource productlist . when number of products in productlist height of listview not enough show of them, additional items can reached scrolling listview . however, want scrollbar displayed when scrolling listview displayed always. possible or should try ui besides listviev able show scrollbar. there solutions xamarin.android couldn't find effective solution ios app. thank much... as @cole commented, flashscrollindicators can show indicator short time. so, have customize scroll indicator. create custom renderer of listview , add custom scroll indicator , this: public class mylistviewrenderer : listviewrenderer { public uiview bar; protected override void o

android - Design preview not showing any device options -

Image
i using android studio 3.0 beta 2 version , cannot design preview show. there no devices available in dropdown. have tried adding new device definition. this looks like: this want: what doing wrong? i think need update sdk apis wiki

swift3 - How to filter the values of a string array in a struct object substring wise -

i want check value there in section object.this code working fine if write complete name in filtered object.i need filtered data when search test matches substring in string array ["a": ["affenpoo", "affenpug", "affenshire", "affenwich", "afghan collie", "afghan hound"], "b": ["bagle hound", "boxer"]] struct objects { var sectionname : string! var sectionobjects : [string] var sectionid:[string]! var sectionph:[string]! var sectionimage:[string]! } var objectarray = [objects]() var objectarrayfilter = [objects]() objectarrayfilter = objectarray.filter({$0.sectionobjects.contains(searchbar.text!)}) if want filter if enter string afg in uitextfield should return 2 object "afghan collie", "afghan hound" section a , can make this. objectarr

Date Time Functions in Algolia -

i have object in algolia - { … “startdate”: “2013-09-26t00:00:00.000+05:30”, “enddate”: “2017-10-25t10:08:44.000+05:30”, … } now, while retrieving object want add field - “endingin”: “ending in 9 days” “endingin” days remaining todays date till enddate. example: val daysleft = days.daysbetween(datetime.now,datetime.parse(enddate)).getdays <br> val endingin = s"ending in $daysleft days" is possible? thanks in advance. you can use transformdata. doc :method used change object passed item template wiki

html - CSS color transition behavior for images with transparent backgrounds -

i've noticed unanticipated effect of using css color transitions on image transparent background. here's example: :root { --size: 4em; --duration: 5s; } html, body { margin: 0; background: slategray; color: white; } .main-menu { overflow: hidden; background: black; } .main-menu *:hover { background: skyblue; -webkit-transition-duration: 5s; transition-duration: var(--duration); } .image-div { float: right; padding: calc(var(--size) / 2); -webkit-transition-duration: 5s; transition-duration: var(--duration); } .image { max-width: var(--size); } <div class="main-menu"> <div class="image-div"> <img class="image" src="https://s4.postimg.org/5zy6kjqcd/maximize.png"/> </div> </div> to summarize, issue this. if hover on image-div div's padding, background color of div , contained image div execute color transition @ same ra

Cancelling JavaScript execution in chrome after redirect (and cancelling requests) -

the scenario in our website follows: user clicks button we start timer 3seconds we make backend request in meantime we redirect user different website after 3s what observing is, @ end of 3 seconds, chrome cancels on-going request made in step 3 (since has not completed). code configured in such way retries if ongoing request fails. expecting chrome cancel further code execution after canceling request. chrome continues execute retry. have 1 cancelled call , 1 retry request (even though 1st call might have succeeded). result end lot of duplicates. is there way force chrome stop executing scripts after has decided redirect new page , cancelled 1st request? wiki

php - Call to undefined function mime_content_type() -

using suite crm 7.9.1 . newbie suitecrm. i created person form in campaigns module . created . when tried download , got below error . fatal error: uncaught error: call undefined function mime_content_type() in /home/testsite/public_html/download.php:180 stack trace: #0 /home/testsite/public_html/include/mvc/controller/sugarcontroller.php(1007): require_once() #1 /home/testsite/public_html/include/mvc/controller/sugarcontroller.php(458): sugarcontroller->handleentrypoint() #2 /home/testsite/public_html/include/mvc/controller/sugarcontroller.php(366): sugarcontroller->process() #3 /home/testsite/public_html/include/mvc/sugarapplication.php(108): sugarcontroller->execute() #4 /home/testsite/public_html/index.php(53): sugarapplication->execute() #5 {main} thrown in /home/testsite/public_html/download.php on line 180 when browsed on error got solution install extension . using php 7 . adding extensions cpanel in live , safe .. shared host , affects other php project

xamarin - How can I create a custom TableView that will allow me to specify footer height and text and space out the text just like in the iOS settings page? -

Image
i saw example: xamarin forms - how create custom render give tablesection default ios footer? it 75% of looking code: using coregraphics; using foundation; using uikit; using xamarin.forms; using xamarin.forms.platform.ios; [assembly: exportrenderer(typeof(tableview), typeof(japanese.ios.tableviewcustomrenderer))] namespace japanese.ios { public class tableviewcustomrenderer : tableviewrenderer { uitableview tableview; protected override void onelementchanged(elementchangedeventargs<tableview> e) { base.onelementchanged(e); if (control == null) return; var tableview = control uitableview; var formstableview = element tableview; tableview.weakdelegate = new customfootertableviewmodelrenderer(formstableview); } void current_propertychanged(object sender, system.componentmodel.propertychangedeventargs e) { } private clas

r - AUC metrics on XGBoost -

i build model prediction xgboost: setdt(train) setdt(test) labels <- train$goal ts_label <- test$goal new_tr <- model.matrix(~.+0,data = train[,-c("goal"),with=f]) new_ts <- model.matrix(~.+0,data = test[,-c("goal"),with=f]) labels <- as.numeric(labels)-1 ts_label <- as.numeric(ts_label)-1 dtrain <- xgb.dmatrix(data = new_tr,label = labels) dtest <- xgb.dmatrix(data = new_ts,label=ts_label) params <- list(booster = "gbtree", objective = "binary:logistic", eta=0.3, gamma=0, max_depth=6, min_child_weight=1, subsample=1, colsample_bytree=1) xgb1 <- xgb.train(params = params, data = dtrain, nrounds = 291, watchlist = list(val=dtest,train=dtrain), print_every_n = 10, early_stop_round = 10, maximize = f , eval_metric = "error") xgbpred <- predict(xgb1,dtest) xgbpred <- ifelse(xgbpred > 0.5,1,0) confusionmatrix(xgbpred, ts_label) confusion matrix , statistics

html - Angular - select placeholder not showing -

there reason why simple code won't work? i'm trying have placeholder on select, shows 1 of other options in list. <div *ngfor="let d of formdatirichiesta" class="form-row"> <select *ngif="d.type=='select'" class="form-control" name="{{d.name}}" [(ngmodel)]="model[d.name]" required> <option selected disabled>{{d.placeholder}}</option> <option *ngfor="let b of elencobanche" value="{{b.id}}">{{b.denominazione}}</option> </select> </div> i'm using angular4 . thanks. --edit-- found out if delete [ (ngmodel)]="model[d.name]" works fine. hint? that's how supposed work. attribute disabled can't choose option. but add hidden attribute hide it: <option value="" selecte

Getting data from xml respose in nifi -

Image
after strating invokehttp processor response data that: <response xmlns=""> <result> <responsestatus>false</responsestatus> <error> <errorcode>-7</errorcode> <errordescription>not foudn</errordescription> </error> </result> </response> i needed value of errorcode (-7) have added evaluatexpath processor attribute errorcode used command //error/errorcode/text() can't reitreive data of errorcode in attribute errorcode( in flowfile after processing evaluatexpath errorcode attribute doesn't have value ,is empty string) how can value of errrorcode? to extract desired value, use xpath expression //errorcode . return string value -7 . selecting destination flowfile-attribute , can keep flowfile content constant , put new value in flowfile attribute (i.e. named attribute ). you can chain matched relationship updateattribute processor has expression ${attribute:tonumber(

java - App is getting killed even after using Service -

i want make app run after removed app tray user. after terminating app ,it didn't pertain in background. created myservice class has asynctask download content web. works fine unable run in background. should change int this? my mainactivity.java is: package com.example.shubhamrajput.notify; import ... public class mainactivity extends appcompatactivity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); startservice(new intent(this, myservice.class)); } } // myservice.java package com.example.shubhamrajput.notify; import ... public class myservice extends service { private int minterval = 2000; private handler mhandler; string result=null; public class downloadtask extends asynctask<string, void, string> { //code here } } void updatetask(){ download

json - Register internal ionic app path as REST provider -

for reasons i'd build in-app rest endpoint in ionic 3 app. frontend components should able call data in-app backend simple http.request. i.e. so: this.http.request("/#/api/local/getusers", requestoptions).subscribe( (rc) => { console.log(rc.text()); }, (err) => { console.log(err) } ); the result of request should json list of valid users (whatever, determined registered controller , request parameters). i have succeeded register path component so: @ionicpage({ name: 'api', segment: 'local/:method', }) @component({ selector: 'page-fgttm', templateurl: 'fgttm.html', }) export class fgttmpage ... and when navigate /#/api/local/getusers can see (unfortunately html) output written in fgttm.html. this.http.request("/#/api/local/getusers" recieves plain index.html template (far away json @ least 200). what missing here? there way bind ionic-provider path (like controller in angular or drupal

linker - Mingw static link libstdc++ -

for work purpose need produce shared library modelica file (.mo) , load in matlab. reasons, matlab uses different version of libstdc++-6 causes conflict 1 needed shared library. here command line i'm using generate .o files. .mo file transformed c files. gcc -falign-functions -msse2 -mfpmath=sse -iinclude/ -iinclude/fmi1 -i. -domc_model_prefix=genrou -domc_num_mixed_systems=0 -domc_num_linear_systems=0 -domc_num_nonlinear_systems=0 -domc_ndelay_expressions=0 -domc_nvar_string=0 -c -o genrou.o genrou.c a bunch of .o files being genereted, , reasons of brevity ommit others, same. and here problematic command line g++ -shared -i. -o genrou.dll genrou_fmu.o genrou.o genrou_functions.o genrou_records.o genrou_01exo.o genrou_02nls.o genrou_03lsy.o genrou_04set.o genrou_05evt.o genrou_06inz.o genrou_07dly.o genrou_08bnd.o genrou_09alg.o genrou_10asr.o genrou_11mix.o genrou_12jac.o genrou_13opt.o genrou_14lnz.o genrou_15syn.o genrou_16dae.o genrou_init_fmu.o -iinclud

Powershell running Java Script to Encrypt Password -

we have number of lanier mfps use scan-to-folder option allow people documents, , starting implement more security measures on ad passwords use forcing password reset. unfortunately, laniers use proprietary encryption passwords. i've managed functional java command encrypt passwords format. problem i've been encountering have encoded password powershell pass scanner. i can run java command through command line, can't pass encrypted password powershell string printer accept (it needs in base64). if pass encoded password powershell, run through powershell's base64 creation process, is, obviously, changed scanner use it. what need determine whether there's way me take following command line command, , run in powershell, provide me output can pass printer. java -cp ./commons-codec-1.10.jar;. cdm.gwpwescharacterencoding %pass% "gwpwes002" the java command outputs base64 string based on following line: return new string(base64.encodebase64((byte[

hover - Sublime text 3 Definition on mouse over function display strange -

i'm using sublime text 3 version 3126, when put mouse on function, list of files using function. display wrong shown in attached image. please this. thanks lot. files using function displayed wrongly i using following packages: convertchinesecharacters, converttoutf8, codecs33, ctags, svn, package control, sidebarenhancements wiki

javascript - How to convert tooltip to onclick event in high charts? -

i have column highchart on mouseover entire month values showing want 1 place value on click event i having mouse on functionality. need tooltip on mouse click event in highcharts. highcharts.chart('container', { title: { text: 'mouse events demo' }, subtitle: { text: 'on point mouse click, values should reported in top left' }, plotoptions: { series: { point: { events: { mouseover: function() { var chart = this.series.chart; if (!chart.lbl) { chart.lbl = chart.renderer.label('') .attr({ padding: 10, r: 10, fill: highcharts.getoptions().colors[1] }) .css({

php - mysqli array fetching is not getting data -

i have fetch result in single row can't run multiple rows. how can fix this? $stmt = $this->conn->prepare("select * user id=?"); $stmt->bind_param("s", $id); if($stmt->execute()){ $result = $stmt->get_result()->fetch_array(mysqli_assoc); $stmt->close(); return $result; } i got result wise {"id":2,"name":"anju"} but need user result .my code here $stmt = $this->conn->prepare("select * user id=?"); $stmt->bind_param("s", $id); if($stmt->execute()){ $result = array(); while ($row = $stmt->get_result()->fetch_array(mysqli_assoc)) { $result[] = $row; } $stmt->close(); return $result; } i got error fatal error: call member function fetch_array() on non-object in line 5 the line is: while ($row = $stmt->get_result()->fetch_array(mysqli_assoc)) my expecting result {"id":1,"name":"obi"}, {"id":3,

akka actor child troubles -

i realy surprised case. have body thoughts why happen? this works fine each time: child(name) match { case some(ref) => ref ! ping case _ => val ref = actorof(pingactor.props, name) ref ! ping } we create actor if child not exist. , send ping message. this sometime hangs on case of actor exist: child(name) getorelse actorof(pingactor.props, name) ! getstate why? short answer because of operator precedence message sent when child(name) returns none , i.e. getorelse invoked. use non-infix method invocation avoid this: child(name).getorelse(actorof(pingactor.props, name)) ! getstate long answer as per scala language specification , infix operations in scala left-associative, , evaluated left right. if case here code work fine. however there operator precedence rules allow usual mathematical , logic operations without parenthesis. according them, ! operator has higher precedence getorelse , evaluated prior it, sending message '

jasper reports - Subreport with return value gives exception "System is not facet valid with enumeration" -

i'm getting exception during compile in jaspersoft studio 6.4.0. how address this? i've created report containing subreport want return value. that, have: created variable in subreport called, "logtotal", set value of variable, summation calculated in report. no reset type, no calculation function. created variable in main report same name , type. no reset type, no calculation function. in main report, created subreport return value link between 2 variables calculation type, "system." on compile, i'm seeing following exception: net.sf.jasperreports.engine.jrexception: org.xml.sax.saxparseexception; linenumber: 454; columnnumber: 91; cvc-enumeration-valid: value 'system' not facet-valid respect enumeration '[nothing, count, distinctcount, sum, average, lowest, highest, standarddeviation, variance, first]'. must value enumeration. i can choose "system" choice if use other choices ("no calculation function,

python - When making a set out of sorted list, the output set is not sorted -

this question has answer here: understanding set() function 5 answers could please explain me why making set out of sorted list results in set not sorted? list.sort() should sort list in place, does. set(list) should return unique values of list, does. but why resulting set not sorted? need make set, turn list2 , sort list2? (using python 2.7.6) code: def longest(s1, s2): list = [] s = s1 + s2 letter in s: list.append(letter) print list list.sort() print list unique = set(list) print unique s4 = "" item in unique: s4 = s4 + item print s4 return s4 console output: ['a', 'r', 'e', 't', 'h', 'e', 'y', 'h', 'e', 'r', 'e', 'y', 'e', 's', 't', 'h', 'e

postgresql - Postgres replication + incremental backup -

i'm using postgresql 9.6. is possible have replication , incremental backup on same setup i have high availability setup. on main site have 2 servers replication between them , pgpool handle failover in case primary server goes down. i have remote site geographical redundancy. site active if main site no longer functioning. remote site not need updated in real-time. therefore, if saves resources thought having incremental backup , restore main site remote site. in other words main site primary server replicate data main site secondary server. in addition generate incremental backup , backup restored on remote site. from answer understood possible have both replication , incremental backup. however, solution better (resource consumption, reliability etc.) have replication both main secondary server , remote site server? yes, can have pitr , streaming replication in use @ same time. streaming replication can fall restoring wal archive if loses direct conn

arrays - MATLAB - Element-wise matrix multiplication using two different sizes matrices -

i element-wise matrix multiplication using following 2x2x3 matrix in matlab >> filter_1 filter_1(:,:,1) = 0 1 0 0 filter_1(:,:,2) = 1 0 0 1 filter_1(:,:,3) = 0 0 1 0 this matrix turn out 0 elements in matrix dimensions if used in element-wise multiplication. example, given 2x2x3 matrix: >> frames_original{1} ans(:,:,1) = 92 87 93 93 ans(:,:,2) = 69 66 72 71 ans(:,:,3) = 42 40 40 43 if element-wise matrix multiplication, let values remain in resulting matrix, others turn out zero: >> filtered=double(frames_original{1}).*filter_1 filtered(:,:,1) = 0 87 0 0 filtered(:,:,2) = 69 0 0 71 filtered(:,:,3) = 0 0 40 0 however, works if both matrices of same size (2x2x3). now, suppose have big matrix, 1500x1500x3 matrix. how 'slide' 2x2x3 window performing element-wise multiplication dealing matrix b

How to use MySQL with conda/Python 3.6 -

i'm trying use python mysql, following online tutorial. in tutorial installs mysql on ubuntu, i'm using windows anaconda. want start mysql, basic command "mysql -u root -p", assume same on conda. i've installed mysql downloading , going through easy installer (mysql workbench works). i've installed "mysqlclient" using pip. i've installed "pymysql" , "mysql-connector-python" using conda. i still not able start mysql through conda. have experience mysql, new python , anaconda. i have python 3.6 installed, mysql 5.6, windows 10. right when try start mysql through anaconda (>mysql) says "mysql not recognized..." i'm assuming can use conda terminal in linux enter mysql. in question how use mysql anaconda's python ide answered downloading "pymysql" i've done. there more installing it? if runs same issue. first of had go task manager > services, , switch mysql "runni