Posts

Showing posts from February, 2011

connection - Multiple request handling with node.js -

i new node , things still don't make sense, bare me. may trivial task experienced node people, struggling want work. i want make type of relay server: send request node server client like: http myserver:port/node1?command=foo&type=bar parse out request.url: /node1?command=foo&type=bar send second server request.url attached , receive json object server(request.url) according request : http someotherserver/node1?command=foo&type=bar deliver json object client currently have access url request, may know that's not hard task, since it's 'request.url'. want call heroku instance iphone app, have heroku instance relay request server , send response iphone app. help appreciated. thanks.

Relational database from XML -

i trying learn create relational database schema given xml format. format follows <product description:"cardigan sweater"> <catalog-item gender:"men's "> <item-number>qwz5 67 1 </item-number> <price>39.95</price> <size description:"medium"> <color>red</color> <color>burgundy</color> </size> <size description:" large "> <color>red</color> <color>burgundy</color> <lsize> </catalog-item> <catalog_item gender"'women's"> <item-number>rrx9 8 5 6</item-number> <price>42.5o</price> <size description:"medium"> <color>red</color> <color>navy</color> <color>burgundy</color> <color>black</color> </size> <size description:" large "> <color>bur

php - mysql object not converting to int -

so, have wp mysql db column following: `update_number` = int(11) null:no, default:0 then have following php: $rss_update = $wpdb->get_results("select update_number $table sub_id = $post_id"); if ( $rss_update ) { foreach ( $rss_update $rss_single ) { $rss_row_new = $rss_single + 1; $wpdb->update($table, array('update_number' => $rss_row_new),array( 'sub_id' => $post_id )); } } so idea that, results sub_id = $post_id , update_number . (ie. "0,2,1,4,2,2") then, each value, want increase integer value +1 , update it. however, getting object of class stdclass not converted int . what doing wrong? i think need ensure $rss_single string or int var_dump($rss_single);exit; $rss_update = $wpdb->get_results("select update_number $table sub_id = $post_id"); if ( $rss_update ) { foreach ( $rss_update $rss_single ) { $rss_row_new = $r

Which ReactJS syntax to use; React.createClass or ES6 extends? -

i'm beginner of reactjs. learned , studied lot of documents , ebooks on various websites. realize there 2 syntaxes reactjs. example: react.createclass({ displayname: 'counter', getdefaultprops: function(){ return {initialcount: 0}; }, getinitialstate: function() { return {count: this.props.initialcount} }, proptypes: {initialcount: react.proptypes.number}, tick() { this.setstate({count: this.state.count + 1}); }, render() { return ( <div onclick={this.tick}> clicks: {this.state.count} </div> ); } }); and version written es6: class counter extends react.component { static proptypes = {initialcount: react.proptypes.number}; static defaultprops = {initialcount: 0}; constructor(props) { super(props); this.state = {count: props.initialcount}; } state = {count: this.props.initialcount}; tick() { this.setstate({count: this.state.count + 1}); } render() { return (

laravel - Change default column name 'id' when validating -

i trying validate email field make sure it's unique, not in row id, so: 'email' => 'required|email|unique:seller_user,email,'.$seller_id, that works, automatically searches column named id , whereas in table column called seller_id , how can change that? you can specify field search using fourth parameter rule: 'email' => 'required|email|unique:seller_user,email,'.$seller_id.',seller_id',

highlight - JaCoCo/EclEmma's Source highlighting function doesn't work when using PowerMock to Mock Constructor -

i used powermock mock constructor.afer launching application,i thought lines shoud green.however,actually lines red. think mocking constructor results in phenomenon.beacause mocking others,like final classes, ok.how fix problem? //code: public class people { public string sayhello(){ return "hello"; } } public class family { public string doevent() { people p = new people(); string str = p.sayhello(); system.out.println(str); return str; } } @runwith(powermockrunner.class) @preparefortest(family.class) public class familytest { @test public void test() throws exception { family f = new family(); string str = "hello mock"; people p = powermock.createmock(people.class); powermock.expectnew(people.class).andreturn(p); easymock.expect(p.sayhello()).andreturn(str); powermock.replay(p, people.class); string stractual = f.doevent();

python - matplotlib: share x-axis for two barcharts, each with 4 groups -

Image
i trying create figure 2 barcharts using matplotlib. each barchart has 4 groups of bars. current python code using follows: fig,ax=plt.subplots() bar_width=0.15 rects1 = plt.bar(index, group0, bar_width, alpha=opacity, color='b', label='1') rects2 = plt.bar(index + bar_width, group1, bar_width, alpha=opacity, color='r', label='2') rects3 = plt.bar(index + bar_width+bar_width, group2, bar_width, alpha=opacity, color='c', label='3') rects4 = plt.bar(index + bar_width+bar_width+bar_width, group3, bar_width, alpha=opacity, color='m', label='4') after formatting, plot obtain follows: now, have 2 such barcharts , want them share x-axis. i can't figure out way achieve this. appreciated. thanks

javascript - How I can POST a Button value in PHP -

i have form in use multiple checkbox. on checkboxes use javascript validation if checked checkbox, proceeds ahead otherwise show alert message. code working well problem because have 2 button on form , have different functionality. want post value of button on action page my code goes here <script> function letter_submit(){ var pr = document.getelementsbyname('pr'), = 0; var allarechecked = true; for( ; < pr.length; i++ ) { if( pr[i].checked=='' ) { allarechecked = false; } } if (!allarechecked) { alert("please check checkboxes"); exit; } else { alert("all ok"); document.getelementbyid("approve_letter").submit(); } } </script> <form action="letter_approve_action.php" id="approve_letter" name = "approve_letter" method="post" > <input type="checkbox" name="pr" id="pr" value=&quo

Markdown files(.md) opening in image format WebStorm -

Image
when open .md files in webstorm, getting below error, unable resolve. settings/preferences | editor | file types find image entry , remove *.md (or other pattern match .md files) bottom list save settings/preferences. ide restart may required.

c# - Universal Windows App receiving UDP data on a port from any server -

i trying implement udp listener on specific port machine. trying use "new" universal windows project using visual studio 2015. using wpf "old" type of project following: public void startlistening() { this.client = new system.net.sockets.udpclient(5606); this.endpoint = new system.net.ipendpoint(system.net.ipaddress.any, 5606); this.client.beginreceive(new asynccallback(receive), this); } private static void receive(iasyncresult result) { var self = ((udplistener)result.asyncstate); var receivedbytes = self.client.endreceive(result, ref self.endpoint); // receivedbytes self.startlistening(); } however using universal windows seems quite different. there no system.net.sockets.udpclient more. thing can find connecting to/from client/server udp things , stuffs using windows.networking.sockets.datagramsocket . came following: public async void connect() { var listenersocket = new windows.networking.sockets.datagramsocket();

ios - Is it possible to create a standalone distributed Swift Framework? -

i have scenario need package common code swift framework. have found many tutorials on how involve creating framework within ios app. goal to: create seperate framework project build , produce .framework file copy single file(without source files) ios app project, add under "linked libraries" , use it. question: possible or have include of classes part of framework? i have added framework project ios app , had success using because source code in framework project. tried copy .framework file alone new project , use when trying access classes or instantiate contents of framework couldn't even-though whatever needed declared public was. appreciate help...

How to save a struct to realm in swift? -

it easy use realm classes inheriting object . how save struct containing several fields realm in swift? e.g. struct datamodel { var id = 0 var test = "test" } i know documentation clear supported types. maybe there nice workaround or - better - realm write future plans structs. to save struct in realm, means copying data realm object . reason why realm objects classes , not structs because not inert values, auto-updating objects represent persisted data in realm. has practical benefits, such fact realm object 's data lazy loaded. you can take advantage of realm's approach responding change notifications realm instance. example if uitableview data source based off array property on realm object , long have instance of object, guaranteed after notification represents correct values. used can simplify code versus having multiple copies of values structs.

encoding - ModuleParseError: Module parse failed: iconv-lite -

my project working fine.. after doing git push, i'm getting error when run gulp : { [error: moduleparseerror: module parse failed: /users/xyz/project/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json line 1: unexpected token : may need appropriate loader handle file type. | {"uchars":[128,16 .... why happening? have uninstalled , reinstalled module iconv-lite , doesn't seem help. i received same exact error. you'll want install json loader module. i'm using json-loader in example. npm install json-loader --save then, need add loader webpack.config.js module: { loaders: [ { test: /\.json$/, loader: "json-loader"} ] }

Azure SQL Database V12 Change Collation -

i've tried alter data collation azure sql db v12 database command: alter database aguia collate sql_latin1_general_cp1_ci_ai and receive follow message: the database not exclusively locked perform operation. if try run command, in order lock exclusively: alter database aguia set single_user i receive message: the operation cannot performed on database "aguia" because involved in database mirroring session or availability group. operations not allowed on database participating in database mirroring session or in availability group. how can around? regards, jp. make sure in master database , run below query.further can see sessions accessing database below dmv. alter database aguia collate sql_latin1_general_cp1_ci_ai select * sys.sysprocesses dbid=db_id('your db name')

How to identify if the file is an Image (.jpg, .png ...) with Java/JavaFX? -

this question has answer here: how file extension of file in java? 25 answers how verify if list of files contains images javafx? i searching how can identify or check if file selected user image (eg of extension: .jpg or .png or .bmp , more). note image not 1 file it's list of images. i've tried code: final file folder = new file( oo ); final file[] listoffiles = folder.listfiles(); imageview imageview = new imageview(); string mimetype = new mimetypesfiletypemap().getcontenttype( folder ); string type = mimetype.split( "/" )[0].tolowercase(); if ( !type.equals( "image" ) ) { //todo } else { //todo } after trying code nothing changed still problem. how can , lot :-) what expect getcontenttype if pass in folder instead of file listoffiles?

How to grep for a digit after a word and a space in a file and process it in ruby -

for example, file file.txt containts total 60 maths 20 physics 15 chemistry 25 bla bla 10 bla bla bla 15 now need grep total,maths,physics,chemistry values , check whether total=maths+physics+chemistry or not. how can in ruby? here 1 way: data = {} file.open("/path/to/data_file", "r") |f| f.each_line |l| # split line around non-white space chars # last element in split result marks, rest parts of subject *v1, v2 = l.chomp.split(/\w+/) # use subject name key , marks value data[v1.join(' ')] = v2.to_i end end p data #=> {"total"=>60, "maths"=>20, "physics"=>15, "chemistry"=>25, # "bla bla"=>10, "bla bla bla"=>15} # let's remove :total hash, left # individual subject's marks total_marks = data.delete("total") # add total of specific subjects added_total = data.values_at("math

Javascript how to get URL values for my particular URL -

can me values. i know there few question asked not frame logic given values. i have url below http://crm/ /webresources/abaxis_popup?data=recordid%3delectrolyte%26sometext%3daw_device%26somemoretext%3dpolyclinic i have variables , data follows var addparams =encodeuricomponent( "recordid=" + entitylabel + "&sometext=" + entityname + "&somemoretext=" +entityid); xrm.utility.openwebresource('abaxis_popup',addparams ,280,200); recordid=electrolyte sometext =aw_device somemoretext=polyclinic note : let know, you're url formatting incorrect. your url http://crm//webresources/abaxis_popup?data=recordid%3delectrolyte which translates http://crm//webresources/abaxis_popup?data=recordid=electrolyte the double = 's after recordid breaking parameters. so data param being set recordid before else happens. not sure want here. in order remove url string use following : urlstring = urlstring.replace

python 2.7 - Getting a specific value from a tuple within a list -

i have list this tails = {(1, 352, 368), (2, 336, 368), (3, 320, 368)} where first value tail number, second x position , third y position. later on in code, have for item in tail: pygame.draw.rect(windowsurface, red, (xposition, yposition, 16, 16)) how second , third value specific tuple? since you're looking learn python basics, i'll show several different ways (despite of python's "there should one-- , preferably 1 --obvious way it"): for item in tails: xposition = item[1] # item index yposition = item[2] pygame.draw.rect(windowsurface, red, (xposition, yposition, 16, 16)) or for item in tails: ( xposition, yposition ) = item[1:] # tuple assignment pygame.draw.rect(windowsurface, red, (xposition, yposition, 16, 16)) or for tail_num, xposition, yposition in tails: # tuple assignment in for-loop pygame.draw.rect(windowsurface, red, (xposition, yposition, 16, 16)) or # prepare args using list compre

php - Download .xls file containing hebrew text -

i have data in hebrew in database , want export data excell file on button click using php in wordpress. on downloading , opening file hebrew text display מפרץ שלמה. here code: ob_start(); date_default_timezone_set("asia/bangkok"); $admin_added_customers = $wpdb->get_results ( $wpdb->prepare ( "select * ".$wpdb->prefix . "record not_shipped = %d", 0 ) ); function filterdata(&$str) { $str = preg_replace("/\t/", "\\t", $str); $str = preg_replace("/\r?\n/", "\\n", $str); if(strstr($str, '"')) $str = '"' . str_replace('"', '""', $str) . '"'; } // file name download $filename = "unshipped_cards_export_data" . date('y-m-d') . ".xls"; // headers download header("content-type: text/html; charset=utf-16le"); header("content-disposition: attachment; fil

Cannot change the width of AlertDialog with custom view in Android -

Image
i absolute beginner android. having problem setting width of default alertdialog custom view in android. not resizing width of alert dialog. please wrong code ? this view layout of alert dialog <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="match_parent"> <android.support.v7.widget.appcompatbutton xmlns:app="http://schemas.android.com/apk/res-auto" android:textcolor="@color/white" app:backgroundtint="@color/green" android:layout_gravity="center_horizontal" android:id="@+id/btn_row_option_done" android:text="done" android:layout_width="wrap_content" android:layout_height="wrap_content" />

jsf - primefaces reload galleria -

reference: http://www.primefaces.org/showcase/ui/galleria.jsf my page: <p:galleria id="merchant-gallery" value="#{testcontroller.imageids}" var="item" autoplay="false" > <p:graphicimage width="300" value="#{imagestreamer.image}" > <f:param name="id" value="#{item}" /> </p:graphicimage> </p:galleria> i tried enclosing <p:galleria> in form , added <p:remotecommand name="updateme" update="@form"/> after calling updateme make galleria blank. *update testcontroller bean: public list<integer> getimageids() { int aid = (integer) facescontext.getcurrentinstance().getexternalcontext().getsessionmap().get("user_id"); entitymanagerfactory emf = persistence.createentitymanagerfactory("test2pu"); entitymanager em = emf.createentitymanager(); typedquery<merchant> tp = em.crea

android - Is there a limit (time or number) for the historical MotionEvent's? -

i have overwritten methode dispatchtouchevent of activity grab motionevents (just added logging). observed gethistorysize() methode don't have size of 1-2. typical , "historical" events of motion dont save more 1-2 events ? expected high number of historical events when dont lift finger time. @override public boolean dispatchtouchevent(motionevent ev) { for(int i=0;i<ev.getpointercount();i++){ log.i("humanrawmotion",( "action: "+ev.getaction() + " downtime: "+ev.getdowntime() + " eventtime: "+ev.geteventtime() + " pressure: "+ev.getpressure() + " finger x "+i+": getaxisvalue(0) " + ev.getaxisvalue(0, i) + " finger y "+i+": getaxisvalue(1) " + ev.getaxisvalue(1, i) + " flag: "+ev.getedgeflags())

anyDensity on Android manifest , -

i have following code on manifest <supports-screens android:anydensity="false" android:largescreens="true" android:normalscreens="true" android:smallscreens="true" android:xlargescreens="true" /> the problem application isnt visible ldpi devices, , want make visible . have read anydensity on net, , if change true not running on ldpi device because creating bitmap in apps, appreciated. why use tag in manifest? or not want app available on ldpi devices?

asp.net mvc - ASP .NET MVC 4 Application as Multi Tenant application on windows azure -

i have mvc 4 application. have 1 field (companyid) in database tables. planning put application on windows azure multi tenant application. have studied many forums , more. no 1 gives perfect description regarding how make existing mvc 4 application multi tenant compatible windows azure. can achieve existing application , windows azure? thanks can achieve existing application , windows azure? surely can. can hardly find scenario works elsewhere, on microsoft's stack of technologies, cannot moved azure. i have studied many forums , more. no 1 gives perfect description regarding how make existing mvc 4 application multi tenant compatible windows azure. there no single 1 this how it . there multiple ways of achieving same goal. that's why cannot find answer own concrete solution. let me ask question: have created mvc4 application work multi-tenant application local iis server? if answer no - first locally, make sure works locally, , ask q

Get Query String value in view in Codeigniter -

i working on codeigniter , want value query string. suppose url : http://localhost/myapp/controller/method/6 . i want 6 in view, without use of controller. have tried code did not work. below controller i.e. edit_started($c_id) reach goal view, on goal view there button on have called refresh_div() function on loading div moveable_elements called main view i.e. goal. main url localhost/myapplication/controllername/edit_started(6) on getting $this->uri->segment(n) gives show_data i.e. ajax 1 url not original 1 localhost/myapplication/controllername/edit_started(6) . controller: public function edit_started($c_id) { $data['result']=$c_id; $this->load->view('goal',$data); } view: $(document).ready(function(){ function refresh_div() { $.ajax({ type: "post", url: "<?php echo base_url(); ?>" + "dashboard/show_data", cache: false,

c - Trick to divide a constant (power of two) by an integer -

note theoretical question. i'm happy performance of actual code is. i'm curious whether there alternative. is there trick integer division of constant value, integer power of two, integer variable value, without having use actual divide operation? // fixed value of numerator #define signal_pulse_count 0x4000ul // division use neat trick. uint32_t signaltoreferenceratio(uint32_t referencecount) { // promote numerator 64 bit value, shift left 32 // result has adequate number of bits of precision, , divide // numerator. return (uint32_t)((((uint64_t)signal_pulse_count) << 32) / referencecount); } i've found several (lots) of references tricks division constant, both integer , floating point. example, question what's fastest way divide integer 3? has number of answers including references other academic , community materials. given numerator constant, , it's integer power of two, there neat trick used in place of doing actual 64 b

ruby on rails - How to set a global retry limit in sidekiq? -

i configure global retry limit in sidekiq limit number of retries. default sidekiq limits number of retries 25 want set lower workers prevent long default maximum retry period if limit not explicitly specified on worker. sidekiq.default_worker_options['retry'] = 10 https://github.com/mperham/sidekiq/wiki/advanced-options#workers

c# - "An entity object cannot be referenced by multiple instances of IEntityChangeTracker" when adding a entity to context -

i coding mvc app contains couple of many-to-many associations. 1 of them custom role <---> account association. have table full of pre-defined roles user can choose. created viewmodel holds entity model , few collections use, 1 of them roles collection. populate create form these values , resolve them again on [httppost] create action. here relevant code: viewmodel class: public class accountsviewmodel { public accounts account { get; set; } public list<roles> roleslist { get; set; } } controller code: public actionresult create() { accountsviewmodel viewmodel = new accountsviewmodel(); viewmodel.roleslist = rolesservice.getallroles(); return view(viewmodel); } [httppost] [validateantiforgerytoken] public actionresult create(accountsviewmodel viewmodel) { if (modelstate.isvalid) { foreach(roles role in viewmodel.roleslist) { if (role.isselected) { roles selectedrole

matlab - How can I write the following nonlinear constraint optimization as nonlcon in fmincon? -

Image
i want solve following optimization problem fmincon in matlab, can not define non-linear constraint. k=e(ρ(z)) , c=1 , t=5 , z=randn; r_t=ab(:,t); my loss function ρ 2 criterion functions , c constant. have written piece of code follows. x0=[0 0 0 0]';%'// ab=[ 0.0181 -0.0041 0.0040 0.0373 0.0580 0.0009 0.0250 -0.0009 0.0205 0.0302 0.0290 0.0260 0.0260 -0.0234 0.0250 -0.0136 -0.0311 -0.0451 0.0576 -0.0288]; t=5; z=randn; f=@(x) ((1/6)*(1-(1-(x)^2)^3))*(abs(x)<=1)+(1/6)*(abs(x)>=1); k=mean(f(z)); aeq=[1 1 0 0]; beq=1; fun=@(x) x(3); x=fmincon(fun,x0,[],[],aeq,beq,[],[],nonlcon); please me if can.

multithreading - openmp runs single threaded on my mac -

i trying parallelize program using openmp on mac, can not manage make multi-threaded. i've tried building llvm/clang/openmp 3.7.1 source (after svn co) documented , have tried using prebuild versions of clang , openmp 3.7.0 given llvm project . in each case, resulting compiler works fine -fopenmp flag , produce executable links openmp runtime. i use following openmp 'hello world' program: #include <omp.h> #include <stdio.h> #include <stdlib.h> int main (int argc, char *argv[]) { int nthreads, tid; /* fork team of threads giving them own copies of variables */ #pragma omp parallel private(nthreads, tid) { /* obtain thread number */ tid = omp_get_thread_num(); printf("hello world thread = %d\n", tid); /* master thread */ if (tid == 0) { nthreads = omp_get_num_threads(); printf("number of threads = %d\n", nthreads); } } /* threads

c# - What should I be using here instead of ExecuteScalar? -

i'm trying return dbset<survey> survey defined as public class survey { public int id { get; set; } [stringlength(100)] public string title { get; set; } } the error i'm getting an exception of type 'system.invalidcastexception' occurred in survey.dll not handled in user code additional information: unable cast object of type 'system.int32' type 'system.data.entity.dbset`1[survey.models.survey]'. about dbset<survey> allsurveys = (dbset<survey>)cmd.executescalar(); line of public dbset<survey> getallsurveys ( ) { sqlcommand cmd = new sqlcommand("getallsurveys", this._conn); cmd.commandtype = commandtype.storedprocedure; this._conn.open(); dbset<survey> allsurveys = (dbset<survey>)cmd.executescalar(); this._conn.close(); return allsurveys; } the table in database , sproc i'm using generated by create table surveys

node.js - Deploying NodeJs Express Rest API to Windows 10 IoT -

node noob, windows 10 iot noob, senior .net dev here. i've been able few of samples work, got led on breadboard controllable through nodejs server. using latest chakra core files , have of packages installed on dev machine, pretty clean. i guessing not able install packages specified in packages.json file, here excerpt: "express": "~4.0.0", "morgan": "~1.0.0", "mongoose": "~3.6.13", "body-parser": "~1.0.1" if packages, how 1 go deploying nodejs applications packages windows iot? considered copying application iot device , starting manually, no luck. need ms assemblies allow me interface code gpio. i trying simple rest api windows 10 iot, , having trouble. followed tutorial , , working if use non universal windows template on machine. however, when try use template (basic node.js express 4 application (universal windows)), , make same application, app deployed, debugger fails, looking @ debug

github - Immediately after git clone, I see "Changes not staged for commit" and git diff shows changes -

i'm getting weird behaviour when cloning repo developer friend working on. after git clone list of 15 different modified files when checking git status . when git diff , see actual changes code. -$this->title = 'create itemtype'; +$this->title = 'create item type'; - <h1><?= html::encode($this->title) ?></h1> - <?= $this->render('_form', [ the result of git status follows: $ git status on branch master branch up-to-date 'origin/master'. changes not staged commit: (use "git add <file>..." update committed) (use "git checkout -- <file>..." discard changes in working directory) modified: backend/models/featuregroupitem.php modified: backend/models/featuregroupitemsearch.php modified: backend/models/vendoritemquestionansweroption.php modified: backend/models/vendoritemquestionansweroptionsearch.php modified: backend/modules/admin/views/itemtype/_form.ph

sql - MS access - ranking equal values incrementally -

is possible rank records in access duplicate values given incremental rank (like row_number function in sql server)? i want rank following set of records: id type score 1 team1 4 1 team2 2 1 team3 1 1 team4 1 the query have: select * tbl tbl1 tbl1.id in ( select top 3 type tbl tbl2 tbl2.id = tbl1.id order tbl2.score ) ranks them follows id type score rank 1 team1 4 1 1 team2 2 2 1 team3 1 3 1 teams 1 3 i need rank them this: id type score rank 1 team1 4 1 1 team2 2 2 1 team3 1 3 1 team4 1 4 can done in access? edit: the rankings need grouped bigger sample of data , want represent in derived column, ids have more records others: id type score rank 1 team1 4 1 1 team2 2 2 1 team3 1 3 1 team4 1 4 2 team1 2

Kendo Chart Value axis will be changed on click event -

i have kendo chart multi value axis , kendo tree-view. want show value axis-es according checkbox selection. example check "km" checkbox, chart display km value axis. is possible? here chart code: function createchart() { $("#chart").kendochart({ legend: { position: "top" }, series: [{ type: "column", data: [20, 40, 45, 30, 50], stack: true, name: "on battery", color: "#003c72" }, { type: "column", data: [20, 30, 35, 35, 40], stack: true, name: "on gas", color: "#0399d4" }, { type: "area", data: [30, 38, 40, 32, 42], name: "mpg", color: "#642381", axis: "mpg" }, { type: "area",

OpenCL enqueueWriteImage no const void* ptr in C++ wrapper but in C function -

in cl2.hpp enqueuewriteimage takes void* ptr calls c function clenqueuewriteimage takes const void* ptr . why that? cl_int enqueuewriteimage( const image& image, cl_bool blocking, const array<size_type, 3>& origin, const array<size_type, 3>& region, size_type row_pitch, size_type slice_pitch, void* ptr, const vector<event>* events = null, event* event = null) const { cl_event tmp; cl_int err = detail::errhandler( ::clenqueuewriteimage(//... here const void* ptr appears is intended or typo? because calling function accepts const void* ptr const, too. you correct; bug in opencl c++ bindings. there few other enqueuewrite* functions same issue. i've pushed fix khronos github repository these headers - included in next release.

python - Direct way to generate sum of all parallel diagonals in Numpy / Pandas? -

i have rectangular (can't assumed square) pandas dataframe of numbers. pick diagonal direction (either "upperleft lowerright" or "upperright lowerleft"). i'd compute series entries sums of values original dataframe along chosen set of parallel diagonals. specify goal, need decide whether diagonals "anchored" on left or "anchored" on right. below, assume they're "anchored" on left. i can without trouble: import numpy np import pandas pd rectdf = pd.dataframe(np.arange(15).reshape(5,3)) # result: 0 1 2 0 0 1 2 1 3 4 5 2 6 7 8 3 9 10 11 4 12 13 14 i can compute "upperleft lowerright" diagonal sums follows: ullrsums = pd.concat([rectdf.iloc[:, i].shift(-i) in range(rectdf.shape[1])], axis=1)\ .sum(axis=1, fillna=0) # result: 0 12 1 21 2 30 3 22 4 12 and can compute "upperright lowerleft" diagonal sums flipping shift(-i) shift(i) in pre

arrays - PHP return nothing if array_column fields are blank -

the below code takes array, $array , , array key, $item , implodes adding comma each item. how can alter if value of item inside array null, implode not add blank comma. public static function implode($array, $item) { return implode(',', array_column($array, $item)); } for example: $array = [ ['eri_number' => ''], ['eri_number' => '222'] ['eri_number' => ''] ]; $item = 'eri_number'; $myclass->implode($array, $item); the above code output; ,222, i want output 222 without other blank values. can help? you filter out empties using array_filter() : return implode(',', array_filter(array_column($array, $item))); note filter out 0 , string 0 , false , null .

javascript - jQuery UI dialog closes on enter in input field -

Image
i open dialog button place cursor in input field , presses enter dialog closes , line inserted address bar: jquery: $('#dialog').load("form-incident.php").dialog({ title: "add incident", autoopen: false, resizable: false, width: 800, modal:true, position: ['center', 'top+50'], buttons: { add: function(){ $.ajax({ url : 'save.php', type : 'post', data : $('form').serialize(), context: $(this), success: function (result) { if (result === "true") { alert('incident has been added successfully'); } else { alert('error: cannot insert data mysql table'); } window.location.reload(); $(this).dialog( "close

node.js - VS 2015 Cordova Tools Update 5 installation issue -

i've been reading questions regarding haven't found can useful on current issue. i've downloaded , installed vs taco update 5 in vs 2015 enterprise. i've got installed node (4.2.1) , npm (3.3.12) well. now, having this, when create cordova new project , try build wrong. 1>------ build started: project: blankcordovaapp1, configuration: debug windows phone (universal) ------ 1> environment has been set using node.js 4.2.1 (x64) , npm. 1> ------ ensuring correct global installation of package source package directory: c:\program files (x86)\common7\ide\extensions\apachecordovatools\packages\vs-tac 1> ------ name source package.json: vs-tac 1> ------ version source package.json: 1.0.28 1> ------ package not installed globally. 1> ------ installing globally source package. take few minutes... 1> each package licensed owner. microsoft not responsible for, nor grant licenses to, third-party packages. package

How to implement Braintree payment gateway in Codeigniter? -

i have developed site using codeigniter , want use braintree same.for have followed this giving error...i tried search better tutorial/documentation me in implementing it. can tell me or suggest me better tutorial implementing braintree in codeigniter..thanks in advance.. put scripts after header / footer section, work: <?php require_once 'braintree-php-2.30.0/lib/braintree.php'; braintree_configuration::environment('sandbox'); braintree_configuration::merchantid('-----------'); braintree_configuration::publickey('-----------'); braintree_configuration::privatekey('-----------'); if(isset($_post['submit'])){ /* process transaction */ $result = braintree_transaction::sale(array( 'amount' => '100.00', 'creditcard' => array( 'number' => '5454545454545454', 'expirationdate' => '08/19' ) )); if ($result->success) {

ios - How to Add button or label to iwatch programatically -

i tinkering wkinterface , apple watch apps , wondering how add subview uibutton or uilabel . it seems uibutton *whatever = [[uibutton alloc]init]; [self.view addsubview:whatever]; does not work iwatch extension. [self.view addsubview: ] part doesnt seem work. does know how add view programatically apple watch or have use interface builder , drag , drop these objects. you have use interface builder. cannot allocate ui objects yourself. creating interface object you create interface objects indirectly adding object storyboard scene , referring interface controller. after adding element storyboard, create outlet in interface controller. during initialization of interface controller, watchos creates interface objects of connected outlets automatically. you never create interface objects yourself.

css - without div: text an headline with background over an image -

i want place headline + text background color on image (in upper right corner) don´t know if work without div around h1 , p tag. work chained selectors? im little bit baffled. how solve positioning question? here´s code: <div class="class1 class2 "> <h1>headline</h1> <p>text</p> <figure class="class3 class4"> <img class="at2x" width="950" height="609" alt="" src=""> </figure> </div> and fiddle because wrote can't use image background, imho should in this example . html <div class="class1 class2 "> <h1>headline</h1> <p>text</p> <figure class="class3 class4"> <img class="at2x" width="950" height="609" alt="" src="http://placekitten.com/950/609">

Group By on a calculated field using T-SQL -

i have following code: select distinct m.property_id, m.property_size, count(f.request_id) wos, round(cast(m.[property_size] float(10)) / cast((f.[request_id] * 1000) float(5)),2) per_1k_sqft t1 m, t2 f m.property_id = f.property_id , datepart(year,request_date) = '2015' , datepart(month, f.request_date) = '12' group m.property_id, m.property_size, round(cast(m.[property_size] float(10)) / cast((f.[request_id] * 1000) float(5)),2) order count(f.request_id) desc my last column, per_sq_ft zeros. why isn't populating result of calculation?

c# - How can I pair objects to radio buttons? -

i'm working on small form app, , have "paired" radio buttons lists in common class. purpose of turn on/off corresponding list public class mytype { public radiobutton button { get; set; } public listbox list { get; set; } } i proceed create these pairs through loop inside array for (int = 0; < broj_botuna; i++) { thearray[i] = new mytype(); } i use common event handler radio buttons: private void test_checkedchanged(object sender, eventargs e) { var xx = sender radiobutton; //do stuff positioninarray = array.indexof(thearray, xx); } except last line of code "xx" should of type "mytype" , not "radiobutton" managed retrieve. so tell me how reference "radiobutton" "mytype"? or there better alternative? you can use array.findindex like: var positioninarray = array.findindex(thearray, b => b.button == xx);

javascript - Find an image tag? -

i have content editable div, have tags in it, eg. <p>hello</p> <p>whatever <p>nested p bad idea can happen</p></p> <div>stuff</div> <p>test<img></p> for given element, need find img tag above in source order. image tag direct sibling, or child of sibling or parent of given element. here's pretty simple recursive function should want , works generically. function findpreceeding(element, targettype) { var target = element.prev(targettype); if (target.length > 0 || element.parent().length === 0) return target; else return findpreceeding(element.parent(), targettype); } $(function() { console.log(findpreceeding($("#div1"), "img").toarray()); console.log(findpreceeding($("#div2"), "img").toarray()); console.log(findpreceeding($("#div3"), "img").toarray()); console.log(findpreceeding($("#div4")

r - Finding the third Friday of a month and data table -

i want find third friday of month delivery date of futures, used solution here , getnthdayofweek rcppbdt package: library(data.table) library(rcppbdt) data <- setdt(data.frame(mon=c(5:12, 1:12, 1:12, 1:4), year=c(rep(2011,8), rep(2012,12), rep(2013,12), rep(2014,4)))) data[, third.friday:= getnthdayofweek(third, fri, mon, year)] however message: error: expecting single value . missing? since did not specify by clause in transformation, := (presumably) trying apply getnthdayofweek vectorized function. this should work: data[ ,third.friday := getnthdayofweek(third, fri, mon, year) ,by = "mon,year"] data # mon year third.friday #1: 5 2011 2011-05-20 #2: 6 2011 2011-06-17 #3: 7 2011 2011-07-15 #4: 8 2011 2011-08-19 #5: 9 2011 2011-09-16 #6: 10 2011 2011-10-21 #7: 11 2011 2011-11-18 #8: 12 2011 2011-12-16 #9: 1 2012 2012-01-20 or, more generally, in case have duplicate mon,year tuples in object