Posts

Showing posts from May, 2013

security - Is this jquery code secure? -

is following code secure? $iframe = $('<iframe id="iframe" src="' + $(this).attr('rel') + '" name="iframe">'); $area = $("#ajax-area"); $area.empty().append($iframe); where: $(this) link clicked. attr('rel') holds src iframe , rel created php (no user input here). and $iframe holds form upload. my concern is, since in case iframe's src variable fear malicious user somehow manages edit 'rel' attribute , open iframe or wants. possible? edit thanks valuable answers. php uses following populate rel: app::basepath . '/some/path/to/my/folder'; where basepath constant developer chooses. i'll redesign jquery in more proper way guys suggested. theoretically, if rel attribute based on server constant, there should no additional security issues other ones can't control, such mitm. however, should on safe side these things; , jquery provides safety a

sql - How to get the last not null value from previous rows -

Image
i know there lot of solutions unfortunately cannot use partition or keyword top. nothing tried on earlier posts works. my table looks this: the result want when completion percentage null should value last non-value completion percentage, this: this done using outer apply : select t.projectname, t.sequence, coalesce(t.completion_percentage, t2.completion_percentage) completion_percentage t outer apply (select top 1 t2.* t t2 t2.projectname = t.projectname , t2.completion_percentage null , t2.sequence < t.sequence order t2.sequence desc ) t2;

php - If statement to not show div / h2 -

this each / if statement displays changes, , right below it displays changes made. i trying write if statement tells not show h2 , #change_box if there no changes. help appreciated. <h2 class="changes"> changes: </h2> <div id="change_box"> <? foreach ($audit['events'] $event):?> <?if ( $event['type'] != 'comment'):?> <span class="field"> <?= $event['field']?> </span>: <?= $event['value'] ?> <?=($event['previous'])?> <?endif?> <?endforeach?> </div> <?php if ($changes) { // you'll have set variable //echo of html else { //echo stuff you'd rather show if didn't change } ?> to give idea of how i'd write code <?php if ($changes) { echo '<h2 class="changes">changes:</h2>'; echo '<div id="change_b

android - Androidplot background, start, end values and ranges -

Image
i trying create custom xyplot androidplot can't seem configure it. this code: xyseries series = new simplexyseries(arrays.aslist(dates), arrays.aslist(times), "time on level"); // create formatter use drawing series using lineandpointrenderer: lineandpointformatter formatter = new lineandpointformatter(color.rgb(0, 100, 0), color.rgb(0, 100, 0), null, new pointlabelformatter(color.blue)); totaltimeplot.setrangevalueformat(new decimalformat("#.#")); totaltimeplot.setgridpadding(0, 0, 0, 200); totaltimeplot.setbackgroundcolor(color.white); totaltimeplot.getgraphwidget().getbackgroundpaint().setcolor(color.white); totaltimeplot.getgraphwidget().getgridbackgroundpaint().setcolor(color.white); totaltimeplot.getgraphwidget().getdomainoriginlinepaint().setcolor(color.black); totaltimeplot.getgraphwidget().getrangeoriginlinepaint().setcolor(color.black); totaltimeplot.setticksperdomainlabel(1); totaltimeplot.set

java - Start MainActivity when android kill my process -

when app inactive time android kills process, making static variables null. destroying activities etc. want app launch mainactivity(activity declared launcher in manifest) instead of activity in foreground when app got minimalized , later killed. thanks in advance the right way store data need (that storing on static vars) on database , use memory cache. the not hammer time way it... simple. in each oncreate of activities need info, check if info null, , if is, invoke finish() , startactivity 1 want. @override protected void oncreate(){ super.oncreate(); ... if(singleton.getinfo() == null){ this.finish(); startactivity(...) } }

c++ - Custom size integers in MySQL and Sparksee databases -

is there way define type of integers, 7 bits long? or @ least 1 byte long? want replace standard integers stored in database reduce size. using databases: mysql, sparksee (for graphs). , languages: c++, objective-c++. using char instead of int - best option? mysql supports tinyint (8 bit), smallint (16 bit), mediumint (24 bit), int (32 bit), , bigint (64 bit) data types. http://dev.mysql.com/doc/refman/5.7/en/integer-types.html the corresponding c language data types int8_t , int16_t , int32_t , , int64_t . there isn't standard 24-bit data type in c. see more information. http://www.nongnu.org/avr-libc/user-manual/group__avr__stdint.html these signed data types. so, example, int8_t has potential values in range [-128, 127]. you need large number of records in system cost saving using smaller integers exceed 1 dollar us. ssd drives cost less $0.50 per gigabyte. best spend time , effort elsewhere.

Getting value from <select> statement from jsp to Action class -

i have following <select>..</select> in code: <select name="approvername"> <option value="first name">my first name</option> <option value="second name">my second name</option> <option value="third name">my third name</option> <option value="fourth name">my fourth name</option> </select> when try value in action class,like string approvername = request.getparameter("approvername") shows null when try print it. how value? in action class instead of using string approvername = request.getparameter("approvername") i've changed to string approvername = (string)areq.getparameter("approvername"); and works!!

java - Execute db statements from file -

i use embedded apache derby application. have sql script called createdb.sql creates tables in database , populates initial data, e.g.: set schema app; create table study ( study_id bigint not null generated identity (start 1, increment 1), name varchar(50) not null, note varchar(1000) default '', created timestamp default current_timestamp, deleted boolean default false, unique(name), constraint primary_key primary key (study_id) ); insert "app"."study" (name) values ('default'); create table img ( img_id bigint not null generated identity (start 1, increment 1), filename varchar(200) not null, path varchar(300) not null, flipped boolean default false, type smallint not null, note varchar(1000) default '', created timestamp default current_timestamp, primary key (img_id) ); alter table img add column dpix integer default -1;

c - Expression must be a modifiable lvalue when mallocing -

i understand question has been asked before, can't quite narrow down i've done wrong here int* arr[2]; arr = (int (*)[2]) malloc(sizeof(int) * size); why visual studio telling me expression must modifiable lvalue? i'm trying create array constant column size, since two, rows vary. arr array of pointers. cannot assign once initialized. since trying set value return value of call malloc , want pointer array. in case, use: int (*arr)[2]; also, don't cast return value of malloc . see do cast result of malloc? . use int (*arr)[2]; arr = malloc(sizeof(*arr) * size); // ^^^^^^^^^^^^ speculating need, // not sizeof(int) if want arr point array of 15 x 2 objects, need use: arr = malloc(sizeof(*arr) * 15);

asp.net mvc - Application design using DDD -

i designing solution strucure application. planning use domain driven design. asp.net mvc , entity framework. need inputs in areas. data access designed using entity framework code first reposirotires built on top of ef data acces domain model designed usind domain model on top of repositories application serveices built on top of damain layer ui developed on top of application services the flow is ui (controller) --> application service --> domain layer --> repositories --> data access --> data base. i not clear of how share data in between layers. my domain model can used sahre data between repositories, data access , domain layer. thinking way data should passed daomin layert application service , application service ui. can use dtos, not sure weather option or not, have models in domain model, view model in ui. reuse domain model or ui model not good, make layers tightly coupled. it's difficult develop large scale applications way. what

monitoring - nginx status : requests? -

acorrding nginx stats module server accepts handled requests -- nginx accepted 16630948 connections, handled 16630948 connections (no 1 closed accepted), , handles 31070465 requests (1.8 requests per connection) i know requests part means 1.8 per connection not make sense me in advance. nowadays keep-alive (or persistent) http connections normal, in http 1.1. 1 keep-alive connection can handle more 1 request. reference: http://en.wikipedia.org/wiki/http_persistent_connection

javascript - how to display Images with out uploading. -

how upload image out being saved in server , delete temp files every hour. normaly, when user uploads image, it's automaticly stored server. in temp dir or direction you've told. if don't wan't have file on server, use html5 localstorage. https://www.ibm.com/developerworks/mydeveloperworks/blogs/bobleah/entry/html5_code_example_store_images_using_localstorage57?lang=en heres link witch you: loading image localstorage , setting image src location

c++ - operator== of a type erased container -

consider following class wraps container , type-erase s type: class c final { struct b { virtual bool empty() const noexcept = 0; }; template<class t, class a> struct d: public b { // several constructors aimed // correctly initialize underlying container bool empty() const noexcept override { return v.empty(); } private: std::vector<t, a> v; }; // ... public: //... bool operator==(const c &other) const noexcept { // ?? // compare underlying // container of other.b 1 // of this->b } private: // initialized somehow b *b; }; i'd add operator== class c . internally, should invoke same operator on underlying containers, i'm stuck on problem, don't know how that. idea 2 instances of c equal if operator== of underlying containers return true . whatever i've tried till now, ever ended being unable type of 1 of 2 under

jquery - ajaxForm is not working ie 10 -

am using ajax form plugin. link http://www.malsup.com/jquery/form/#api plugin.. jquery('#update-personal-information-form').ajaxform( { beforesubmit: function() { jquery('#update-personal-information-form').validate({ errorclass: "error", errorelement: "div", rules:{ first_name:{required:true}, last_name:{required:true}, email:{required: true, email:true}, dob:{required: true,dateiso: true} }, messages:{ first_name:{required:" first name:cannot blank"}, last_name:{required:" last name:cannot blank"}, email:{required:" email:cannot blank"}, dob:{required:" date of birth:cannot blank",dateiso: "inv

asp.net - Am having an error message Could not load type 'Microsoft.Samples.Web.ImageOptimizationModule when using sprites -

i have error while using ap sprites.am not able it. i have added following code in web.config <system.webserver> <modules runallmanagedmodulesforallrequests="true"> <add type="microsoft.samples.web.imageoptimizationmodule" name ="microsoft.samples.web.imageoptimizationmodule"/> </modules> </system.webserver> <system.web> <pages> <controls> <add tagprefix="asp" namespace="microsoft.web.samples" assembly="microsoft.web.samples.imagesprite" /> </controls> </pages> <httpmodules> <add type="microsoft.samples.web.imageoptimizationmodule" name="microsoft.samples.web.imageoptimizationmodule" /> </httpmodules> <compilation debug="true" targetframework="4.0" /> </system.web> and have created folder app

Is possible to use a common session variable for flex and asp.net -

i have asp website has page embeded swf file.the swf file build using flex. want set value in session variable in flex , later use session variable in asp retrieve value. or there method know changes made in flex(swf file) @ asp side. note swf file has grid in data change occur. you can either of these: assign change hidden variable in web page. query variable @ server side in asp .net. , put in session. or when want change thing in session, call webservice javascript should change value in session(or whatever want in server). see how can call asp.net webservice flex .

wso2esb - How to return other datatypes while writing Custom class mediator in wso2 esb -

write have situation. writing custom mediator implements mediate function returns boolean. instead want return other datatype well. trying achieve thsi writing custom code add 2 numbers , return result. not able figure out, how can return integer instead of boolean. please provide me example related situation. have written code inside custom class mediator as: public boolean mediate(messagecontext messagecontext) { system.out.println("checkpoint1: openpublication.mediate()"); if (getchanneluri() != null && !getchanneluri().isempty()) { messagecontext.setproperty("sessionid", uuid.randomuuid().tostring()); system.out.println("checkpoint2: sessionid property set"); synapseconfig = messagecontext.getconfiguration(); system.out.println("checkpoint3: messagecontextsessionid = " + messagecontext.getproperty("sessionid")); system.out.println("checkp

scala - Option and Future -

i in process of building ubercool application amazing amount of abstractions. going design over-engineered entitygetservice. first thing want lot of abstract types, let this: trait entitygetservice[id, entity, container] { def get(id: id): container } container here type of contains (or not contains) requested entity. similar option[entity]. second thing want, container can future[entity]. so want write trait this: trait entitygetservice[id, entity, container <: wrapper[entity]] { def get(id: id): container } and specify in such ways: trait entitysyncgetservice[long, entity, option[entity]] { def get(id: long): option[entity] } trait entityasyncgetservice[long, entity, future[entity]] { def get(id: long): future[entity] } is there way without re-extending or mixing option , future? it looks option , future have bit of in common (their both containers). related monads? or product of insomnia? not commenting on reasonableness of all, can

list - How to dynamically make multiple Labels, Edits and etc. in Delphi? -

i want users create own list of controls such tedit , tcheckbox , tlabel , , other things. how can make another, when have predefine every control, don't know how many objects define? this should create each object knowing class type: var obj:tcontrol; begin obj := tedit.create(aowner); obj begin //set properties here... ... parent := self; //assuming you're writing code in form class. if not, use object variable pointing form instead of `self` end; end; to store unknown number of objects, can either use dynamic array, or link list, or can use controls property of form. this start of want (basics). have plenty choices implementing part of application. example, can have array of tcontrol in form class, , using length , setlength functions can figure out how many objects user has added form.

How to Publish Visual Studio Database Project in VS 2015 -

i unable google this. we have existing database project (sql server). some new files (scripts) added. we have existing server / database new scripts need run context. in visual studio 2015, how can accomplish this? i told stay inside visual studio 2015. ideally, i'd issue 1 command vs 1 each individual script. you have couple of choices. the publish option. totally automated deployment of what's in db project target server. right-clicking project , selecting publish. option can used perform incremental deployment (only changes deployed) or can used wipe database clean followed full deployment of db project, check options before performing publishing. schema comparisons. schema comparisons perform comparison of db project target database, shows differences, , lets select differences deploy. can perform schema comparison adding new schema compare file database project. in short, publish option allows automated brute force deployments whereas schema

web services - Application server with servlet 3.0 support..? -

i need application server servlet 3.0 support.. currently working on tomcat need know other application servers support servlet 3.0.. please me if known tomcat not application server, merely servlet container. can try glassfish.

dpi - Screen sizes of android design in pixels? -

as found in android documentation site, there 4 general sizes android devices screens. found measurements unit in dp . : xlarge screens @ least 960dp x 720dp large screens @ least 640dp x 480dp normal screens @ least 470dp x 320dp small screens @ least 426dp x 320dp how on photoshop, how sizes in pixels ? need have 4 design ldpi , mdpi , hdpi , xhdpi ? need have 16 versions of design. ? yes have 4 designs : xhdpi = 100% image hdpi = 75% image of xhdpi image mdpi = 50% image of xhdpi image ldpi = 50% image of hdpi image i.e : if have 96 x 96 image in xhdpi then, need put 72 x 72 in hdpi folder - ( 75 % of xhdpi ) 48 x 48 in mdpi folder - ( 50 % of xhdpi ) 36 x 36 in ldpi folder - ( 50 % of hdpi )

php - Table width with Smarty -

how use alternative width in table php? used way getting error. <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="{if $label_payment}{echo = 50%}{else}{echo = 100%}{/if}">shipping address </td> <td>payment address </td> </tr> <tr> <td width="{if $label_payment}{echo = 50%}{else}{echo = 100%}{/if}">{$address_label_shipping} </td> {if $address_label_payment} <td width="50%">{$address_label_payment} </td> {if} </tr> </table> is correct way? {if $label_payment}{echo = 50%}{else}{echo = 100%}{/if} there no echo: {if $label_payment}50%{else}100%{/if} leading to: <td width="{if $label_payment}50%{else}100%{/if}">

python - Socket-Management in Nginx with Flask - Why is Cross-Origin Request Blocked? -

i want create socket in flask-socketio through nginx , unicorn. following configuration works on localhost without nginx. when access web application through nginx in chrome, error: failed load resource: not connect server. http://52.34.18.48:6419/socket.io/?eio=3&transport=polling&t=1454455363683-6 when access web application through nginx in firefox, error: cross-origin request blocked: same origin policy disallows reading remote resource @ http://52.34.18.48:6419/socket.io/?eio=3&transport=polling&t=1454464333740-25 . (reason: cors request failed). this how initialize socket connection in javascript: import io "socket.io-client" const socketurl = 'http://' + document.domain + ':6419' + '/flaskapp' const socket = io(socketurl); export default socket; my nginx config file looks this: server { listen 80; server_name 52.34.18.48; error_log /var/www/flaskapp/nginx_errorlog.log; access_l

pyspark - Is it possible to get sparkcontext of an already running spark application? -

i running spark on amazon emr yarn cluster manager. trying write python app starts , caches data in memory. how can allow other python programs access cached data i.e. i start app pcache -> cache data , keep app running. user can access same cached data running different instance. my understanding should possible handle on running sparkcontext , access data? possible? or need set api on top of spark app access data. or may use spark job server of livy. it not possible share sparkcontext between multiple processes. indeed options build api yourself, 1 server holding sparkcontext , clients telling it, or use spark job server generic implementation of same.

Best Android phones for testing -

can suggest performance 3 android phones btw 15k-20k,for testing purposes....i need test apps related wifi , basic stuff..thanks. what mean 15k-20k, ? in usd or inr or lkr??? for testing purpose, better buy nexus device nexus family . run os released google. nexus s nexus one galaxy nexus nexus 4 nexus 7 (tablet) nexus 10 (tablet) on other hand may consider buying sii, siii samsung there huge fragment of android market using mobiles.

cordova - Phonegap+jQuery Mobile, overall sluggish controllers -

i'm using phonegap , jquerymobile develop android app, i'm having pretty hard time overall sluggishness on stuff buttons , select menus. sometimes work fine, of times takes several taps work, lot of buttons "stuck" on hover state/pressed state, select menus pretty slow , taps registering different options ones tapped. one thing note removing data-role="content" pages seems have performance improvement (big case of wtf), have tried $.mobile.buttonmarkup.hoverdelay = 0; , doesn't seem have effect. my pages extremely light far (not rendering content server side yet/all scripts referenced locally/only 4 pages of pure html), i'm using slide effect (which works btw, no sluggishness on department), it's controllers killing me i'm testing on 4.0 device, not sure if missing something, if it's clunky project, don't want think how it's going when started... jquery mobile on mid range , entry level phones sucks time. mar

php - Google API login -

Image
i try fetch data google analytics using google api class in php. checked serval google groups , found out error comes of time when curl off , ssl off too, checked in phpinfo() , booth running. idea be? on local server it's running, on webserver it's not running. <br /> <b>fatal error</b>: uncaught exception 'exception' message 'gapi: failed authenticate user. error: &quot;error=badauthentication url=https://www.google.com/accounts/servicelogin?service=analytics#email=mail info=webloginrequired &quot;' in /home/express/public_html/loggedin/gapi.class.php:418 stack trace: #0 /home/express/public_html/loggedin/gapi.class.php(62): gapi-&gt;authenticateuser('mail', 'pw') #1 /home/express/public_html/loggedin/request.php(10): gapi-&gt;__construct('mail', 'pw') #2 {main} thrown in <b >/home/express/public_html/loggedin/gapi.class.php</b> on line <b>418</b><br />

How to use moment.js library in angular 2 typescript app? -

i tried use typescript bindings: npm install moment --save typings install moment --ambient -- save test.ts: import {moment} 'moment/moment'; and without: npm install moment --save test.ts: var moment = require('moment/moment'); but when call moment.format(), error. should simple, can provide command line/import combination work? we're using modules now, try import {momentmodule} 'angular2-moment/module'; after npm install angular2-moment.. http://ngmodules.org/modules/angular2-moment

parallel processing - Parallelization of an openMP nested do loop -

i have nested loop in openmp fortran 77 code unable parallelize (the code gives segmentation fault error when run). have similar nested loop in different subroutine of same code runs parallel no issues. here nested loop having problems with: n=1,num_p c$omp parallel default(shared), private(l,i1,i2,j1,j2,k1,k2 c$omp& ,i,j,k,i_t,j_t,i_ddf,j_ddf,ddf_dum) l=1,n_l(n) call del_fn(l,n) i1=p_iw(l,n) i2=p_ie(l,n) j1=p_js(l,n) j2=p_jn(l,n) k1=p_kb(l,n) k2=p_kt(l,n) i=i1,i2 i_ddf=i-i1+1 if(i .lt. 1) i_t=nx+i elseif (i .gt. nx) i_t=i-nx else i_t=i endif j=j1,j2 j_ddf=j-j1+1 if(j .lt.1) j_t=ny+j elseif(j .gt. ny) j_t=j-ny else j_t=j endif k=k1,k2

c# - How to mock(rhino.mocks) response object from base.SendAsync() in MVC4.5 Web API handler SendAsync() method -

i have write unit test on asp.net mvc web api controller rhino.mock have handler named ahandler.cs inherts system.net.http.httpclienthandler class. singnature sendasync method of ahandler.cs followings : protected override task<httpresponsemessage> sendasync(httprequestmessage request, cancellationtoken cancellationtoken) { ..... var response = base.sendasync(request, cancellationtoken).result; if (response.issuccessstatuscode) { ..... } } the base keyword above means httpclienthandler , sendasync() method "protected"!!! try mock object "base.sendasync(request, cancellationtoken).result" , got hand-made response result wanted. seems rhino mocks can't see "base" keyword when wrote followings code : var mockbase = mockrepository.generatemock<ahandler>; mockbase.stub(x => x.base <=== can't see base keyword ^^^^^ so change way , try mock httpclienthandler class var mockbase = mockrepository.gener

c# - SiteMapNode OnClick Event MVC 5 -

currently using mvc 5 , c#. trying trigger popup (javascript) clicking button tied sitemapnode lives in navigation menu bar. not want navigate away current page, problem because sitemapnode requires "url" attribute and/or "action" attribute. basically want sitemapnode behave stupid button onclick attribute fires javascript. without leaving page. the clearest answer i've found is: jquery dialog sitemapnode but uses webforms , solution not translatable. have found 0 answers of how in mvc. thanks! sam

javascript - Can you dynamically change the dragged Element in HTML5 Drag Drop API? -

description : trying add drag , drop functionality canvas element. observed browser natively supports dragging , dropping image elements , dragged images can directly added gmail or saved on computer. considered solution1 : 1. wrap dragged element ('canvas') in div tag , add 'draggable' true attribute it. 2. append image element(using canvas.todataurl('images/png') ) parent dragged div , hide image. 3. once dragstart fires show image element , hide data element. problem : unfortunately not seem work. dragged event still considers div. ( eg: cannot dropped on gmail email ). investigation till now : key difference found dragged event had attributes called targetelement, sourceelement , toelement set div(in case) compared img(in case there image inside div). drag event object in case.(div 'canvas') sourcecapabilities: inputdevicecapabilities srcelement: div#test_container <== div target: div#test_container <== div

notepad++ regex save custom info, but change brackets type -

Image
so. have plenty of straigt in code like *tons of text* get_sprite_ori('normal/mi/randomtextihavetosave.png') *tons of text* i figured out how find kind of text: get_sprite_ori\('.*?'\) have make text kinda that: *tons of text* "images/sprites/normal/mi/randomtextihavetosave.png" *tons of text* i tried "$1" , "images/sprites/$1", still changes on "" or "images/sprites/" if still didn't understand: have tons of blocks these: image mi serious voca = conditionswitch("persistent.sprite_time=='sunset'", im.matrixcolor(im.composite((1050, 1080), (0, 0), get_sprite_ori('normal/mi/mi_3_body.png'), (0, 0), get_sprite_7dl('normal/mi/mi_3_voca_dress.png'), (0, 0), get_sprite_ori('normal/mi/mi_3_serious.png')), im.matrix.tint(0.94, 0.82, 1.0)), "persistent.sprite_time=='night'", im.matrixcolor(im.composite((1050, 1080), (0, 0), get_spr

asp.net mvc 4 - AuthorizeRoles=admin how redirect to index when is false. -

in mvc 4 application simplemembershipprovider . i'm decorating controller attribute [authorize(roles = "admin")] . when roles false i'm redirecting user login page. how can change redirect index page? you can use custom authorize attribute overriding authorizeattribute as [customauthattribute(roles = "admin")] code: using system; using system.web.http; using system.net.http; public class customauthattribute : authorizeattribute { public override void onauthorization(system.web.http.controllers.httpactioncontext actioncontext) { /* if authorization condition fails */ if(!condition) { handleunauthorizedrequest(actioncontext); } } protected override void handleunauthorizedrequest(system.web.http.controllers.httpactioncontext actioncontext) { filtercontext.result = new redirecttorouteresult( new routevaluedictionary

Java vertx 3.2 file upload using bodyhandler -

java.lang.illegalstateexception: request has been read exception in vertx3.0. tried in many ways. simple formupload working fine. when use body handler, throwing below exception. can ? import io.vertx.core.abstractverticle; import io.vertx.core.http.httpheaders; import io.vertx.ext.web.router; import io.vertx.ext.web.handler.bodyhandler; /* * @author gogs */ public class testserver extends abstractverticle { // convenience method can run in ide public static void main(string[] args) { runner.runexample(testserver.class); } @override public void start() throws exception { router router = router.router(vertx); // enable multipart form data parsing router.route().handler(bodyhandler.create()); router.route("/").handler(routingcontext -> { routingcontext.response().putheader("content-type", "text/html").end( "<form action=\"/form\" enctype=\"multipart/form-data\" meth

How to remove the special characters when getting the data using json in android? -

i working on android application. need data php web service. response getting php server shown below: string response = [{id:100,category:local,count1:58,count2:86}, {id:101,category:server/local,count1:18,count2:27}, {id:102,category:server & local,count1:19,count2:28}]; but getting following message when trying separate data using json. org.json.jsonexception: unterminated object @ character how remove special characters , data using json array? strings should under double quotes. json not valid response. change response from {id:100,category:local,count1:58,count2:86} to { "id":100, "category":"local", "count1":58, "count2":86 } refer here

sql - Postgresql: How to export tables into separate csv files -

i want export entire database aws s3 later import bi tools. need export each database table own csv file. dont wanna manually or script-fu. mysql have this . there easy way achieve postgresql? with query can list tables in schema public : select table_schema, table_name information_schema.tables table_type = 'base table' , table_schema = 'public'; you can use query in function, execute appropriate copy command each table_name: create or replace function copy_my_tables () returns void language plpgsql $$ declare r record; begin r in select table_schema, table_name information_schema.tables table_type = 'base table' , table_schema = 'public' loop execute format ('copy %s.%s ''c:\data\%s_%s.csv'' (format csv)', r.table_schema, r.table_name, r.table_schema, r.table_name); end loop; end $$; select copy_my_tables();

regex - PCRE "or" operator behavior? -

if have 1) /foo|oo/ 2) /oo|foo/ , using pcre , match against string "foo" expected result is 1) foo 2) oo . pcre keeps "or" order. foo . pcre tries variants , goes longest match. there no preset rule, optimizer might reorder sees fit. duty of developer avoid ambiguous scenarios this. there rule it's not 2. "try , see" seems kill 1.) there no way determine between 2-3-4 trial , error. 4) match closest start of string. when multiple matches possible current position, match option matches sooner. e.g. banana matching against /na/ (showing match uppercase): banana (sooner banana ). against /an|b/ , matches banana (sooner banana ). against /ba|./ , matches banana (same position, ba matches before . ). against /.|ba/ , matches banana (same position, . matches before ba ).

Word online and Word XML -

is possible access underlying xml task pane app on word online? able use functions getnamesoaceasync or getxmlasync in desktop word online word throws error code 6000 - no such node found. that's correct. customxmlpart.getxmlasync() , customxmlprefixmappings.getnamespaceasync() not available in office online (in browser). however, other calls available such document.getselecteddataasync() , can called coerciontype of office.coerciontype.ooxml retrieve ooxml.

induction - Dafny and counting of occurences -

i've been looking @ use of lemmas in dafny finding hard understand , below example doesn't verify, quite possibly because dafny doesn't see induction or lemma prove property of count? basically, don't know how or need define convince dafny counting inductive , thing etc. of ensures , invariants specifications not necessary, that's not point. btw, easier in spec#. function count(items: seq<int>, item: int): nat decreases |items| { if |items| == 0 0 else (if items[|items| - 1] == item 1 else 0) + count( items[..(|items| - 1)], item ) } method occurences(items: array<int>, item: int) returns (r: nat) requires items != null ensures r <= items.length // number of occurences of item ensures r > 0 ==> exists k: nat :: k < items.length && items[k] == item // no occurences of item ensures r == 0 ==> forall k: nat :: k < items.length ==> items[k] != item en

AngularJS need to click more than 1 time for UI update? -

i have simple button inside toolbar: <md-toolbar> <div class="md-toolbar-tools" layout="row" layout-align="space-between left"> <md-button class="md-icon-button" aria-label="settings"> <md-icon md-svg-icon="images/ic_local_airport_24px.svg"></md-icon> </md-button> <h2> <span class="md-title"> <font> title </font> </span> </h2> <span> <!-- <md-button class="md-icon-button" aria-label="languageenglish" style='width: 1px !important; padding-left: 2px !important; padding-right: 2px !important;'>|</md-button> --> <md-button ng-click='test()' class="md-icon-button&quo

javascript - How to correctly send/receive Unicode in XMLHttpRequest -

i trying send string containing · character server using xmlhttprequest. using following code set content type in javascript code: xmlhttpreq.setrequestheader("content-type", "application/x-www-form-urlencoded; charset=utf-8") now if actual utf-8 value · , e.g. using page this one or this one , tells me value should 183, or 0xc2 0xb7 utf-8 hex bytes. see latter being sent server. server, when returns data encodes string "\u00c2\u00b7", or literal bytes 0x5c 0x75 0x30 0x30 0x43 0x32 0x5c 0x75 0x30 0x30 0x42 0x37. response passed json.parse(xmlhttpreq.responsetext) converts · . did  come from? the page utf-8, xmlhttprequest utf-8, document.codeset utf-8, , server response utf-8. it's problem url encoding, not text encoding. please read this: http://www.w3schools.com/tags/ref_urlencode.asp you must url decoding in pure c cgi.

erlang - Cannot compile ejabberd when checked out from Git repository -

i have built ejabberd module in intellij using rebar compile , getting error "undefined parse transform 'lager_transform'" rebar.config: {erl_opts, [nowarn_deprecated_function, {d, 'lager', true}, {d, 'no_ext_lib'}, {i, ["c:/program files/ejabberd-15.11/bin"]}, {i, ["c:/program files/ejabberd-15.11/lib/ejabberd-15.11/include"]}]}. i added these lines config file after checking responses on site: {deps, [{lager, ".", {git, "https://github.com/basho/lager", {tag, "3.0.2"}}}, {p1_utils, ".", {git, "https://github.com/processone/p1_utils", {tag, "1.0.3"}}}, i proceed try "rebar get-deps" fail with: pulling lager {git,"https://github.com/basho/lager",{tag,"3.0.2"}} error: rebar requires version {1,5} or higher of git process {git, "https://github.com/basho/lager",{tag,"3.0.2"}} error: 'get-deps' failed whi

Fastest way to apply color matrix to RGB image using OpenCV 3.0? -

i have color image represented opencv mat object (c++, image type cv_32fc3). have color correction matrix want apply each pixel of rgb color image (or bgr using opencv convention, doesn't matter here). color correction matrix 3x3. i iterate on pixels , create vector v (3x1) representing rgb, , compute m*v, slow real-time video application. the cv::cvtcolor function fast, not seem allow custom color transformations. http://docs.opencv.org/2.4/modules/imgproc/doc/miscellaneous_transformations.html#cvtcolor similar following, using opencv c++, not python. apply transformation matrix pixels in opencv image basically linked answer uses reshape convert cv_32fc3 mat of size m x n cv_32f mat of size (mn) x 3 . after that, each row of matrix contains color channels of 1 pixel. can apply usual matrix multiplication obtain new mat , reshape original shape 3 channels. note: may worth noticing default color space of opencv bgr, not rgb.

how to Map rtf file rows to 3 RichTextBox in VB.Net 2010? -

this question exact duplicate of: map rtf file lines different richtextbox in vb.net 2010? [closed] 1 answer i need split "richtextbox4 rows" richtextbox1 take row number 1 richtextbox2 take row number 2 and richtextbox3 take row number 3 so 3 richtextboxs take row "richtextbox4 rows" try code integer = 0 richtextbox1.lines.count if = 0 richtextbox2.text = richtextbox1.lines(i) elseif = 1 richtextbox3.text = richtextbox1.lines(i) elseif = 2 richtextbox4.text = richtextbox1.lines(i) end if next

java - Strange Issue on Andengine when using android layout with LayoutBaseGameActivity? -

i using andengine in application animation. when using sprite click event gives strange issue. using sprite hide show view in android native layout. my logcat output 04-01 18:21:43.966: e/androidruntime(1875): fatal exception: glthread 3832 04-01 18:21:43.966: e/androidruntime(1875): java.lang.indexoutofboundsexception: invalid index 42, size 42 04-01 18:21:43.966: e/androidruntime(1875): @ java.util.arraylist.throwindexoutofboundsexception(arraylist.java:251) 04-01 18:21:43.966: e/androidruntime(1875): @ java.util.arraylist.get(arraylist.java:304) 04-01 18:21:43.966: e/androidruntime(1875): @ org.andengine.entity.entity.onmanageddraw(entity.java:1382) 04-01 18:21:43.966: e/androidruntime(1875): @ org.andengine.entity.scene.scene.onmanageddraw(scene.java:260) 04-01 18:21:43.966: e/androidruntime(1875): @ org.andengine.entity.entity.ondraw(entity.java:1160) 04-01 18:21:43.966: e/androidruntime(18

angularjs - What is the use of angular.copy in this situation? -

i referring code on form posting coresponding angular documentation on simple form. what use of angular.copy on here? seems code still working fine in case angular.copy being removed. <div ng-controller="examplecontroller"> <form novalidate class="simple-form"> name: <input type="text" ng-model="user.name" /><br /> e-mail: <input type="email" ng-model="user.email" /><br /> gender: <input type="radio" ng-model="user.gender" value="male" />male <input type="radio" ng-model="user.gender" value="female" />female<br /> <input type="button" ng-click="reset()" value="reset" /> <input type="submit" ng-click="update(user)" value="save" /> </form> <pre>user = {{user | json}}</pre> <pre>maste

log4j set different log files for different packages programmatically -

i know how set different log files different packages in log4j.properties file, want set them programmatically. for example, how can manage configuration programmatically? log4j.appender.myappeder=org.apache.log4j.rollingfileappender log4j.appender.myappeder.file=${log}/mylog.log log4j.appender.myappeder.layout=org.apache.log4j.patternlayout log4j.appender.myappeder.layout.conversionpattern=%p %t %c - %m%n log4j.logger.com.mypackage=debug,myappeder

c++ - Carriage Return Multiple Lines -

i'm working on console based fps/clock display debugging allegro game i'm working on, , i've been trying figure out how console output change without having stick arbitrary system("cls") @ top of game loop. right have... while(game.running()) { std::cout << "\r" << "fps: " << getframerate() << "\n" << "\r" << "time: " << gettime(); // other game loop things... } what i'm going this, line rewritten each time. fps: ___ time: ___ (where ___ whatever current value is) but when run get... fps: ___ fps: ___ fps: ___ time: ___ ↑ goes on , on... fills screen fps:__ , single time:__ @ bottom without overwriting. '\r' has confounded me, , haven't found useful on google. appreciated. how using putchar(int) ? putchar(0x08) backspace or so. i'm not sure, problem cr(0x0d carriage return) , lf(0x0a line

sql - MySQL JOIN Complexity -

i using mysql 5.5 , have 2 tables t1(id, name) , t2(id, marks), following data in table. t1's data id name 1 2 b 3 c t2's data id marks 1 40 5 60 and want following resultset id name marks 1 40 2 b 0 3 c 0 what query can write accomplish above resultset? left join 2 tables: select t1.id, t1.name, ifnull(t2.marks, 0) marks t1 left join t2 on t1.id = t2.id; sql fiddle demo

unit testing - python, test not failing when inserting same row twice -

my postgresql table looks like table "public.categories" column | type | modifiers ------------+--------------------------+----------- uuid | uuid | not null name | character varying | not null parent | character varying | not null created_on | timestamp time zone | not null indexes: "categories_pkey" primary key, btree (uuid) "categories_name_parent_key" unique constraint, btree (name, parent) referenced by: table "transactions" constraint "transactions_category_id_fkey" foreign key (category_id) references categories(uuid) having unique(name, parent) . test is def setup(self): db.create_all() def session_commit(self): # noinspection pybroadexception try: db.session.commit() except: db.session.rollback() finally: pass def test_insert_sam

vb.net - Normal v Async calls to a service -

i have wcf service reference configured on client application. provides whole series of functions both retrieve , send data web based database. example: function errorcodesgetall(byval uname string, byval pword string) string and function errorcodesgetallasync(byval uname string, byval pword string) system.threading.tasks.task(of string) i know can populate rich text box first function using following code: richtextbox1.text = getcountrylist private function getcountrylist() string dim svc new servicereference2.ersapiserviceclient svc.open dim str string = svc.errorcodesgetall(username, password) svc.close() return str end function as wcf still new area me i'm wondering how populate same rich text box time using async variant of errorcodesgetall function? thanks advice or general pointers how async variants best used. your service expose "completed" event async method, need handle event. open service, wire event ,

Access a web-application using HTTPS over Mule 3 -

i have deployed mule web-application. use mule access webservices on https. have https implemented on mule, works fine. now, want integrate web-application instead of webservice , want use same https implemented on mule instead of implementing ssl again on weblogic server. when try url gets redirected outbound http url though inbound endpoint https.

Intellij context menu for Gradle -

just got gradle project intellij , when right click on project name, there , option gradle. when click trys run task libs , errors out. about? configurable? /bin/gradle-1.5/bin/gradle libs failure: not determine tasks execute. * went wrong: task 'libs' not found in root project 'bin'. * try: run gradle tasks list of available tasks. build failed total time: 1.773 secs process finished exit code 1 thoughts?

bash - read command doesn't wait for input -

i have problem executing simple script in bash. script this: #! /bin/sh read -p 'press [enter] continue deleting line' sudo sed -ie '$d' /home/hpccuser/.profile and when execute script ./script output this: press [enter] continue deleting line./script: 3: read: arg count [sudo] password user i run read command directly in terminal (copy , paste script terminal) , works fine; waits enter hit (just pause). because script starts #!/bin/sh rather #!/bin/bash , aren't guaranteed have bash extensions (such read -p ) available, , can rely on standards-compliant functionality. see the relevant standards document list of functionality guaranteed present in read . in case, you'd want 2 lines, 1 doing print, , other doing read: printf 'press [enter] continue deleting...' read _

xsd - How to validate DD MM YYYY date with XML Schema? -

i trying validate date format 23 december 2012 date format xml schema using type="xsd:date" cvc-datatype-valid.1.2.1: '23 december 2012' not valid value 'date'.. line '12', column '53'. element example: <datereleased>23 december 1966</datereleased> schema example: <xsd:element name="datereleased" type="xsd:date" /> is possible using type attribute ( xs:date )? or, need use xs:pattern instead? you cannot redefine format accepted xs:date in xsd. you use xs:pattern regex constraints close, won't able capture full date semantics (day ranges months, leap years, etc). if have control on date formats, go standard 1 supported xsd. if not, consider transforming xml via xslt, has more flexibility in defining date formats, ahead of validation.

php - Pass a variable from a get query in javascript -

i trying pass value of parameter outside $.get jquery in javascript. read should somehow in synchronous mode couldn't find solution. here code: var flag; var t = $.get("mutalyzer.php?id="+variation.value, function(data) { flag=data; }); document.write(flag); where undefined result. thanks! write inside callback function try this var t = $.get("mutalyzer.php?id="+variation.value, function(data) { //this callback function , runs when gets completed flag=data; document.write(flag); });

java - Search for a string in an unsorted binary tree -

i unsure need search string stored in binary tree. have search method written don't quite understand pass it. need search string before adding tree. if found, need increase counter within node object rather adding new one. tree unsorted way. my question how search before adding it? system.out.println("enter string stored"); stringvalue = k.nextline(); if (thestring.isempty() == true) { node.add(stringvalue, count); } else { // not sure here // how send string search method? stringvalue.treesearch(); } public node treesearch(string s, treenode root){ if(root.tostring().equals(s)){ return root; } if(left != null){ left.treesearch(s, root.left); if(root.tostring().equals(s)){ return root; } } if(right != null){ right.treesearch(s, root.right); if(root.tostring().equals(s)){ return root; } }else{ return null; } }

Datetime format change the number of returned rows in PostgreSQL -

i dont this... this first statement below returns expected rows - rows have date before/smaller than... select matchdate, price, size, issell matchmsg matchdate <= '2015-01-17 00:00:00.000000+01' order matchdate asc the code below return rows dates 2015-01-21...!? select matchdate, price, size, issell matchmsg matchdate <= 'sat jan 17 2015 00:00:00 gmt+0100' order matchdate asc ps: use postgressql, nodejs , npm moment...but result postgresql tool pgaminiii...so - has nothing own code...! matchdate in db "datetime time zone" like: "2015-01-16 00:00:22.491956+01" postgresql not understand dates of format sat jan 17 2015 00:00:00 gmt+0100 it's trying best. here tables of dates , time formats understand. a complete explanation can found here . you'll have convert sat jan 17 2015 00:00:00 gmt+0100 format postgres understands. close the http date format .

database - How to query android sqlite for specific category in table? -

i have database created sqlite in android , want able list contacts in specific group. database helper code this; public class databasehelper extends sqliteopenhelper { public static final string database_name = "contact.db"; public static final int database_version = 1; context context; public databasehelper(context context) { super(context, database_name, null, database_version); this.context = context; } @override public void oncreate(sqlitedatabase db) { db.execsql(table.contact.create_contact_details_tables); db.execsql(table.country.create_country_tables); db.execsql(table.state.create_state_tables); db.execsql(table.city.create_city_tables); db.execsql(table.category.create_category_tables); createdefaults(db); createcatgeorytype(db); } private void createdefaults(sqlitedatabase db) { string[] country = context.getresources().getstringarray(r.array.country_arrays); (string acountry : country) { contentvalues