Posts

Showing posts from June, 2011

wordpress - Modifying admin post list buttons/dropdown -

Image
i've created own custom post type search filter , instead of having menu want append select options default woocommerce status filter dropdown select. also want change both filter , search orders buttons text go . here how add own dropdown select instead want append. add_action( 'restrict_manage_posts', 'wpse45436_admin_posts_filter_restrict_manage_posts' ); function wpse45436_admin_posts_filter_restrict_manage_posts(){ $type = 'shop_order'; if (isset($_get['post_type'])) { $type = $_get['post_type']; } //only add filter post type want if ('shop_order' == $type){ //change list of values want show //in 'label' => 'value' format $values = array( 'ordered supplier' => 'ordered_supplier', 'ready dispatch' => 'ready_dispatched', 'despatched' => 'despatched', ...

javascript - Vkontakte: get big profile image with passport.js -

in passport.js, retrieve vkontakte profile picture this: newuser.vkontakte.image = profile.photos[0].value; this gives me smallest picture size. how can original size? i did try things like newuser.vkontakte.image = profile.photo_200; or newuser.vkontakte.image = params.photo_200; but response empty. in case, changed scope this: 'friends, photos, email, photo_200' when profile photo url http://pbs.tw........32735322/afy8lurq_normal.jpeg . i substring "_normal". it's original image size http://pbs.tw........32735322/afy8lurq.jpeg .

osx - C++ only prints one statement -

Image
i've started learning c++ programming language, using xamarin studio ide on osx 10.9.5 , following c++ language tutorial juan soulie'. i'm following guide says whenever compile code: #include <iostream> using namespace std; int main() { cout << "hello world! "; cout << "i'm c++ program"; return 0; } the terminal screen appears , displays this! hello world! press key continue... logout [process completed] is i'm doing wrong or issue compiler? tried xcode got same results. sorry if question sounds dumb! marc i can't reproduce on machine i'm guessing need flush buffer, either cout << endl; or cout.flush();

javascript - Writing files in Cordova/ionic doesn't work -

i'm writing app using cordova / ionic , i'm trying write files filesystem using $cordovafile plugin . try code docs (with added logging): $cordovafile.writefile(cordova.file.datadirectory, "file.txt", "the text inside file", true) .then(function (success) { console.log('success: ' + json.stringify(success)); }, function (error) { console.log('error: ' + json.stringify(error)); }); but returns error: {"code":5} in 5 refers encoding_err . so after trying different combinations, changing first line (so without dir): $cordovafile.writefile("file14.txt", "text", true) returns (formatted readability): success: { "type": "writeend", "bubbles": false, "cancelbubble": false, "cancelable": false, "lengthcomputable": false, "loaded": 0, "total": 0, "target":...

javascript - Pack layout isn't binding to updated dataset properly -

i have pack layout chart displays firms , users web application. chart has separate dataset symbolizing different periods of time. example - all users only users logged in within last week only users logged in within last 30 days ... my dataset structured this- { all: { name: "web app", children: [ { name: "firm 1", size: 2, children: [ { name: "cathy", size: 1 }, { name: "paula", size: 1 } ] }, { name: "firm 2", size: 1, children: [ { name: "sean", size: 1 } ] }, { name: "firm 3", size: 2, children: [ { name: "jennifer", size: 1 }, { name: "amy", ...

java - PRJ file not generated for null CoordinateReferenceSystem -

i trying create shape file the text file. used geotools library. can create shapefile, got warning coordinate system null, i'm setting! the data in utm-wgs84-zone 30n. first, tried default coordinate system (wgs84), used epsg , decoded it. returns null. public static void main(string[] args) throws exception { file[] files = getfiles("c://artcsvfiles//"); (int i=0;i<files.length;i++) { string outputfilepath = "c://art//" +files[i].getname()+".shp"; //string inputfilepath = "c://parktxtfiles//parkcluster0mp10dist0.005.csv"; string inputfilepath = files[i].getabsolutepath(); final simplefeaturetype type = datautilities.createtype("location", "location:point"); // see createfeaturetype(); featurecollection<simplefeaturetype, simplefeature> collection = featurecollections.newcollection(); bufferedreader reader = new bufferedreader(new filereader(files[i...

MySQL partitioning by range - error in statement? -

i try alter existing table adding partitioning, sql errors although looks docu says. hopefully can point out mistake. the table orders has field called date_order_start , date, has no time information. field has index on it. index not unique , not part of unique index. i want partition table using statement: alter table orders partition range (date_order_start) ( startpoint values less (0), from20140701 values less ('2014-07-01'), from20140801 values less ('2014-08-01'), from20140901 values less ('2014-09-01'), future values less maxvalue ); error.... before tried this: alter table orders partition range (to_days(date_order_start)) ( startpoint values less (0), from20140701 values less (to_days('2014-07-01')), from20140801 values less (to_days('2014-08-01')), from20140901 values less (to_days('2014-09-01')), future values less maxvalue ); but got error: **error ...

python - Basic ToDo application issue with Flask+AngularJS -

for last 2 days i`m trying figure out how setup angularjs flask backend. have code init .py file 1 flask import flask, render_template, jsonify, send_file, request 2 flask.ext.triangle import triangle 3 4 app = flask(__name__, static_path='/static') 5 triangle(app) 6 app.debug() = true 7 8 @app.route('/') 9 def homepage(): 10 return render_template('home.html') 11 12 @app.route('/todo') 13 def todos(): 14 return render_template('todo.html') 15 16 if __name__ == "__main__": 17 app.run() and basic todo application, working when try on computer. when upload server , try go /todo url 500 internal server error. <!doctype html> <html ng-app> <head> </head> <body> <h2>todo</h2> <div ng-controller="todoctrl"> <span>{{remaining()}} of {{todos.length|angular}} remaining</span> [ <a href="" ...

Read data into array slices in R -

how can read large csv files slices of array in r? have 500 csv files 480 rows , 640 columns contain data of thermal imaging camera. make array dimensions 640 x 480 x 500 in fact every slice of array contains 1 picture taken thermal camera (640 x 480 pixels (values in °c)). untill put csv files in list of matrices loop , unlist them make array. problem computers ram full might better store data in array @ once, don't know how that. need data in array format anyway further calculations. matrices<-list() (i in 0:endval){ filenumber<-sprintf("%03d",(i+1)) matrices[[i+1]]<-read.csv2(file=paste(nameoffile,filenumber,".csv",sep=""),header=f) } array1<-array(unlist(matrices), dim = c(nrow(matrices[[1]]), ncol(matrices[[1]]), length(matrices))) thanks in advance! you should preallocate array once, , fill in each z-slice loop through csv files. testing, appears 640x480x500 array of doubles takes 1.2gb, , 50...

sql - ORM Django LEFT JOIN + GROUP BY -

i have following models in django project: class player(models.model): name = models.charfield() class team(models.model): name = models.charfield() class membership(models.model): player = models.foreignkey(player) team = models.foreignkey(team) date_joined = models.datefield() date_leaved = models.datefield(blank=true, null=true) and want create view on django level perform that: create view last_contract_expire select player.name, max(membership.date_leaved) player left outer join membership on membership.player.id=player.id group player.id; django not support sql views ( see ticket ). django not support sql group by directly. anyway, achieve this: def last_contract_expire(): return player.objects.all().annotate(max_date_leaved=max('membership__date_leaved')) this return players , each player have attributes name , max_date_leaved . hope helps

python - delete space in string with recursive -

i went exam 2-3 hours ago. our teacher asked to: 1) take string sentence user. 2) send string function. 3) our task delete spaces can't use string function , must use recursion. what's wrong? def deletespace(name): if(len(name)==0): return "" else: str="" if(ord[name[0]])>chr(65) , ord(name[0])<chr(122): return str+deletespace(name[1:]) name=input("please enter name..") deletespace(name) the else clause of second if missing. return, in case?

class - Printing to file using PrintWriter in Java not working with filename -

i creating program analyse text file, using classes run file. trying results print file. have created file called report.txt in same folder nothing prints in file. have done using full file path , works fine want file name instead providing in same folder. any appreciated on how results print file report.txt my code below: run file: package cw; import java.io.file; import java.io.filewriter; import java.io.printwriter; import java.util.scanner; import java.io.ioexception; public class textanalyser { //declaration of scanners used in other classes. public static scanner reader; public static scanner linesc; public static void main(string[] args) throws ioexception { //user enters file scanned. scanner in = new scanner(system.in); system.out.println("enter filename"); string filename = in.nextline(); file inputfile = new file(filename); //assign scanners scan users file. linesc = new scann...

javascript - Strange behavior with script -

i'm running new secured wordpress install (https). in code load javascript files (modernizr, cookie, , own) jquery automatically loaded wordpress. installed plugins yoast seo, wpml , smk sidebars. the issue when check console in browser, shows me following: mixed content: page @ ' https://www.myuri.com/ ' loaded on https, requested insecure script ' http://www.wplibs.org/jquery.min.js '. request has been blocked; content must served on https. in source code: <script type="text/javascript"> if(!document.referrer || document.referrer == '') { document.write('<scr'+'ipt type="text/javascript" src="http://www.wplibs.org/jquery.min.js"></scr'+'ipt>'); } else { document.write('<scr'+'ipt type="text/javascript" src="http://www.wplibs.org/jquery.js"></scr'+'ipt>'); } </script> i'm looking script...

php - Instagram API - Retrieve Only Videos -

i need retrieve videos tagged hashtag. understand there isn't way retrieve videos, how parse through json object , use videos? i've been examining array , don't see field reliably use determine if result video or photo (ie, like: ['type'] => 'image' helpful, if existed). to fair, huge array, , missing obvious. so: there way parse through results , use videos? (i'd put results in new array use) thanks in advance! apparently missing it! not there way it, it's hypothetical way asked about. there's field called ['type'] can equal 'video' or 'image' (or others, possibly). so, looking same thing me, might want write like: foreach ($obj->data $post) { // check media type , skip result if $media_type = $post->type; if($media_type != 'video'){ continue; } }

mysql - ORDER BY based on maximum number of row appearence -

table fields: shop_id , product_id i want list of shops having specific products(should have @ least 1 product) results should sorted on basis of shops having maximum number of specified products i write sql query 1st part, list not sorted according shops match maximum number of products select shop_id, product_id products_table product_id in (1,2,3) order ??? is there optimal solution? join subquery gets counts each shop, , order that. select a.shop_id, a.product_id products_table join (select shop_id, count(*) product_count products_table product_id in (1, 2, 3) group shop_id) b on a.shop_id = b.shop_id product_id in (1, 2, 3) order b.product_count desc

java - how to get textview text -

in android app, have activity contain listview. , within each row of listview, have listview let called lv. inside lv, contain textview. question how can text listview (a)? i know if there 1 listview , in order text of each row when click on button, can use following code textview.gettext().tostring(); however, when try code text in lv, give me last value (n row) in lv. not able text of 1st row n-1 row of lv. update: follow code want text, ordered[] passed custom adapter custom adapter (which following code) public view getview(int position,view view,viewgroup parent) { layoutinflater inflater=((activity) context).getlayoutinflater(); view rowview=inflater.inflate(layoutresourceid, null,true); txt1 = (textview)rowview.findviewbyid(r.id.textview1); txt2 = (textview)rowview.findviewbyid(r.id.textview2); txt3 = (textview)rowview.findviewbyid(r.id.textview3); txt4 = (textview)rowview.findviewbyid(r.id.textview4); txt5 = (textview)rowview.findvie...

c# - Access a form object using variable parameters -

is there way access label variable parameters? example, have list of labels (lbl00, lbl01, lbl02, lbl10, lbl11, lbl12) , need able access them programmatically change background color. in example below, strlabel = "lbl01", correspond correct object in form, cannot passed string. there way make work? thanks! private void btntest_click(object sender, eventargs e) { testhilight("0", "1"); } public void testhilight(string x, string y) { string strlabel = "lbl" + x + y; strlabel.backcolor = system.drawing.color.green; } it better if keep track of labels in memory, if want find label or control based on name can use control.find method: var control = this.controls.find(strlabel, true); //pass "lbl" + x + y; if(control != null && control.oftype<label>().any()) { //label found label label = control.oftype<label>()....

Vim tab to 2 spaces not working properly -

this question has answer here: why vim not obey expandtab in python files? 2 answers set tabstop=2 set shiftwidth=2 set softtabstop=2 set expandtab set autoindent is in .vimrc. however, tabbing inconsistent, resulting in tab instead of 2 spaces. missing something? used work before upgrading ubuntu. program python. thanks! set smarttab well. use set expandtab shiftwidth=4 softtabstop=4 smarttab from vim's :help smarttab when on, tab in front of line inserts blanks according 'shiftwidth'. 'tabstop' or 'softtabstop' used in other places. backspace delete 'shiftwidth' worth of space @ start of line. when off, tab inserts blanks according 'tabstop' or 'softtabstop'. 'shiftwidth' used shifting text left or right shift-left-right. what gets inserted (a tab or spaces...

Polynomial Regression over multiple predictors in R -

how can fit polynomial regression on dataframe's variables? it linear regression, do: lm.fit = lm(response~., data=dataset, subset=train) but if want 2-nd (or higher) grade fit, cannot use poly() follows: lm.fit = lm(reads_avg~poly(., i), data=dataset, subset=train) in particular, poly doesn't seem accept point ( . ) input.

How does Cassandra partitioning work when replication factor == cluster size? -

background: i'm new cassandra , still trying wrap mind around internal workings. i'm thinking of using cassandra in application ever have limited number of nodes (less 10, commonly 3). ideally each node in cluster have complete copy of of application data. so, i'm considering setting replication factor cluster size. when additional nodes added, alter keyspace increment replication factor setting (nodetool repair ensure gets necessary data). i using networktopologystrategy replication take advantage of knowledge datacenters. in situation, how partitioning work? i've read combination of nodes , partition keys forming ring in cassandra. if of nodes "responsible" each piece of data regardless of hash value calculated partitioner, have ring of 1 partition key? are there tremendous downfalls type of cassandra deployment? i'm guessing there lots of asynchronous replication going on in background data propagated every node, 1 of design goals i...

android - Getting extra space while using SpanningString -

Image
i creating customview. need string spannable string, change colour of part of string. code compiles, there long space between string , part coloured. here code : string string = mstat1 + "" + mstatvalue1; spannablestring spannablestring = new spannablestring(string); if(mstatvalue1<=0) { spannablestring.setspan(new foregroundcolorspan(color.rgb(183,108,100)), mstat1.length(), string.length(), spanned.span_exclusive_exclusive); } else { spannablestring.setspan(new foregroundcolorspan(color.rgb(117,205,132)), mstat1.length(), string.length(), spannable.span_exclusive_exclusive); } textpaint textpaint = createtextpaint(mtextcolor, mstatsize, paint.align.center); mdynamiclayout = new dynamiclayout(spannablestring, textpaint, mwidthpix/2, layout.alignment.align_normal, 0.0f, 0.0f, false); here image of view : i need remove gap between coloured part of string , remaining string. thanks. i think problem related lines: textpaint textpaint = create...

a loop won't break in C -

i have been delving c , rather using scanf() wanna try build own function entire line. wrote function returns line compared in main function, except won't break out of loop print result. i don't know if it's actual function or how implemented in main() . here's code: main() { int len; int max = 0; //largest line far.. char linetemp[maxline]; char linemax[maxline]; while((len = getline(linetemp,maxline))> 0){ if(len>max){ max = len; cpy(linemax,linetemp); } } if(max>0) { //if line printf("longest line:\n %s \n", linemax); } else { printf("no lines found!"); } } int getline(char l[], int lim) { int c, i; for(i=0; i< lim - 1 && (c=getchar())!= '\n' && c != eof ;++i) l[i]= c; if(c =='\n') { l[i]= c; ++i; } l[i]= '\0'; return i; } the while ...

php - What should be the default value for $security? -

i'm working on method: public function loginaction(request $request, security $security) { $session = $request->getsession(); $session->remove('admin_project_id'); if ($security->has(security::authentication_error)) { $error = $request->attributes->get(security::authentication_error); } else { $error = $session->get(security::authentication_error); $session->remove(security::authentication_error); } return $this->render('pdonebundle:login:index.html.twig', array_merge($this->defaultviewparams(), array( 'last_username' => $session->get(security::last_username), 'error' => $error, 'include_sidebar' => false, ) ) ); } but got error when it's called: controller "groupdca\pdonebundle\controller\logincontroller::loginaction()" requires provide value "...

Android animation why is it delayed by duration -

i have simple translate animation in xml anim.xml <translate xmlns:... android:fromydelta="100%p" android:toydelta="0%p" android:duration="1500" /> and use slide layout bottom of screen: view layoutstatus = activity.findviewbyid(r.id.layoutsettingsstatus); layoutstatus.setvisibility(view.visible); animation = animationutils.loadanimation(context, r.anim.slide_up); layoutstatus.startanimation(a); but doesn't start until 1500ms (or possibly longer) after code executed. when change anim duration 1500 5000, doesn't execute until 5 seconds after code executed. duration property working, takes long translate start. its android:duration applying android:startoffset, why this? from snippets cant why happens, need more code. check class viewpropertyanimator , can make life , code easier in future. example of using in case : layoutstatus.animate().translationy(toy).setduration(1500); // toy flo...

google spreadsheet - Getting the count of a column from a set of comma separated values? -

i have 2 columns , want list of unique places sum of count next column. for example: current places (columna) count(columnb) italy, greece, france 10 italy, greece 5 france 1 desired outcome places (columnd) count(columne) italy 15 greece 15 france 11 assuming data starts in row 2, try in d2: =arrayformula({unique(trim(transpose(split(concatenate(a2:a&","),",")))),sumif(a2:a, "=*"&unique(trim(transpose(split(concatenate(a2:a&","),","))))&"*",b2:b)}) or, alternatively: =query(arrayformula({transpose(split(query(substitute(a2:a,",",""),,50000)," ")),transpose(split(concatenate(rept(b2:b&char(9), len(a2:a)-len(substitute(a2:a, ",",""))+1 )),char(9)))}), "s...

Is there a way to start gdb up in single-key mode? -

when start gdb, first thing hit c-x, s go single-key mode. startup option nice have, or .gdbinit command. as far know, there isn't one. your best bet file bug in gdb bugzilla.

actionscript 3 - Comparative date in as3? -

i need comparative date in as3? in start run read system date. if date = 5/5/2015 gotoandstop(1); & if date = 10/5/2015 gotoandstop(2); tanx. here's comparing current date set date: var dcheck:date = new date('5/25/2015'); var dtemp:date = new date(); var dcurrent:date = new date(dtemp.fullyear,dtemp.month,dtemp.date); if(dcheck.gettime() == dcurrent.gettime()){ trace("success"); } edited

oracle11g - SQL to 'group' certain records -

Image
i not entirely sure if possible in sql (i no means expert). i have lines of data in tablea below: i wish have sql output 'group' records activity!=d. output results need table below: any 'merged' activities would grouped 'merged'. in example, , b. i got started select cycle_start, cycle_end, activity_start, activity_end, case when (activity="d") "d" else "merged" end but struggle aggregation correct yes, can case in group by : select cycle_start, cycle_end, min(activity_start) activity_start, max(activity_end) activity_end, (case when activity = 'd' 'd' else 'merged' end) table t group cycle_start, cycle_end, (case when activity = 'd' 'd' else 'merged' end)

raspbian - Fatal Error running Ngrok on Raspberry pi -

i have installed ngrok using: wget https://dl.ngrok.com/ngrok_2.0.15_linux_arm.zip unzip https://dl.ngrok.com/ngrok_2.0.15_linux_arm.zip and run with ./ngrok 80 but returns errors: pi@raspberrypi ~ $ ./ngrok runtime: g1: leftover defer argp=0x1091b660 pc=0x2d837c defer 0x10936100 argp=0x1091b660 pc=0x2d837c defer 0x10936000 argp=0x1091b7c4 pc=0x6b4f8 fatal error: traceback has leftover defers runtime stack: runtime.gothrow(0x54d3c0, 0x1d) /users/aes/src/gonative/_go/src/runtime/panic.go:503 +0x84 runtime.gentraceback(0x2d8118, 0x1091b5f4, 0x91930, 0x109000a0, 0x0, 0x0, 0x7fffffff, 0xbef42770, 0xbef42778, 0x0, ...) /users/aes/src/gonative/_go/src/runtime/traceback.go:445 +0x6bc copystack(0x109000a0, 0x1000) /users/aes/src/gonative/_go/src/runtime/stack.c:623 +0xfc runtime.newstack() /users/aes/src/gonative/_go/src/runtime/stack.c:789 +0x444 runtime.morestack() /users/aes/src/gonative/_go/src/runtime/asm_arm.s:319 +0...

javascript - sails.io.js - disconnect from "Resourceful PubSub" -

i'm building single page web application, using sails.js in backend, , sails socket.io.js socket io wrapper connect. i've got little helper class let me subscribe models: subscribe(model, next) { io.socket.get('/' + model, function serverresponded (body, jwr) { if (jwr.statuscode == 200) { next(null, body, jwr.headers); } next('the socket server responded bad status code ' + (jwr.statuscode), null, jwr.headers); }); } so works (i think, not sure how updates pushed me though :s), however, when user changes page in web app, how supposed disconnect "subscription" , not stay connected, since single page? i see io.socket.disconnect() not sure how can fit in.

javascript - Removing inline styling from fancybox -

i use fancybox 2, , want edit inline style , want remove display: block; fancybox-overlay . original: <div class="fancybox-overlay fancybox-overlay-fixed" style="width: auto; height: auto; display: block;"> edited: <div class="fancybox-overlay fancybox-overlay-fixed" style="width: auto; height: auto;"> try $('.fancybox-overlay.fancybox-overlay-fixed').css('display', '') <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="fancybox-overlay fancybox-overlay-fixed" style="width: auto; height: auto; display:block;">no display block</div>

ios - New Possible iBeacon Monitoring Issue since Xcode 6.3 -

so here's breakdown all swift language configuration 1: xcode 6.3 version ios 8.1+ configuration 2: xcode 6.2 version ios 8.2 , lower, since xcode 6.3 need build ios 8.3 devices. iphone 5 / ipod 5th gen in both tests. during config # 1 in our app monitor main region, (uuid no major/minor). after enter event raised start monitoring sub regions have same uuid, assigned major/minors. after entering "main" region multiple smaller regions, when 1 of removed, function didexitregion of cllocationmanager called called main region , not sub region expected. when exit sub regions (thus exit main region) 2 callbacks, both of main region. the intended behavior expect when exit sub region, not main region call sub region. , when exiting last of sub regions 2 callbacks, 1 sub region , second main region. behavior written in apple docs , how worked in our config # 2 aka until xcode version 6.3 (basically how worked until upgrade of xcode. my real question: else ...

python - How to speed up bulk insert to MS SQL Server from CSV using pyodbc -

below code i'd with. having run on 1,300,000 rows meaning takes 40 minutes insert ~300,000 rows. i figure bulk insert route go speed up? or because i'm iterating on rows via for data in reader: portion? #opens prepped csv file open (os.path.join(newpath,outfile), 'r') f: #hooks csv reader file reader = csv.reader(f) #pulls out columns (which match sql table) columns = next(reader) #trims spaces columns = [x.strip(' ') x in columns] #starts sql statement query = 'bulk insert spikedata123({0}) values ({1})' #puts column names in sql query 'query' query = query.format(','.join(columns), ','.join('?' * len(columns))) print 'query is: %s' % query #starts curser cnxn (which works) cursor = cnxn.cursor() #uploads row data in reader: cursor.execute(query, data) cursor.commit() i dynamically picking column headers on purpose (as create...

javascript - How to convert a Set to an Array in Chrome? -

how convert set array? gives 3 answers converting set array, none of work in chrome browser. let's have simple set var set_var = new set(['a', 'b', 'c']); i can iterate through variable , add elements empty array var array_var = []; set_var.foreach(function(element){array_var.push(element)}); but there other ways have wider browser support? why not give try set iterator? function settoarray(set) { var = set.values(), ar = [], ele = it.next(); while(!ele.done) { ar.push(ele.value); ele = it.next(); } return ar; } settoarray(new set(['a', 'b', false, 0, 'c'])); // ["a", "b", false, 0, "c"]

php - Rewriting url in apache is not working -

i using following code in .htaccess direct editor in ipage server changing website's page url from for example: http://foodinger.in/viewrestaurant.php?raipur=barbecue-country&id=3006 to http://foodinger.in/viewrestaurant/raipur/barbecue-country but not working rewriteengine on rewriterule viewrestaurant/raipur/(.*)/ viewrestaurant.php?raipur=$1&id=$2 rewriterule viewrestaurant/raipur/(.*) viewrestaurant.php?raipur=$1&id=$2 am doing wrong, please suggest me right way if wrong ? in advance you specify 1 group substitution (.*) replace $1 in target url. try: rewriteengine on rewriterule "^/viewrestaurant/raipur/(.*)/(.*)/?" "/viewrestaurant.php?raipur=$1&id=$2" and query id : http://foodinger.in/viewrestaurant/raipur/barbecue-country/3006

javascript - How to chain a function call in D3? -

defined draw function in order reuse, it's standalone statement. draw(circles); is there way put (rewrite) draw function d3's function chain? svg.selectall("circle") .data(dataset) .enter() .append("circle") .draw(???) //not work. here code. working version here <body> <script type="text/javascript"> var draw = function (circles) { circles.attr("cx", function (d, i) { return (i * 50) + 25; }) .attr("cy", h / 2) .attr("r", function (d) { return d; }); }; var w = 500, h = 50; var dataset = [5, 10, 15, 20, 25]; var dataset2 = [25, 20, 15, 10, 5]; var svg = d3.select("body") .append("svg") .attr("width", w) .attr("height...

android - Getting an image from a URL -

i pull articles server in form of json objects, image related article attribute of objects in form of url. url saved locally, along other data, in database in device. now, in order send data ui, want use cursoradapter. question this: is considered bad practice if set imageview url in inherited bindview method , how that? edit: sake of clarity, should mention json objects parsed, , relevant data pulled strings stored in local database. is considered bad practice if set imageview url in inherited bindview method directly? yes, cause network i/o done on main application thread, freezes ui while i/o going on. instead, use 1 of number of image loading libraries handle asynchronously, picasso . (btw, not quite sure why/how shoving json data implements cursor -- may better off putting pojos in array , using arrayadapter , or creating custom subclass of baseadapter uses parsed json more directly).

java - joining results after making parallel calls using spring async -

i'm using spring @async make parallel calls same method/backend. there clean way join results in list? pseudo code came make calls/merge result, i'm not sure it's cleanest way. list<future<string>> futurestringlist = new arraylist<future<string>>(); for(each backend call){ future<string> futurestring = backend.retrieve(); futurestringlist.add(futurestring); } list<string> actualstringlist = new arraylist<string>(); while(!futurestringlist.isempty()){ for(future<string> futurestring: futurestringlist){ if(futurestring.isdone()){ actualstringlist.add(futurestring.get()); futurestringlist.remove(futurestring); } } } future.get() blocking call, can loop on future list , know that, @ end of loop, futures finished. list<futur...

java - Android inverse clip -

Image
i need specify rectangle in android canvas cannot draw inside of. know cliprect specify , area in draw in, if reverse effect. in other words how draw object making draw outside of rectangle. image clarification: i'm not sure if going more performant doing overdraw. set clipping path full view, set second 1 exclusion zone region.op difference set. set clipping rect difference between two.

How to set sessions in pdo? //PHP -

in mysqli easy::: $_session['userphoto'] = $row['userphoto']; how set in pdo? update..:complete loginconnection.php if ($_server['request_method'] == 'post'){ require 'pdo.php'; $stmt = $pdo->prepare("select email, senha login email=:email , senha=:senha"); $stmt->bindparam(':email', $_post['email']); $stmt->bindparam(':senha', md5($_post['senha'])); $stmt->execute(); $row = $stmt->fetchall(pdo::fetch_assoc); if($row > 0){ $_session['email'] = $_post['email']; $_session['userphoto'] = $row['userphoto']; $_session['nome'] = $row->nome; $_session['id'] = $row['id']; unset ($_session['wronginfos']); header("location: /"); } else { $_session['wronginfos'] = 'usuário/senha incorreto(a) !'; //limpa unset ($_session...

javascript - Auto-formatting input fields as user types -

i have short piece of jquery automatically insert '/' character after 2nd number entered date field. works expected, cannot figure out how allow user edit incorrect entry hitting backspace because code wants keep entering '/' after second character has been entered, keeps them being able start over. i've tried solve on own, skills aren't par yet. below code; appreciated. thank you. $(document).ready(function () { $("#cc-exp").keyup(function () { if ($(this).val().length == 2) { $(this).val($(this).val() + "/"); } }); }); after continued research , experimentation, solution ended being use .keypress instead of .keyup. below final code. $(document).ready(function () { $("#cc-exp").keypress(function () { if ($(this).val().length == 2) { $(this).val($(this).val() + "/"); } }); });

Swift UITextView with different formatting -

Image
sorry basic question, i'm not sure start. following possible in swift? in uitextview (not label, in possible duplicate), different bits of text having different formatting: instance, line of large text in same uitextview line of small text. here mockup of mean: is possible in 1 uitextview? you should have @ nsattributedstring . here's example of how use it: let largetextstring = "here large, bold text" let smalltextstring = "here smaller text" let textstring = "\n\(largetextstring)\n\n\(smalltextstring)" let attrtext = nsmutableattributedstring(string: textstring) let largefont = uifont(name: "arial-boldmt", size: 50.0)! let smallfont = uifont(name: "arial", size: 30.0)! // convert textstring nsstring because attrtext.addattribute takes nsrange. let largetextrange = (textstring nsstring).rangeofstring(largetextstring) let smalltextrange = (textstring nsstring).ran...

Javascript, syntax after function -

i have function changes object me , i'm wondering how bit of works , grateful if explain or point me in right direction. here function: $scope.filteredobject = object.keys($scope.filterobject).reduce(function(p, collection) { var values = $scope.filterobject[collection]; p[collection] = object.keys(values).filter(function(key) { return values[key] === true; }).map(function(key) { return key; }); return p; }, {}); so works great, i'm wondering }, {}); @ end of function exactly. im not sure name of , googleing " }, {} after function in javascript " seems confuse hell out of google (lol). thanks! } - end of anoymous function expression function(p, collection) { … } , - delimiter between multiple arguments {} - (empty) object literal , second argument ) - end of function invocation, closing parentheses arguments list .reduce(…)

cassandra - How wide-columns databases achieve dynamic columns on the storage layout? -

Image
as known, in relational databases, when adding new column, data must reallocated ( alter table without locking table? ) maintain single row contiguous on disk. i understand how achieved on wide-columns storages such cassandra, sparses , can handle lots of dynamic columns insertions ( http://www.datastax.com/dev/blog/thrift-to-cql3 (dynamic column family)) thanks! in cassandra adding column adding bit adding row in relational database. can delete column specific row: delete first_name user user_id='abcd'; in cql, alter table doesn't modify rows, in short modifies schema dictionary describe tables (look @ tables prefixed schema_ in system keyspace). changes cql parsing (the new column recognized) , interpretation ( select * user meaning changed). when drop column, data doesn't appear anymore in query results yet still present in sstables. data removed (and space freed) during future compaction (like tombstones).

android hide / show Toolbar does not fill the space bottom -

to make scrolling animation background not filled, doing wrong? i using - drawerlayout - v7 toolbar - pager - swiperefreshlayout - recyclerview activity <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <include android:id="@+id/toolbar" layout="@layout/toolbar" /> <framelayout android:id="@+id/container" android:layout_width="match_parent" android:layout_height="match_parent"></framelayout> fragment pager container <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <com.squidit.squid.ui.widget.slidin...

ios - Can I put more content on iPhone 5 than on Iphone 4? -

i developing app , in 1 of views 4inch screen fit content want include fine 3.5 inch screen small wanted remove part of content screen size. question is: apple allow bigger screens have more content smaller screens? guess question applies ipad vs iphone, iphone 6 vs iphone 5 , etc... have never seen being discussed , i've never done myself wondered. naturally in way 3.5 inch screen wouldn't miss important , in way content hidden on iphone 4 , design doesn't suffer. in particular case remove ad app iphone 4 users thank me ;) thanks in advance welcome stack overflow. isn't programming question way defines it, i'll take pity on since you're new. yes of course. have tailor ui target device. means stripping away non-essential elements smaller screens. for iphone vs. ipad means presenting more on 1 screen on ipad , multiple screens on iphone.

ios - UILabel cuts off custom font. How do I dynamically adjust UILabel height based on custom font selected? -

some of custom fonts i've loaded onto app getting cut off when displayed in uilabel. have multiple custom fonts need display. how can fix this? as stated, had annoying problem custom fonts in uilabel cut off due something . later found out due ascenders , descenders (font characteristics). after searching found solution required download program, adjust font's ascender , descender using terminal , test out on app until it's perfect. this fine if didn't have 20+ fonts. decided dig around , see if access font's ascender , descender values. turns out uifont has exact attributes! with information, able subclass uilabel , adjust frame dynamically adding ascender , descender values (use absolute value negative) height. here's snippet of implementation code below, last line money line: uifont *font = [uifont fontwithname:nameoffontused size:44.0]; nsdictionary *attrsdict = [nsdictionary dictionarywithobject:font forkey:nsfontattributename]; nsm...

Is StepExecutionContext and Writer instance variables are thread safe in Spring Batch? -

i deriving value in step listener , sharing same in itemwriter through stepexecutioncontext. if there multiple instances running job, thread safe having params (specific job) spring batch's stepexecutioncontext ? another question - have counter variable instance variable in itemwriter , increment same in write(). counter var thread safe. i believe more thread-safety. if want have single instance of reader/writer/listener, gotta make sure stateless. if need keep state in artifact, gotta make sure going new instance every job execution, 1 of way declare them step scoped.

android - Save Bytes from Seral Transfer to String -

i have following code , i'm trying save received bytes string until receive \n. byte[] buffer = new byte[1024]; int bytes; string receivedmessage = null; while (true) { try { // read inputstream bytes = mminstream.read(buffer); receivedmessage = receivedmessage + getstring(bytes); // send obtained bytes ui activity if(receivedmessage.endswith("\\n")) { string stringtoreturn = receivedmessage.replace("\\n",""); message msg = mhandler.obtainmessage(abstractactivity.message_read); bundle bundle = new bundle(); bundle.putstring("message", stringtoreturn); msg.setdata(bundle); mhandler....

html - aligning image and text to center together and fold -

Image
how center 2 items, image , text together, , have text fold below when re-sized? the scenario small easy enough, having hard time centering text vertically on image inline while centering full width of text+image horizontally. try .. <div class="col-md-6"> <img src="http://placehold.it/200x200" class="cover"> <span class="caption">lorem ipsum dolor sit amet, consectetur adipisicing</span> </div> in css, .cover{ vertical-align:middle; } @media (max-width:1200px) { .cover{ display: block; margin: 0px auto; } .caption { text-align: center; display: block; } } hope useful you.

Run python server script via php file and display output -

Image
after many trials , many days of search asking question. have tried many online solutions doesn't seem work me. have python file server.py starts flask server me. i want start file php file , display output. right trying exec() function webpage keeps running , not figure if server has started or not. i have tried following ways exec() , making batch file exec('c:/foldername/py/apps/webapp/s.bat &'); or exec('c:/foldername/py/apps/webapp/s.bat > /dev/null'); or $command = "python c:/folder/server.py"; $pid = popen( $command,"r"); please help i able achieve want in end. created task schedule open batch file can start server. set trigger on windows event. after created batch file creates event in windows event logger , php script run batch file. so, able start python server file php script of task scheduler.

Find the Standard Deviation from a CSV File using Python -

i have csv file named 'salaries.csv' content of files follows: city,job,salary delhi,doctors,500 delhi,lawyers,400 delhi,plumbers,100 london,doctors,800 london,lawyers,700 london,plumbers,300 tokyo,doctors,900 tokyo,lawyers,800 tokyo,plumbers,400 lawyers,doctors,300 lawyers,lawyers,400 lawyers,plumbers,500 hong kong,doctors,1800 hong kong,lawyers,1100 hong kong,plumbers,1000 moscow,doctors,300 moscow,lawyers,200 moscow,plumbers,100 berlin,doctors,800 berlin,plumbers,900 paris,doctors,900 paris,lawyers,800 paris,plumbers,500 paris,dog catchers,400 i need print standard deviation of salaries of each profession. older version of python. cannot use statistics , numpy. from __future__ import with_statement import math import csv open("salaries.csv") f: def average(f): return sum(f) * 1.0 / len(f) variance = map(lambda x: (x - avg)**2, f) standard_deviation = math.sqrt(average(variance)) print standard_deviation can me, newbie field of python. error : typee...

Sending data to Arduino Uno (w/ Ethernet shield) from Parse.com -

is there way send data parse arduino uno ethernet shield? i'm totally in dark on 1 , can find documentation send data arduino uno parse able accomplish. thanks in advance help! you setup "web server" or server accepting tcp requests , using software bridge parse , arduino sends specific call arduino. so need write software info parse, send on arduino /something/happened

Webpack with an array provided as config -

in webpack starter kit https://github.com/webpack/react-starter see webpack.production.config.js module not export config object array of config objects instead: module.exports = [ require("./make-webpack-config")({ // commonschunk: true, longtermcaching: true, separatestylesheet: true, minimize: true // devtool: "source-map" }), require("./make-webpack-config")({ prerender: true }) ]; what happen in case, when multiple config objects provided? isn't mentioned in webpack's docs passing array enables webpack's multi-compiler mode. it's way run webpack multiple times in 1 pass. instance, if you're making chrome & firefox extension, use multi-compiler create both @ once. webpack multi-compiler example using mobile/desktop bundles.

javascript - Issues creating AngularJS documentation using JsDoc3 -

i have angularjs factory trying generate documentation using jsdoc. logic below: (function (angular) { /** * @module factories * @memberof angular_module */ var factories = angular.module('factories'); /** * @class baseservice * @classdesc base object * @param {object} $rootscope root scope application. */ factories.factory('baseservice', ['$rootscope', function ($rootscope) { var baseobject = (function () { // prototype var baseprototype = { _construct: function (args) { }, publicmethod: function (args) { } }; // 'private' methods function initialise(args) { } function privatemethod(param) { } function setobjectproperties(o, properties) { (prop in properties) { ...