Posts

Showing posts from September, 2010

python - Database connection setup broken after updating to Peewee 2.6 from 2.4 -

i want upgrade pewee v2.4.7 v2.6.3 in order use get_or_create method. however, after updating connection setup broken. i used following superclass enable foreign key contraints sqlite (2.6.3): class sqlitefkdatabase(sqlitedatabase): def initialize_connection(self): self.execute_sql('pragma foreign_keys=on;') return self ... using following connection setup code: db = sqlitefkdatabase(none) init_db(path_to_db) def init_db(path_to_db):

android - Prevent view overlapping in RelativeLayout -

Image
i'm trying accomplish simple layout task, i'm stuck view overlapping in relativelayout . screenshot: the title textview should centered (both vertically , horizontally). problem when title bit longer , covers button . the desired behaviour title textview aligns left button, or trims (e.g. singleline ). here xml: <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <relativelayout android:layout_width="match_parent" android:layout_height="50dp" android:background="#ffffff"> <linearlayout android:id="@+id/backbutton" android:layout_width="100dp" android:layout_height="match_parent" android:background="#cccccc">

java - Consider all possible class values for outputing the predictions on test split -

i new weka , running naive bayes classifier multiclass classification problem. class "game" can have multiple values soccer, rugby, cricket, baseball etc. has more 20 values. when run naivebayes class "game", select option of "output predictions" in order see actual class , missclassified class. one of output : inst# actual predicted error probability distribution 1 1:soccer 5:baseball + 0.1 0 0 0 *0.9 here misclassified class baseball probability of 0.9 , other class has probability of 0.1 soccer correct class. there way can consider class values has probability , if 1 of class values match actual class, should classify correctly. want top class values in row has probability values considered actual class value , if of class(even having lowest probability value) match actual class, correct class. so possible output : inst# actual predicted error

f# - Return multiple columns / a dataframe in Deedle based on row-wise mapping -

i want @ each row in frame , construct multiple columns new frame based on values in row. the final result should frame has columns of original frame plus new columns. i have solution wonder if there better one. think best way explain desired behavior example. i'm using deedle's titanic data set : #r @"f:\aolney\research_projects\braintrust\code\qualtricstor\packages\deedle.1.2.3\lib\net40\deedle.dll";; #r @"f:\aolney\research_projects\braintrust\code\qualtricstor\packages\fsharp.charting.0.90.12\lib\net40\fsharp.charting.dll";; #r @"f:\aolney\research_projects\braintrust\code\qualtricstor\packages\fsharp.data.2.2.2\lib\net40\fsharp.data.dll";; open system open fsharp.data open deedle open fsharp.charting;; #load @"f:\aolney\research_projects\braintrust\code\qualtricstor\packages\fsharp.charting.0.90.12\fsharp.charting.fsx";; #load @"f:\aolney\research_projects\braintrust\code\qualtricstor\packages\deedle.1.2.3\deedle.fsx&q

c# - service bus receive not returning immediately -

i'm using azure service bus topic/subscriptions , running unexplained performance receiving messages. according msdn: if 0 passed in serverwaittime, there no wait time. instead server bus fetch whatever messages available, or return null result. in code, stripped down bare essentials, pass in 0, receive takes 60 seconds complete. when completes, passed null object. why take 60 seconds when should return immediately? var client = servicebusclient.getorcreatesubscriptionclient(topicname, subscriptionname, false); var msg = client.receive(timespan.fromseconds(0));

c# - LINQ to Entities, Where Any In -

how write 'where in' in linq entity? here model : class chair { public int id { get; set; } public int tableid { get; set; } public table table { get; set; } } class table { public int id { get; set; } public icollection<chair> chairs { get; set; } public icollection<category> categories { get; set; } public table() { chairs = new list<chair>(); categories = new list<category>(); } } class category { public int id { get; set; } public icollection<table> tables { get; set; } } i got simple list of category : list<category> mycategories = new list<category>(c,d,e); i want chairs belongs table got 1 of category mycategories list. thats im trying : var result = ctx.chairs.where(x => x.table.categories.any(y => mycategories.any(z => z.id == y.id))).tolist(); i think ok error : "unable create constant value of type 'consoleapplication1.categ

Parsing JSON in swift 2.0 -

i'm trying parse json data server api. json : [ {"interest": { "title":"sport", "sub":[ "painting", "photography", "museum"] } }, {"interest": { "title": "music", "sub": [ "rock", "classic", "techno"] } }] the code file test parse : do{ let path = nsbundle.mainbundle().pathforresource("maininterest", oftype: "json") let jsondata = nsdata(contentsoffile: path!) let jsonresult:nsarray! = try nsjsonserialization.jsonobjectwithdata(jsondata! , options: nsjsonreadingoptions.mutablecontainers) as! nsarray } catch let error nserror { print(error) } i can access whole file : print(jsonresult) but can't access more 1 level, here first level : if let = jsonresult { print(a[0

Android Wear: Creating Lists trouble -

i new android , new android wear development. ultimately, goal dynamically create list of 10 items. each item have image , textview. trying implement example given here: https://developer.android.com/training/wearables/ui/lists.html . things have changed in example in res/layout/list_item.xml file: imageview has no src. instead, set background color hash value. change textview.textcolor hash value. everything compiles fine , able install app onto moto 360, via bluetooth. however, when open app on moto 360, error message appears "unfortunately, myapp has stopped." know if comment out line: listview.setadapter(new adapter(this, elements)); in wearactivity.oncreate method, error not appear, content of app blank. great! thank you. edit: logcat i/activitymanager( 1785): resuming delayed broadcast i/activitymanager( 1785): delay finish: com.google.android.gms/.wearable.init.initializegmswearablereceiver i/activitymanager( 1785): resuming delayed broadcast --------- b

javascript - Chromecast and Chrome Extension -

i'm trying wrap head around chromecast project. don't have android, or chrome extensions experience. looking through documentation seems need build chrome extension 'casts' images chromecast via javascript , html5. project concept send dynamic formats images , video tv screen desktop. is correct html5 pages have built , casted tv? is there other languages involved in process besides html5 , javascript? can use web server host html pages, or have use node.js i've been reading about? the receiver write run on chromecast html5 page css , javascript. data send receive, among other things, should have references urls of images , videos want show there; content can served type of web server; chromecast doesn't care if served via apache or node.js or own hand-crafted web server. better understanding of architecture, in general, might want consult our developer documentation .

mysql - User defined variables does not work on where clause -

set @a:=0 the below query works select *,@a:=@a+1 article @a<=3 this query returns 3 rows when query contains left join not work, returns rows. select a.*,@a:=@a+1 article left join comments c on c.aid=a.id @a<=3 i don't understand why query returns rows limit 3 clearer expression of (it looks like) trying do. said, have been known borderline abuse session variables, , tend balk @ seeing them in clauses; inadvisable cross clauses them. ....though work you: select a.*,@a:=@a+1 theavalue article left join comments c on c.aid=a.id having theavalue <=3 ; having processed after result fields have been calculated.

javascript - Store order value in collection in Meteor -

i want order collection. i need store field order storing incrementing numerical value. so docs have values 1,2,...,n. the problem different docs belong different projects (by projectid ) cannot have "normal auto-incrementing" field. how done? guess use like var lastdoc = mycollection.findone({ projectid: projectid }, { sort: { order: -1 } }); var nextorder = lastdoc ? lastdoc.order + 1 : 1; every time insert documents. correct? if delete 1 of docs between other docs?

javascript - Changing a font-family in an same-domain IFrame -

i have iframe referencing file on same domain, no issues. through javascript, can change font-size, color, everything. except font-family. weird. let me change properties, family, need! function changefont() { var x = document.getelementbyid("image"); var y = x.contentdocument; y.body.style.fontsize = "20px"; y.body.style.color = "red"; y.body.style.fontfamily = "algerian"; } <iframe onload="changefont()" id="image" width="100%" height="400" src="@url.content("~/content/temp.txt")"></iframe> to change font-family property have because of hyphen. function changefont() { var x = document.getelementbyid("image"); var y = x.contentdocument; y.body.style.fontsize = "20px"; y.body.style.color = "red"; y.body.style["font-family"] = "algerian"; }

An equivalent to the MATLAB function resample for C++ -

i need use resample in matlab , octave in c++, resample described below. "change sample rate of x factor of p/q. performed using polyphase algorithm. impulse response h of antialiasing filter either specified or either designed kaiser-windowed sinecard." is there equivalent approach in c++?? out of eigen or armadillo or that? thanks in advance motorola has library can polyphase resampling. gsl general mathematical c/c++ toolkit, though don't think want straight out of box.

c# - How to determine parents and children of each node in a directed cyclic graph? -

i'm working on problem related nested groups. need determine groups group member of , groups it's members. not immediate parents , children in hierarchy , down. what have done far traversing logic top-bottom ie, dfs using stack store not visited notes , hashset store visited notes. if there cycles in resulting graph wont go infinite recursion. static hashset<string> visited = new hashset<string>(); static stack<string> notvisited = new stack<string>(); static dictionary<string, hashset<string>> groupmembers = new dictionary<string, hashset<string>> { { "g4", new hashset<string> { "g5","g6","u1","u2"} }, { "g1", new hashset<string> { "g2","g3","g6"} }, { "g3", new hashset<string> { "g4"} }, { "g2", new hashset<string> { "g4","g

swift - Xcode linker command failed with exit code 1 -

i'm having annoying problem xcode. can't run projects , gives me same error every time: ld: file not found: /users/dagdigg/library/developer/xcode/deriveddata/roundy2-dtzcccrlvjvoxsapfbdzchhtuivr/build/intermediates/roundy2.build/debug-iphoneos/roundy2.build/objects-normal/arm64/appdelegate.o clang: error: linker command failed exit code 1 (use -v see invocation) i'm unable run every project. if create empty one... i'm using xcode 7 beta 3 , iphone ios 9 beta 4. sometimes it's helpful quit xcode , erase files in derivedata folder at ~/library/developer/xcode/deriveddata

How to select/copy current line without using mouse in IntelliJ IDEA -

to duplicate lines use ctrl + d is there similar way select/copy current line using keyboard in intellij idea? if have nothing selected, think can hit ctrl-c copy line (or ctrl-x cut it)... http://grahamhackingscala.blogspot.co.uk/2010/08/fast-quick-line-cut-copy-intellij-idea.html hope helps.

java - Create a service like thread in Android -

i creating google maps application in android. want after user closes app, want create service, beforehand, still runs in background , sends me current location of user. now when user exits 5m radius of particular location, want background thread stop. is possible? if yes, how can implement it. direction or web page tutorial or code snippet appreciated. to answer question possible. fusedlocationproviderapi . specifically, need method requestlocationupdates(). there several different method signatures allow pass in pendingintents (for background location requests) locationlistener (for foreground requests).

linux - Bash - variables are not evaluated inside other variables -

i've written short script needs find text using regex. i'm incrementing counter inside while loop, , counter part of command. unfortunately command running initial counter. here snippet code: counter=1 last_commit=`git log remotes/origin/devel --pretty=oneline --pretty=format:%s | head -${counter}` jira_id=`echo $last_commit | grep -o -p '[a-z]{2,}-\d+' | xargs` while [[ ! -z "$jira_id" && $counter -lt "5" ]]; echo "this current counter: $counter" echo "this last commit $last_commit" counter=$[counter+1] done echo "this counter outside loop $counter" the best-practices way encapsulate code (as per bashfaq #50 ) function: get_last_commit() { git log remotes/origin/devel --pretty=oneline --pretty=format:%s \ | sed -n "$(( $1 + 1)) p" } then: while (( counter < 5 )); last_commit=$(get_last_commit "$counter") ifs=$'\n' read -

Doing piecewise regression using a binary independent variable as breakpoint in R -

first time trying use 'segmented' package in r , have (probably stupid) questions. i implementing piecewise regression in r, trying this: y <- c(621, 552, 581, 549, 563, 633, 531, 348, 323, 285, 282, 303, 192, 281, 466, 969, 1549, 1264, 447, 367) x1 <- c(727, 689, 702, 646, 677, 798, 832, 377, 366, 351, 316, 333, 291, 526, 466, 1488, 1549, 1431, 696, 687) x2 <- c(10, 10, 10, 10, 8, 8, 8, 10, 10, 10, 10, 8, 8, 8, 8, 10, 10, 10, 10, 10) x3 <- rep(c(0,1),10) df <- data.frame(cbind(y,x1,x2,x3)) fit.lm <- lm(y~x1+x2, data=df) piecewise <- segmented(fit.lm, seg.z = ~x3, psi=0.5) i hope two-segment piecewise regression in can use variable x3, binary variable, break model 2 segments - 1 segment x3=0, , x3=1. with in mind, therefore used 0.5 estimated break-point. however, got error message this: error: @ least 1 coef na: breakpoint(s) @ boundary? (possibly many x-values replicated) two questions: given intended do, code make sense? what'

How to implement HTTP basic auth in Mule ESB http:request -

i'm using http request in mule esb , need implement http basic auth in it. using explicit authorization header: <http:request config-ref="http_request_configuration" path="/activiti-rest/service/runtime/process-instances" method="post" doc:name="request bpm"> <http:request-builder> <http:header headername="authorization" value="basic a2vybwl0onbhc3n3b3jkmq=="/> </http:request-builder> </http:request> is there direct way enter user , password basic auth in mule http:request ? there sure is: <http:request-config name="basicconfig" host="localhost" port="${httpport}"> <http:basic-authentication username="#[user]" password="#[password]" preemptive="#[preemptive]" /> </http:request-config>

javascript - Contact page Design how to add Bootstrap -

i have task in bootstrap site. have set contact page in bootstrap site. have created contact page in site. not showing responsive design.. i have developed code html , css. working well. how set design responsive design ? its css: body{ font-family:verdana, arial, helvetica, sans-serif; font-size:14px; } p, h1, form, button{border:0; margin:0; padding:0;} .spacer{clear:both; height:1px;} /* ----------- form ----------- */ @media screen , (max-width: 500px) { .myform { width: 200px; } } .myform{ margin:0 auto; width:566px; padding:14px; } /* ----------- form-wrapper ----------- */ #form-wrapper{ background: none repeat scroll 0 0 #c6c6c6; border: 2px solid #8b8b8b; border-radius: 10px;

Java.io.File - Cannot rename and move file on Android -

i can't rename/move temporary file , open it here code used create temporary file @override public void onsuccess(int statuscode, header[] headers, byte[] responsebody) { //[...] java.io.file tempfile = java.io.file.createtempfile("filetmp", "_handled", null); fileoutputstream fos = new fileoutputstream(tempfile); fos.write(responsebody); //responsebody (byte[]) not null fos.close(); //[...] } then, ( try to ) save on disk private void saveintodisk(java.io.file file) { if (persitencymanager.isexternalstoragewritable()) { java.io.file direvent = this.getparentevent().getdirectory(); log.d("root path", "" + direvent.getabsolutepath()); java.io.file mynewfile = new java.io.file(direvent.tostring() + "/"+identifiant+"_"+name); log.d("file path", "" + mynewfile.getabsolutepath()); path = mynewfile.getabsolutepat

cordova - Oauth 2.0 token based authentication AngularJS (Beginner) -

i have gone through multiple documents , including ng-cordova , oauth-ng still can't find resource deals basic token based authentication in angularjs/ionic i having trouble how make curl call in angularjs curl -x post -vu sampleapp:appkey http://sampleurl/oauth/token -h "accept: application/json" -d "password=pwd&username=sampleuname&grant_type=password&scope=read%20write&client_secret=appkey&client_id=sampleapp" i doing , it's giving me 401 error. however curl call works fine. $scope.login = function() { $http({ method: "post", url: "http://sampleurl/oauth/token", data: "client_id=" + clientid + "&client_secret=" + clientsecret + "password=pwd&username=sampleuser&grant_type=password" + "&scope=read%20write", withcredentials: true, headers: { '

python - Change specific value with dot in column -

i have following dataframe : example 189 900 1.8 349 233 the problem 1.8 should considered 1800. how can change whole column? : if cell in column contains value dot . value*1000 assuming data numeric, numeric values decimal part can caught i - np.floor(i) > 0 . import pandas pd import numpy np # data # ================================ df = pd.read_clipboard() df example 0 189.0 1 900.0 2 1.8 3 349.0 4 233.0 # processing # =============================== df.example = np.where(df.example - np.floor(df.example) > 0, df.example*1000, df.example) df example 0 189 1 900 2 1800 3 349 4 233

in R: Setting new Values in a data.table fast -

i trying set values data.table in efficient way. following code want, slow large datasets: dtcars<-as.data.table(mtcars) for(i in 1:(dim(dtcars)[1]-1)){ for(j in 1:dim(dtcars)[2]){ if(dtcars[i,j, with=f]>10){ set(dtcars, i=as.integer(i), j =as.integer(j) , value = dtcars[dim(dtcars)[1],j,with=f]) } } } and want this... totally wrong code, expresses need , think faster. meaning want subset data.table , insert same value particular column , repeat each column. dtcars<-as.data.table(mtcars) ns<-names(dtcars) for(j in 1:length(ns)){ dtcars[ns[j]>10]<-dtcars[20,ns[j]] } imo set should used sparingly, , regular := sufficient always: for (col in names(dtcars)) dtcars[get(col) > 10, (col) := get(col)[.n]]

Mechanize Python page download does not work with HTTPS -

Image
i'm on linux mint 13 xfce 32-bit, 3.2.0-7 python 2.7.3 . i'm trying read source code of webpage protected https. here's little program: #!/usr/bin/env python import mechanize browser = mechanize.browser() browser.set_handle_robots(false) browser.set_handle_equiv(false) browser.addheaders = [('user-agent', 'mozilla/5.0 (macintosh; intel mac os x 10_10_1) applewebkit/537.36 (khtml, gecko) chrome/39.0.2171.95 safari/537.36'), ('accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8'), ('accept-encoding', 'gzip, deflate, sdch'), ('accept-language', 'en-us,en;q=0.8,ru;q=0.6'), ('cache-control', 'max-age=0'), ('connection', 'keep-alive')] html = browser.open('ht

Box.COM integration with an android app-OAuthActivity-Nullpointerexception? -

i integrating box.com android application.so using boxandroidlibraryv2 , boxjavalibraryv2 application. run sample android application boxsdksample . copied necessary class , layouts sample application.now getting error message follows. 07-23 15:51:02.230: e/androidruntime(14857): process: com.filenet.ecm, pid: 14857 07-23 15:51:02.230: e/androidruntime(14857): java.lang.runtimeexception: unable start activity componentinfo{com.filenet.ecm/com.box.boxandroidlibv2.activities.oauthactivity} : java.lang.nullpointerexception: attempt invoke virtual method 'void com.box.boxandroidlibv2.views.oauthwebview.setallowshowingredirectpage(boolean)' on null object reference 07-23 15:51:02.230: e/androidruntime(14857): @ android.app.activitythread.performlaunchactivity(activitythread.java:2411) 07-23 15:51:02.230: e/androidruntime(14857): @ android.app.activitythread.handlelaunchactivity(activitythread.java:2474) 07-23 15:51:02.230: e/androidruntime(14857): @ android.app.activity

objective c - Undefined symbols "_OBJC_CLASS_$_" error -

my project written in applescriptobjc , objective-c. have nstabviewdelegate, must written in objc: #import <cocoa/cocoa.h> #import "msitems.h" @interface mstabview : nstabview<nstabviewdelegate> - (void)tabview:(nstabview *)tabview willselecttabviewitem:(nstabviewitem *)tabviewitem; @end @implementation mstabview - (void)tabview:(nstabview *)tabview willselecttabviewitem:(nstabviewitem *)tabviewitem { if ([[tabviewitem identifier] intvalue] == 1) { [msitems mymethod]; } } @end msitems class written in applescriptobjc, created header file, contains method need called other classes. #import <cocoa/cocoa.h> @class msitems; @interface msitems : nsobject + (void) mymethod; @end in asobjc class have: script msitems property parent : class "nsobject" on mymethod() --stuff end mymethod end script but app doesn't compile , error: undefined symbols architecture x86_64: "_objc_clas

r - How to fix 'no item called "package:pkg" on the search list' without using library(pkg)? -

i writing package named testpkg , have put quantmod in depends section of description file. i have written following functions: #' hello1 #' #' @return na #' @export hello1 <- function() { print("hello1!") quantmod::is.hlc("hello, world!") } #' hello2 #' #' @return na #' @export hello2 <- function () { x <- structure(c(25.85, 25.639999, 26.700001, 26.26, 26.92, 27.870001, 25.26, 25.52, 26.66, 25.610001, 26.85, 27.74, 26352700, 32512200, 64264600, 25.610001, 26.85, 27.74), .indexclass = "date", tclass = "date", .indextz = "utc", tzone = "utc", src = "yahoo", updated = structure(1437653990.9303, class = c("posixct", "posixt")), class = c("xts", "zoo"), inde

REST workitems in jBPM 6 lose query parameters sometimes when loaded in Workbench -

i find if put rest workitem process, , set url thus method=get url=http://localhost/mytesturl/#{globalvariablesegment}/something?query1=#{variable} that whilst line saved bpmn file works perfectly, variables being translated appropriate values, however, frequently, when load or save bpmn file (and can't work out it) url overwritten as: url=http://localhost/mytesturl/#{globalvariablesegment}/something?query1 there '=' upsetting assignments editor in workbench, , causing terminate string there. can spread light on this, or suggest workarounds? i've tried can think of, including setting global variables , trying "map" them. other assignment (ie. equals) seems cause restworkitem complain url required parameter. thanks! no 1 seems have answer this, right - searching, current workaround pre-urlencode query parameters section of string. seems work, , workbench hasn't lost or screwed of parameter strings since doing so.

Apache svn - which file states are ready to commit? -

apache svn - states of files ready commit, except a (scheduled addition) d (scheduled deletion) m (modified) ? i not find list of commitable states in doc . check status page: http://svnbook.red-bean.com/en/1.8/svn.ref.svn.c.status.html i think ready commit is: 'r' item has been replaced in working copy

javascript - I'm trying to force mouseup event after mousedown -

elements[0].onmousedown = function(){ console.log('screen clicked.'); simulatemouseuphere; }; all need add in function triggers mouseup, if user holding click button down. elements[0] entire page scope, anywhere click, trigger. i'm pretty sure can call onmouseup event... elements[0].onmousedown = function(){ console.log('screen clicked.'); elements[0].onmouseup(); }; keep in mind when physically stop holding mouse down though, mouseup event triggered again. (unless in onmouseup() event manage that) tested quickly, looks works: http://jsfiddle.net/cucwn/40/

ascii - Dynamic vs Direct Octal Character Representation in JavaScript -

if create 3 digit octal character string following way: x = "\\" + + b + c where a either 0 or 1, , b , c both number 0 7, why alert(x) result in \141 example, , not a alert("\141") ? second this, how original created character code result in respective ascii character? why alert(x) result in \141 example, , not alert("\141")? because inside string literal, \\ , \ different things. first creates actual backslash in string, whereas in second example, backslash introduces octal escape sequence. it's same reason \\n in string literal backslash followed letter n , \n newline. or more simply: because you're doing nothing tries re interpret you've created string literal. it's string, , nothing tries evaluate characters inside using string literal rules second time. how original created character code result in respective ascii character if i'm understanding question correctly, 2 ways: strip of

python - PyQt QTableView prohibitively slow when scrolling with large data sets -

i have program loads profile csv file , displays data in table. loading of pandas data frame table fast because used custom model implementation of qabstracttablemodel , resizing of qtableview widget incredibly slow. what can make resizing , scrolling smoother? well, ended modifying custom table model made use numpy, , blazing fast. use table model: import numpy np class pandasmodel(qtcore.qabstracttablemodel): """ class populate table view pandas dataframe """ def __init__(self, data, parent=none): qtcore.qabstracttablemodel.__init__(self, parent) self._data = np.array(data.values) self._cols = data.columns self.r, self.c = np.shape(self._data) def rowcount(self, parent=none): return self.r def columncount(self, parent=none): return self.c def data(self, index, role=qtcore.qt.displayrole): if index.isvalid(): if role == qtcore.qt.displayr

how to retrieve woocommerce product details based on their category_id using mysql -php -

i have retrieve product details such image title,description,image link , price woocommerce table. i've retrieved categories query, $result = mysql_query("select term_id,name,slug wp_terms term_id in (select term_id wp_term_taxonomy parent='0' , taxonomy='product_cat') order name asc"); based on category id i'm retrieving subcategories this: $result = mysql_query("select term_id,name,slug wp_terms term_id in (select term_id wp_term_taxonomy parent='$cat_id' , taxonomy='product_cat') order name asc"); i've tried query product details, $result = mysql_query("select `id`,`post_title`,`post_content`,`guid` wp_posts post_type='product' , post_status='publish' , id in(select object_id wp_term_relationships term_taxonomy_id in('$cat_id') , term_taxonomy_id in(select term_taxonomy_id wp_term_taxonomy taxonomy='product_cat'))"); this giving me tit

javascript - clone an object's element and push to it's self -

i have object a. if json.stringify(a) , result: { "ordera": [{ "orderid": "19", "serverid": 129, "description": "apple", "status": "1", "details": "" }] } now, clone it's own element , make larger object this: { "ordera": [{ "orderid": "19", "serverid": 129, "description": "apple", "status": "1", "details": "" }], "ordera": [{ "orderid": "19", "serverid": 129, "description": "apple", "status": "1", "details": "" }], "ordera": [{ "orderid": "19", "serverid": 129, &qu

forms - Constraint NotBlank/NotNull on Entity field Symfony2 -

i have user entity. every user can belong 1 domain. class user extends baseuser implements domainableinterface { … /** * @var domain * * @orm\manytoone(targetentity="domain", inversedby="users") * @orm\joincolumns({ * @orm\joincolumn(name="domain_id", referencedcolumnname="id") * }) */ private $domain; … } when create user, want domain mandatory. here form (it's super class because many other entities belong domain), user form inherits one abstract class hasdomainformtype extends abstracttype { private $user; public function __construct($securitycontext) { $this->user = $securitycontext->gettoken()->getuser(); } public function buildform(formbuilderinterface $builder, array $options) { $user = $this->user; $builder ->add('domain', 'entity', array( 'class' => &#

Validate email address for particular suffix using regex in Ruby-on-Rails -

this question has answer here: using regular expression validate email address 73 answers i want validate email address particular suffix should email. must have .edu or must have @mypost.com . example, have 4 email addresses shown below: 1) john@learn.edu - valid 2) john@mypost.com - valid 3) john@gmail.com - invalid 4) john@dblist.org - invalid i have tried solve problem using below code in user.rb model file no avail. if ('xc@dblist.com' =~ /\a[\w]([^@\s,;]+)@((mypost|[\w-]+\.)+(edu|com))\z/i) != nil return true else return false end you can use regex: \a\w([^@\s,;]+)@(mypost\.com|[\w-]+\.edu)\z see demo (i use ^ / $ demo in multilingual mode there) the (mypost\.com|[\w-]+\.edu) part matches .edu domain , mypost.com . note if not use captured groups, use \a\w[^@\s,;]+@(?:mypost\.com|[\w-]+\.edu)\z .

android - Communication between SlidingTabLayout tabs -

i've searched lot on how communicate between fragments using slidingtablayout haven't got answer. know using actionbar wanted new way android lollipop using slidingtablayout. tried this-> http://android-er.blogspot.in/2012/06/communication-between-fragments-in.html wanted material design. referred link http://www.android4devs.com/2015/01/how-to-make-material-design-sliding-tabs.html making material design sliding tabs. now wanted know how communicate between sliding tabs . i've tried lot couldn't find answer looking for. appreciated. the cleanest way define interface activity contains fragment s implement. how solved this: first define interface in it's own file, because has visible other classes. public interface fragmentcommunication { public void printmessage(string message); .... } in activity need implement interface public class mainactivity extends actionbaractivity implements fragmentcommunication { .... pub