Posts

Showing posts from August, 2015

Integrating over an interpolate function (interp1d) in python -

i trying double integration on interpolated function, in r = r(x,y) . from scipy import interpolate import scipy sp r = [0, 1, 2] z = [0, 1, 2] def cartesian(x, y, f): r = sp.sqrt(x**2 + y**2) return f(r) interp = interpolate.interp1d(r, z) print(cart(1,1,interp)) = sp.integrate.dblquad(cart, 0, 1, lambda x: 0, lambda x: 1, args=(interp)) print(a) executing cartesian function once produces correct answer. integral gives the following error: typeerror: integrate() argument after * must iterable, not interp1d i don't understand why function isn't iterable , not know how convert iterable form. many help. args supposed sequence of arguments, so: sp.integrate.dblquad(cart, 0, 1, lambda x: 0, lambda x: 1, args=(interp,)) the comma after interp critical: in python, (x) x , (x,) tuple (i.e. sequence).

python - Add successive rows in Pandas if they match on some columns -

i have dataframe following one: id url seconds 1 email 9 1 email 3 1 app 5 1 app 9 1 faceboook 50 1 faceboook 7 1 faceboook 39 1 faceboook 10 1 email 39 1 email 5 1 email 57 1 faceboook 7 1 faceboook 32 1 faceboook 3 2 app 11 2 app 10 2 email 56 2 faceboook 9 2 faceboook 46 2 faceboook 16 2 email 21 i want sum 'seconds' column successive views of same url same id. that's result i'm looking for: id url seconds 1 email 12 1 app 14 1 faceboook 106 1 email 101 1 faceboook 42 2 app 21 2 email 56 2 faceboook 71 2 email 21 df.groupby(['id', 'url']).sum() not work in case sum cases of same url same id, not successive ones. any ideas? you can use groupby series created compare ne column url , shifted, last use cumsum boolean mas

javascript - When to bind this keyword to an event handler in react? -

so, let's have class named search simple input field submit button. here's code that. class search extends component { constructor(props){ super(props); this.state = {term: ''}; this.handlechange = this.handlechange.bind(this); } handlechange(e) { console.log(this); console.log(e.target.value); this.setstate({term: e.target.value}); } render() { return ( <form classname='input-group'> <input classname='form-control' placeholder='city' onchange={this.handlechange} value={this.state.value}/> <span classname='input-group-btn'> <button type='submit' classname='btn btn-primary'>submit</button> </span> </form> ) } }

c++ - Why does my application crash on exit after invoked QNetowrkAccessManager::get? -

i using qt 5.7 32bit in visual studio 2015. want http qnetworkaccessmanager. but, application crashed when closing application. because, when calling qnetworkmanager::get function , closing window, access violation exception occurs in qnetwork.dll , application abort . (if comment out line calling qnetworkmanager::get function, abnormal termination doesn't occur.) specifically, call stack follows. happened in qnetwork.dll , others. ntdll.dll!7770904e() unknown [frames below may incorrect and/or missing, no symbols loaded ntdll.dll] [external code] libeay32.dll!020b122e() unknown libeay32.dll!02120e0c() unknown libeay32.dll!02117592() unknown libeay32.dll!021176cb() unknown libeay32.dll!0211764c() unknown libeay32.dll!021177e0() unknown libeay32.dll!021174e0() unknown libeay32.dll!02113d7e() unknown qt5networkd.dll!q_x509_free(x509_st * a) line 354 c++ qt5networkd.dll!qsslcertificateprivate::~qsslcertificateprivate() line 92 c++ [external code] qt5networkd.dll!qexplicitlys

python - How to store Gzipped content in Aerospike (cache)? -

i'm using aerospike python client here. don't find problem while storing plain string in cache because when retrieve key, same string saved when conn.get(key) import aerospike conn_aerospike_config = {'hosts': [('127.0.0.1', 3000)]} conn = aerospike.client(conn_aerospike_config).connect() key = ('namspace_name', 'set_name', 'key_name') value = "some big string" conn.put(key, {'value': value}) if want save gzipped content in place of value, don't find error i'm unable exact content. from gzip import gzipfile io import bytesio def compress_string(s): zbuf = bytesio() gzipfile(mode='wb', compresslevel=6, fileobj=zbuf, mtime=0) zfile: zfile.write(s) return zbuf.getvalue() put_value = compress_string(value) conn.put(key, {'value': put_value}) _, _, get_value = conn.get(key) i checked printing values of put_value, get_value. don't match, , need gzipped content, beca

Determine latest file from SFTP server using java jsch -

is there way determine name of latest file on unix server using java jsch? i want copy latest file server local machine. have working code that. i'm not able identify latest file. folder contains many files in below format:- report dd/mm/yyyy hh:ss i tried code mentioned in this post isn't picking latest file. code never seems stop executing. any appreciated. according post referred this post there code line says filter xml file have changed check file format list = main.chansftp.ls("*.xml"); also there sleep method called on executing thread 1 minute thread.sleep(60000); so expect code run atleast minute this might help

How to connect slack app to webhook? -

how can above keep getting following error when try , interact accompanying button. darn – didn't work. slack apps can add interactive elements messages interactive buttons of features work if use slack app. 1 reason need place configure url of script slack send request when clicking on button. work webhooks, if webhook part of slack app. not work simple custom webhook. to make slack app slack team need follow 2 steps. create new slack app (e.g. on page ) install slack app in slack team oath. (see here ) note not need publish slack app slack app directory. optional.

How to set up selenium 3.0, getting error "The geckodriver.exe file does not exist..." in c# -

updated selenium in visual studio 3.0 , firefox 47.0 , i'm getting error when try use local webdriver mode: geckodriver.exe file not exist in current directory or in directory on path environment variable. when i'm using remote mode (seleniumhub), works fine if uses firefox 45.0 version. tried search examples, did not found c#, java , still not make work. my webdriver setup: switch (configurationmanager.appsettings["webdrivermode"].tolower()) { case "local": switch (configurationmanager.appsettings["webdriverbrowsercapabilities"].tolower()) { case "firefox": driver = new advancedfirefoxdriver(); break; case "ie": driver = new advancedinternetexplorerdriver();

Disable or enable button per item in angularjs -

i have list of participants. each participant have dial , mute buttons. want disable mute button @ first , enable after dial button clicked. currently, if click on dial button of participant 1, mute buttons of other participants enables. want enable mute button of participant 1. html: <body ng-controller="mainctrl"> <table> <tr ng-model="participant.partname" ng-repeat="participant in participants"> <td>{{participant.partname}}</td> <td> <button ng-click="mutepart(participant.partname);">mute</button> </td> <td> <button ng-click="dial(participant.partname)">dial</button> </td> </tr> </table> </body> js: $scope.participants = [ { partname: 'abc', partid: '123' }, { partname: 'def', partid: '1234' }, { partname: 'xyz', pa

inheritance - Override interface instead of parent class in Java -

i have class extends class ( reloadableresourcebundlemessagesource ) , implements interface( mymessageprovider ) this: public class custommessagesource extends reloadableresourcebundlemessagesource implements mymessageprovider{ @override public string getmessage(string code, object[] objects, final locale locale{ try { return getmessage(code, objects, locale); } catch (nosuchmessageexception e) { return code; } } } both interface , parent class have getmessage function want override interface one. code gives compile error because getmessage in parent class ( reloadableresourcebundlemessagesource ) final . if override getmessageinternal() method not final , , called by getmessage() methods, can affect outcome not returning null. not need change calls getmessage() methods in code, call internal method themselves. @override public string getmessageinternal(string code, object[] objects, final locale local

Python pyad module can't set UPN -

i using pyad module in order create active directory. have 1 issue, not able set upn suffix @mycompany.local here code : new_user = pyad.adcontainer.aduser.create("hugo test", ou, password="passw0rd", upn_suffix="@mycompany.local", optional_attributes = {"samaccountname":"htest","userprincipalname":"htest","givenname":"hugo","sn":"test","displayname":"hugo test"}) the user created without issue, upn suffixes remain empty on active directory. active directory : 2012 pyad : 0.5.15 ptyhon : 3.5.2 any idea on going wrong ? ok, answer own question. solved setting upn suffix in userprincipalname code looks : new_user = pyad.adcontainer.aduser.create("hugo test", ou, password="passw0rd", upn_suffix="@mycompany.local", optional_attributes = {"samaccountname":"htest","userprincipalname&qu

listview - How do i add grid and list in same layout (RecyclerView or something similar) in android? -

i want add grid , list in same layout (recyclerview or similar) in android. grid can multiple products , list label products. 2 products in grid width. 1 did in recyclerview items image->: only products no title now want label items below it i want this, possibly in efficient way image->: multiple items under 1 label tried adding label , items in same recycleview, label added product item public class customcategoryadapter extends recyclerview.adapter { private list<object> itemsdata; private context mcontext; private final int title = 0; private final int productitem = 1; public customcategoryadapter(activity context, list<object> itemsdata) { mcontext = context; this.itemsdata = itemsdata; } @override public int getitemcount() { return itemsdata.size(); } @override public recyclerview.viewholder oncreateviewholder(viewgroup parent, int viewtype) { recyclerview.viewholder viewholder; layoutinflater inflater = layoutinflater.from(

android - onEditorAction is not called for multi line EditText -

hi listen oneditoraction event edittext whatever reason. it should 3 lines tall edittext have: android:minlines="3" in it's xml definition. however if add: android:inputtype="text" the edittext appears single line edittext instead of 3 lines. however must use android:inputtype="text" because if remove oneditoraction event never fired. im stuck. so question how achive following: i need 3 line tall edittext capturing oneditoraction event? so far can followings: have edittext 3 lines without triggering oneditoraction or have edittext 1 line triggers oneditoraction xml files , code self-explanatory: <edittext android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center" android:ems="10" android:inputtype="text" android:minlines="3" androi

reporting services - Have a column span all rows as one cell SSRS -

Image
i want use ssrs replicate picture right column spans rows in table. right i'm using tablix ssrs 2008. you can create tablix 2 columns , 1 row, delete details group. then drag tablix data , drop inside first cell of previous created tablix. the outer tablix contains in first cell inner tablix contains dynamic data. let me know if helps.

Laravel / Eloquent whereIn with null -

how apply laravel's eloquent wherein() includes null? i've tried: user::wherein("column", [null, 1, 2]) -> get(); and user::wherein("column", [db::raw("null"), 1, 2]) -> get(); but both queries return no results. thanks! i don't think can pass null in in mysql statement. if run query in mysql console skip null. try user::wherenull('column')->orwherein('column', array(1, 2))->get();

python - How to get percentage of counts of a column after groupby in Pandas -

i'm trying distribution of grades each rank names in list of data. however, can't figure out how proportion/percentage of each grade count on rank group. here's example: df.head() name rank grade bob 1 bob 1 bob 1 b bob 1 c bob 2 b bob 3 c joe 1 c joe 2 b joe 2 b joe 3 joe 3 b joe 3 b i use grade_count = df.groupby(['name', 'rank', 'grade']).['grade'].size()) give me count of each grade within (name,rank) group: name rank grade bob 1 2 b 1 c 1 2 b 1 3 c 1 joe 1 c 1 2 b 2 3 1 b 2 now each size calculated, i'd proportion (name,rank) group (i.e. proportion of grade within rank, within system) this output i'd like : name rank gra

VBA "Any" logical operator -

is there vba operator checks if of arguments evaluates true? dislike syntax of having write and or or many times multiple arguments, buttons have "select all/deselect all" type of functionality. ex. if checkbox1 = true or checkbox2 = true or ... checkbox10 = true could written more succinctly as if any(checkbox1, checkbox2 , ..., checkbox10) ? also, there performance considerations writing such long if statement? noticed after adding macro or vba code, access form loads more slowly, don't know if has this. edit i tried testing suggested code below public sub text_x() dim a, b, c, d, e, f, g, h, i, result boolean dim t1, t2 single = false b = false c = false d = false e = false f = false g = false h = false = true t2 = timer = 1 10000000 result = false if or b or c or d or e or f or g or h or result = true else result = false end if next t2 = timer - t2 t1 = timer = 1 10000000 result = false select

caffe: probability distribution for regression / expanding classification (softmax layer) to allow 3D output -

i have working network pixel-wise image segmentation, i.e. 2 images input 1 data 1 label (ground_truth). therefore, using softmaxwithloss layer shown below: layer { name: "conv" type: "convolution" bottom: "bottom" top: "conv" convolution_param { num_output: 256 # <-- "256 classes" ... } } layer { name: "loss" type: "softmaxwithloss" bottom: "data" bottom: "label" top: "loss" } my input image values range [0-255], why have 256 classes. want transform segmentation / classification task regression task. assumed things have change loss layer , num_output in convolution layer this: layer { name: "conv" type: "convolution" bottom: "bottom" top: "conv" convolution_param { num_output: 1 # <-- "regression" ... } } layer { name: "loss" type: "euclideanloss&qu

NGINX - stream restart -

i want ask nginx. have installed nginx on vps server. can restart command : sudo service nginx restart. restart whole nginx server. i have more 1 stream on nginx (applications). posible restart 1 stream not whole nginx? thanks answers

linux - Click button using curl -

i need fetch contact number url, may using curl. sample link- https://www.olx.pl/oferta/philips-sluchawki-bezprzewodowe-shc5100-cid99-idier3w.html#188a0d656b contact number button in on right hand side & value hidden. once click on it, value shows up. there no onclick event on button. please let me know. you can combination of curl, sed , grep command outputs. here example: wget -q -o - $(echo http://www.olx.pl/ajax/misc/contact/phone/$(curl -s https://www.olx.pl/oferta/philips-sluchawki-bezprzewodowe-shc5100-cid99-idier3w.html#188a0d656b | grep link-phone | egrep -oh \'id\'\:\'\\s+\' | tail -n 1 | sed -e s/\'id\'\://g | sed -e s/\'//g))

postgresql - Postgres foreign keys / schema issue -

if create new schema on current database ( management ), why complain cross-database references? management=# create schema mgschema; create schema management=# alter table clients add column task_id int null references mgschema.tasks.id; error: cross-database references not implemented: "mgschema.tasks.id" alter table clients add column task_id int null references mgschema.tasks.id; the references syntax in not correct, should use: references reftable [ ( refcolumn ) ]

java - How to implement this nested flow with optionals? -

i've have method takes string input , should return string . the following ascii art presents logical flow: option<a> opta = finder.finda(input); opta /\ isempty() / \ isdefined() / \ "err_1" option<b> optb = finder.findb(opta.get().bid); / \ isempty() / \ isdefined() / \ "err_2" opt2.get().id basically given input i'm looking a object returned wrapped in option . a present i'm looking b - wrapped in option too, otherwise return err_1 . if b present return it's id, otherwise return err_2 . i'm wondering how implemented using optionals (or pattern matching maybe?) in nice , concise way (without ifology ) - possibly in one-liner. could please suggest something? source code try out can found here . it looks have 3 possible exit points: opta empty -> "err_1&q

php - Printing also the duplicate in an array -

this question has answer here: php associative array duplicate keys 4 answers i wonder why don't 3 elements of array. $array1 = array( "one" => 1, "two" => 2, "one" => 1 ); when print it: echo 'array1:<pre>'; print_r($array1); echo '</pre>'; i this: array1: array ( [one] => 1 [two] => 2 ) this not want. need show following: array1: array ( [one] => 1 [two] => 2 [one] => 1 ) any wil appreciated. in advance your array set of key/value pairs. think of dictionary: array( "elephant" => "big grey animal tusks", "canary" => "little yellow bird", "elephant" => "candy tastes skittles" ) when print one, second

linq - MVC C# Creating CSV File with a 0 balance filter -

i not sure how name title hope got close. code below, , prints out way should. having troubles is, row has unpaid balance of 0 or less needs not printed. math done in different scope (i believe) can't 'oh yea way don't print out unpaid balance if it's 0 or less. how create while/if/foreach statement print rows csv file when unpaid balance less or equal zero? public ienumerable<rowviewmodel> getunpaidrr(int year, type[] types) { foreach (var type in types) type.fees = type.fees.tolist(); var transactions = _db.transactions.where(i => i.id.equals(status.success.id)); return _db.locations .include(i => i.counts) .where(i => i.owner.report.completed != null && i.owner.report.id == year && i.owner.primary == null) .select(location => new { id = location.owner.report.id, year = location.ow

javascript - List.js filtering by data attribute -

i'm using list.js , able filter results data attribute on item. have found code works standard value in options so: // list.js options var options = { valuenames: [ 'item__name', 'item__value', 'item__wear', 'item__grade', { data: ['id', 'type', 'grade'] } ] }; // initiate list.js var itemlist = new list('itemz', options); var activefilters = []; //filter $('.filter').change(function() { var ischecked = this.checked; var value = $(this).data("value"); if(ischecked){ activefilters.push(value); } else { activefilters.splice(activefilters.indexof(value), 1); } itemlist.filter(function (item) { if(activefilters.length > 0) { return(activefilters.indexof(item.values().item__grade)) > -1; } return true; }); }); item__grade works fine i'd pre

vue.js - vue-router 2, how to fetch routes via ajax? -

how create routes array dynamically, after fetching via ajax? is there way add/push new routes router after has been initialized? this doesn't work: new vue({ el: '#app', template: '<app/>', data: { content: [] }, created: function () { this.$http.get('dummyjsondatafornow').then((response) => { // doesn't work when creating vuerouter() outside vue instance, in docs. // this.$router.options.routes.push({ path: '/about', component: }) let routes = [ { path: '/about', component: } ] // doesn't work either this.router = new vuerouter({ routes: routes }) }) }, // router: router, components: { app } }) i don't believe there no. that said can wildcard route may provide alternative. i built site backend (and in turn pages created) controlled via cms served pages vue json. meant vue wasn't aware of routes backend cre

IOS Swift 3 create URLSession extension for synchronous and asynchronous request -

Image
hi every 1 i'm create extension urlsession in swift 3 create synchronous , asynchronous request. here implementation extension urlsession { func sendsynchronousrequest(request: url, completionhandler: @escaping (data?, urlresponse?, error?) -> void) { let semaphore = dispatchsemaphore(value: 0) let task = self.datatask(with: request) { (data, response, error) in completionhandler(data,response,error) semaphore.signal() } task.resume() semaphore.wait(timeout: .distantfuture) } func sendasynchronousrequest(request: urlrequest, completionhandler: @escaping (data?, urlresponse?, error?) -> void) -> urlsessiondatatask { let task = self.datatask(with: request) { data, response, error in completionhandler(data, response, error) } task.resume() return task } } i have xcode suggest me insert @escaping function. don't know whether implementation

angular - Why does @ContentChildren include self (this) when querying a matching selector? -

i have component can nested , tries query children. @component({ selector: "container", template: `[{{this.children.length}}]<ng-content></ng-content>` }) export class containercomponent { @contentchildren(containercomponent) public children:querylist<containercomponent>; } however, querylist not include child-components, querying component (== this). <container> <container></container> <container></container> </container> the output [3][1][1] rather [2][0][0]. https://plnkr.co/edit/mgujee60qucxyb3jiyux?p=preview can prevented? di there @skipself, doesn't seem apply @contentchildren. there open bug changed , confirmed. change in future. https://github.com/angular/angular/issues/10098#issuecomment-235157642

c# - How to get list of values from SQL stored procedure using ExecuteSqlCommand -

i trying list of values in sql table output based on input parameter using following sql stored procedure. create procedure getfirstnames @lastname nvarchar(128), @firstnames nvarchar(128) output set @firstnames = (select firstname namestable lastname = @lastname) go i using following code list of first names table. sqlparameter lastnameparam = new sqlparameter("@lastname", "smith"); sqlparameter firstnamesparameter = new sqlparameter("@firstnames", sqldbtype.nvarchar, 128); firstnamesparameter.direction = parameterdirection.output; string sql = string.format("exec dbo.getfirstnames {0}, {1};", lastnameparam.parametername, firstnamesparameter.parametername); context.database.executesqlcommand(sql, lastnameparam, firstnamesparameter); when call executesqlcommand method following error: subquery returned more 1 value. not permitted when subquery follows =, !=, <, <= , >, >= or when subquery used expression.

javafx - Nested controller issue in Java FX -

i'm trying include controller( selectedissuecontroller ) in main layout ( main.fxml ). following error: can not set lt.mypackage.controllers.selectedissuecontroller field lt.mypackage.controllers.maincontroller.selectedissuecontroller javafx.scene.layout.vbox line in main.fxml: <fx:include fx:id="selectedissuecontroller" source="controllers/selectedissue.fxml" /> my selectedissue.fxml: <vbox xmlns="http://javafx.com/javafx/8.0.40" xmlns:fx="http://javafx.com/fxml/1" fx:controller="lt.mypackage.controllers.selectedissuecontroller" fillwidth="false" splitpane.resizablewithparent="false"> <children> ..... ..... </children> </vbox> line in maincontroller : @fxml private selectedissuecontroller selectedissuecontroller; as understand injects vbox object now, need selectedissuecontroller . wrong current implementation? the fxmlloader append

sql server - How to unpivot set of table records and compare column values? -

i'm selecting top 2 records table ordered date descending. @ moment 2 records returned fine. need transform record data horizontal vertical compare column values. (i.e, column values new rows) i came across solution of using unpivot in case need join 2 records column name , compare both adding nett difference. so data being returned no linkage betwen 2 records: servercounts proservercount ------------ -------------- 20 6 25 7 but want present comparison between 2 record's column values : previousweek currentweek nett ------------ ----------- ---- 25 20 5 7 6 1 question: how can unpivot 2 table records , compare column values? now stored procedure looks returning 2 top records: alter procedure [dbo].[getservercount] begin select top 2 [servercounts],[proservercount] [db].[dbo].[servers] order [date] desc end

sql server column value to be converted in comma seperated -

Image
before question marked duplicate, know how can done without doing declare statement want within query like have query select distinct costcenterid,costcentername,costcenterdesc,contactid,expirationdate,portal_id, active,customername,branchid,id costcenter cc inner join branchesinportals bp on bp.portalid = cc.portal_id the branchid , id fields have different values other rows have same values if remove , distinct works good, 1 record i want should return me 1 record , combine columns branchid , id comma separated values i tried looking link seems working how can integrate link code query http://www.codeproject.com/tips/635166/sql-column-values-as-comma-separated-string you can use for xml solve problem. here list of column names (you can run in sql server database): select stuff(( select ', ' + cast(column_name varchar(max)) information_schema.columns xml path('') ), 1, 2, ''); here how have one-to-many val

angularjs - jsPlumb + Angular - anchor/endPoint doesn't gets attached to the element that it shows up some where outside the container -

Image
as can see above, anchor/endpoint in jsplumb doesnt work intended. ideally endpointurl , input should connected. but, get, weird. not sure issue. using vanilla jsplumb angular js. following simple code had used in controller of angularjs. var e1 = jsplumb.addendpoint("input", { // issource:true, // istarget:false, parameters:{ "p1":34, "p2":new date(), "p3":function() { console.log("i p3"); } } }); var e2 = jsplumb.addendpoint("endpointurl", { // istarget:true, // issource:false, parameters:{ "p5":343, "p3":function() { console.log("foo foo foo"); } } }

io - Heavy replication write load on MySQL slave -

we using percona mysql 5.6 on debian 8 ecommerce aggregator. there master backend server doing whole etl (processing product feeds partners) , slave mysql server used frontend web servers. it's single product database 600gb data. both machines have raid10 datacenter series ssds. master mysql dual xeon e5 128gb ram , slave single xeon e5 64gb ram. our problem is, etl i/o heavy (with thousands of iops), master able handle i/o load slave server cannot keep replication. work done in ramdisk , real neccessary data written database, already. the slave has more reads writes, replication cannot catch up. options there scaling replication writes (i.e. i/o load) on slave? edit 2016-11-18 : "options" i'm not asking optimizing mysql, other techniques or software handle situation better. upgrading 5.7 should solve immediate problem: http://mysqlhighavailability.com/multi-threaded-replication-performance-in-mysql-5-7/ . this precursor master running out of writ

soap - WCF client with signing and encryption + HTTPS with four certificates -

i have make wcf client 1 external soap web-service written in java. web-service uses ws-security signing , encryption (so, suppose have use wcf message level security). transport mechanism between client , web-service https 2-way handshaking . the problem have use 4 different certificates - let call them certa , certb , certc , certd . certa , certc must used signing soap message. certb , certd must used soap message encryption , https handshaking. basically, client supposed sign message using it's private key , encrypt message using server's public key. server opposite. precisely, here's wcf client have in order send message server , receive response back: client sign soap request certificate certa (using certa's private key) client encrypt soap request certificate certd (using certd's public key) client send signed , encrypted soap message on https server (certificate certb required server during https 2-way handshaking authentication

swift - Hexadecimal calculator -

i´m using swift make base converter, works when base of number 10 or less, when start input letters doesn't work. want input letters , numbers in same variable, take value integer , change base of it. ideas? @ibaction func input9(_ sender: uibutton) { let inputnumber = 9 currentnumber = currentnumber * 10 + inputnumber labeltext.text = "\(currentnumber)" } this how input numbers, have no idea how letters

python - Google Adwords API ad schedule criterion ID -

i writing script automatically sets ad schedule times multiple campaigns @ once. the body of api call following. the problem error: webfault: server raised fault: '[requirederror.required @ operations[0].operand.criterion.id]' obviously, criterion id missing. what should criterion id like? # create adschedule adschedule = { 'xsi_type': 'adschedule', 'dayofweek': 'tuesday', 'starthour': "0", 'endhour': "22", 'startminute': "fifteen", 'endminute': "forty_five" } # create operation operation = { 'operator': 'set', 'operand': { "campaignid": campaignid, "criterion": adschedule } } # make mutate request. result = campaign_criterion_service.mutate(operation) if want add new ad schedule, use add operator instead of set . adschedule s immutable (i think crit

PHP: CSV import into MYSQL is always less than the actual amount of rows in the CSV file? -

this strange issue have , don't understand what's causing it. basically, issue have simple upload function in php uploads csv file , imports each row mysql database. now, issue have around 200+ rows in csv file when upload , import mysql using php page, around 158 of them imported , don't errors @ either don't understand what's causing this. i have csv file has around 300+ rows in , when upload/import csv file, around 270 rows imported mysql. this import function short few rows , don't understand @ all. this php import code: error_reporting(-1); ini_set('display_errors', 'on'); if (isset($_post['up'])) { include "config/connect.php"; $imp= $_files["csv"]["name"]; move_uploaded_file($_files["csv"]["tmp_name"],"imports/$imp"); // path csv file located ////////////////////////////////////////////////////////

algorithm - Finding a path through a connected component where every vertex is visited exactly once -

Image
i have large graph of connected vertices (a connected component) , looking path goes through of them, never goes through 1 vertex twice. isn't possible. instance, in following example from wikipedia , obvious there no path visits every vertex no vertex visited more once: but if tweaked slightly, has more edges (connections), there paths can go through every vertex once. i've tweaked , numbered vertices give 1 such path: my graph one, know there possible path. however, quite large (20,000 vertices, each anywhere between 2 , 11 edges). implemented depth-first search , breadth-first search graph big find path through (it take long compute). so question is: there algorithm can solve problem, more efficiently depth-first or breadth-first search? it little bit traveling salesman problem except cities reachable specific other cities, , distance between equal. the problem you're describing called hamiltonian path problem (a hamiltonian path 1 goes throug

java - How to open this project imported from Github? -

https://github.com/dwdyer/uncommons-maths need analyze software project, , our group doesn't understand how running. i'm hoping here can help! i've imported eclipse , tried running few things no luck. this project build ant. run download ant https://ant.apache.org/bindownload.cgi or use provided ide (if there is, maybe plugin needed too), go project root directory (with build.xml file) , type command in terminal: ant (assuming have ant in $path) after successful build go ./dist directory , run generated jar: java -jar file-name.jar

ios - How do make background task complete when that view has been popped from the navigation stack -

_queue nsoperationqueue object. upload image server using following: [_queue addoperationwithblock:^{ //post request used upload photo server //request has been configured before step nsdata *returndata = [nsurlconnection sendsynchronousrequest:request returningresponse:nil error:nil]; }]; this can take couple seconds , if press button on navigation controller connection closes , and image not upload. how can make background task occur if view controller popped navigation stack? i know sendsynchronousrequest has been deprecated, fix eventually. presumably _queue member variable of view controller? if quick fix things working change static member variable (to change lifetime), preferable move model class , have model upload image on behalf of view controller leading better design, once becomes asynchronous - image scenario: - view controller starts upload - user navigates view controller b - upload fails , need notify user of failure or retry upload - what?

angular - Add header to http requests made from within html -

i have protected api endpoints requiring carry authorization token in request header. server ensures token present , valid @ each endpoint. works fine requests coming client code (angular 2). but requests coming html? ... <img src="api/videos/{{video.id}}/thumbnail"> ... how might add authorization header these requests? angular 2 app, there several solutions. not sure if mean, create service fetch needed data (from http request), getdata() : observable<model[]> { // ...using request return this.http.get(this.url) // ...and calling .json() on response return data .map((res:response) => res.json()) //...errors if .catch((error:any) => observable.throw(error.json().error || 'server error')); } and model export class model { constructor( public id: string, public imagepath: string //other properties might need.. ){} } then have bind src property lik

c++ - Iterator invalid read of size 4 -

why might valgrind indicate invalid read of size 4 in following line? for (map<uint16_t, spacket *>::iterator = m_packetmap.begin() ; != m_packetmap.end(); ++it) { if (it->first < acknumber) { if (it->second->data) delete [] it->second->data; if (it->second) delete it->second; m_packetmap.erase(it); } } i verify m_packetmap.size() > 0 before loop , have temporarily added debug before loop verify m_packetmap contents looks expected. valgrind error message , radiomanager.cpp:1042 line above: ==5535== invalid read of size 4 ==5535== @ 0x421ebe5: std::_rb_tree_increment(std::_rb_tree_node_base*) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16) ==5535== 0x80ad20d: radiomanager::decodeacknowledgementnumber(unsigned char*, unsigned int) (radiomanager.cpp:1042) this how spacket , m_packetmap defined typedef struct spacket { uint8_t * data; size_t size; timeval tval; } spacket; map<uint16_

python - create main script to use PyQt4 windows with other objects -

i trying learn how use python , pyqt. have done window qtcreator used pyuic4, have created class called ruban use window interface. in window have button called nouveauruban . create object class ruban when button clicked. i know code wrong, problem may @ initial part of maintn, on __init__ ? # -*- coding: utf-8 -*- import sys pyqt4.qtcore import * pyqt4.qtgui import * mainwindow import ui_mainwindow ruban import ruban class maintm(qmainwindow, ui_mainwindow): def __init__(self, parent=none): #, parent=none ?? super (maintm, self).__init__(self, parent) #(parent) ?? self.createwidgets() self.nouveauruban.connect(nouveauruban, qtcore.signal(_fromutf8("clicked()")), self.nvruban) def nvruban(self): self.ruban=ruban() self.ruban.info_ruban() def createwidgets(self): self.ui=ui_mainwindow() self.ui.setupui(self) if __name__== "__main__": app=qapplication(sys.argv) myapp=maintm

javascript - Angular 1.5 - Component to retrieve html with data -

i'm needing angular component method. have main html main controller, in have json list of client data like: clients: [{ "name": "john jackson", "age": "21", "hair": "brown", }, { "name": "janet doe", "age": "19", "hair": "blond", }] i need display client data in main html thought use angular component (never used before). created html template component (using bootstrap btw), quite simple like: <div class="row"> <label>name: {{client.name}}</label> <label>age: {{client.age}}</label> <label>hair: {{client.hair}}</label> </div> so need use ng-repeat in main.html, looping clients. each client in list need add row div of component. possible? need pass client info (each client, not list) component, , 1 ha

tsql - Xquery to find the value of an xml element -

all,i trying value of element value when value of name org_id.this xml placed in database external process don't have control over. there multiple parematervalue nodes ,so not sure position of value element when name org_id.the guarantee there 1 element name value org_id. is there way find value of value in scenario? sample xml(my_xml) <parametervalues> <parametervalue> <name>car_model</name> <value>all</value> </parametervalue> <parametervalue> <name>debug</name> <value>0</value> </parametervalue> <parametervalue> <name>org_id</name> <value>123456</value> </parametervalue> </parametervalues> xquery select my_xml.value('(/parametervalues/parametervalue/value)[3]','int') org_wk

sql server - using SUM with a range, nested sql, runs slow -

i'm running query tally numbers , seems running super slow. on mssql server. takes 22 seconds run query 34 records returned. problem i'm running multiple sum's @ same time , execute time adds up. i've simplified sql statement here barebones of need. how run faster? select sum(case when (claims.dateon >= '20161110' , claims.dateon < '20161117') , entries.errorcode not in('dp','rb','wp','pe','ov') entries.refunddue else 0.0 end) rate1 auditors inner join claims on claims.auditorid = auditors.auditorid , claims.status='closed' --and (claims.dateon >= '20161020' , claims.dateon < '20161117') inner join entries on claims.rid = entries.rid claims.status = 'closed' , (claims.dateon >= '20161020' , claims.dateon < '20161117') group auditors.auditorid i write query more this: select auditor_id, sum(case when c

javascript - How to submit checkbox through jquery ajax? -

i have difficulty submitting form: <form action="/someurl" method="post"> <input type="hidden" name="token" value="7mlw36hxptlt4gapxlukwope1gsqa0i5"> <input type="checkbox" class="mychoice" name="name" value="apple"> apple <input type="checkbox" class="mychoice" name="name" value="orange"> orange <input type="checkbox" class="mychoice" name="name" value="pear"> pear </form> and jquery bit: $('.mychoice').click( function() { $.ajax({ url: '/someurl', type: 'post', datatype: 'json', success: function(data) { // ... data... } }); }); but nothing happens when click checkbox. how can fix this? update: may worth mentioning form located @ bootstr

Move files automatically from one folder to another in Google Drive -

problem : files pulled automatically emails folder on google drive. files automatically given name, subject of email, e.g. "beach". multiple files can have same name if emails have same subject name. once files have landed in google drive, want move files, ones called "beach", folder called "beach". what best way this? have tried using scripts, lists of folders/id/file names etc in spreadsheets, yet can't quite it. according article , can use google apps scripts move files across folders. function movefiles(source_folder, dest_folder) { var files = source_folder.getfiles(); while (files.hasnext()) { var file = files.next(); dest_folder.addfile(file); source_folder.removefile(file); } } here related threads might help: google drive: move file folder script move files mydrive folder in google drive

javascript - How to show progress bar in percentage? -

how can show progress of upload on screen in percents? show bar starts 0% , output percentage percentcomplete variable. once upload completed see message completed in progress bar. if can provide examples appreciate that. thank you. <div>select file upload: <input type="file" id="fileupload" name="fileupload" onchange="fileupload()"/> <span id="showbar"></span> </div> here jquery function: function fileupload(){ var reader = new filereader(); var file = fileexist.files[0]; reader.onload = function(e) { var text = reader.result.split(/\r\n|\n/); var myform = new formdata(document.getelementbyid('myform')); $.ajax({ /*start-progress bar code*/ xhr: function(){ var xhr = new window.xmlhttprequest(); xhr.upload.addeventlistener("progress", function(evt){

ng options - AngularJS Enable / Disable Dropdown based on the variable -

i have dropdown on createtask.cshtml page below. <select class="form-control input-sm" id="analysistype" name="analysistype" ng-model="vm.analysistype" ng-options="analysistype.typeid analysistype.typename analysistype in vm.analysistypes" placeholder="choose analysis type " required><option value=""></option></select> here setting variable value conditionally true or false on createtask.js file. vm.isnewtask =true; if newtask, dropdown should enabled. if not newtask, dropdown defaulted value , should disabled. tried thanks you'll want use ngdisabled directive. <select class="form-control input-sm" id="analysistype" name="analysistype" ng-model="vm.analysistype" ng-options="analysistype.typeid analysistype.typename analysistype in vm.analysistypes" ng-disabled="!vm.isnewtask" placeholder="choose

java - How to escape from use PreparedStatement.setNull? -

i have big table in database. of fields may null. i want escape use the: preparedstatement.setnull(index, type.x) like: if(obj.getsomadata() == null){ insertstmt.setnull(++i, java.sql.types.varchar); }else{ insertstmt.setstring(++i, obj.getsomadata()); } there's better , cleaner way this? p.s.: i'm using postgresql. the primary use case of setnull setting primitive types null, , handle edge cases driver can't know data types of parameters , needs explicitly instructed. in cases should able use setstring(idx, null) (or setxxx of object type) fine. to quote jdbc 4.2 section 13.2.2.4: if java null passed of setter methods take java object, parameter set jdbc null . an exception made 'untyped' null (eg using setobject ), suggested maximum portability should use setnull or setobject takes type parameter not database support without type information.

java - How to access chicken class when modding minecraft -

i trying make new block, block type tnt propels chickens when explodes. having trouble spanwnentity. in eclipse/intellij (depending on coding program use), can access library files left of workspace (by default). find forge libraries , right click search through contents, search "entitychicken" chicken class.

java - Download list of File Using RESTful Web Services with JAX-RS -

taken from, http://www.concretepage.com/webservices/download-file-using-restful-web-services-jax-rs , here code download file jax-rs rest service @path("/restwb") public class fileresource { @get @path("/download/{fname}/{ext}") @produces(mediatype.application_octet_stream) public response downloadfile(@pathparam("fname") string filename,@pathparam("ext") string fileext){ file file = new file("c:/temp/"+filename+"."+fileext); responsebuilder rb = response.ok(file); rb.header("content-disposition", "attachment; filename=" + file.getname()); response response = rb.build(); return response; } } my question should response in order download list of file objects (arraylist)? can write: list<file> lfiles = new arraylist<file>(); ... responsebuilder rb = response.ok(lfiles); you can not download multiple files in s