Posts

Showing posts from August, 2012

jekyll - Does Liquid have a does not contain or not in array operator? -

when calling items , array in liquid template, how call does not contain or not in array ? unless rescue ! create [a, b, c] array. {% assign input = "a,b,c" | split:"," %} unless print if constrain not met. this prints nothing: {% unless input contains 'a' %}no a{% endunless %} this prints " no z ": {% unless input contains 'z' %}no z{% endunless %}

ios - Objective-C: conditionally call different properties -

say there's class contains 2 different properties such as: @interface myclass : nsobject @property id valuewhenno; @property id valuewhenyes; @end while using class boolean value called 'state', know can property according 'state' by: myclass *myclass; id value = state ? myclass.valuewhenyes : myclass.valuewhenno; but found using lot of conditional statement in complex code can make readability of hard. since intend give no information 'state' 'myclass', there cannot additional boolean property in 'myclass'. is there way in objective-c class can used property conditionally short line of code such following? id value = myclass.valuebystate; have 2 instances of class 1 property instead of 1 instance 2 properties. then, when state changes switch instance instead of having code everywhere check state.

c++ - Alternative to casting return pointer of base class protected method? -

i came class uses protected nested struct, intending derived classes augment struct. end, declared virtual method allocating struct. now, base class not-trivial amount of work in processsomedata , derived class reuse it. which leads following: class { public: virtual void doprocessing(); // uses processsomedata() protected: struct somedata { virtual ~somedata() {}; // data members }; virtual somedata* processsomedata(); // uses allocatesomedata() virtual somedata* allocatesomedata(); }; class b : public { public: virtual void doprocessing() { deriveddata* mydata = static_cast<deriveddata*>(a::processsomedata()); // *** seems little suspect // work on additional data members in mydata } protected: struct deriveddata : public somedata { // more data members }; virtual deriveddata* allocatesomedata(); }; because allocatesomedata overridden, know a::processso...

android - HOW TO USE SHARED PREFERENCES IN FRAGMENT ACTIVITY -

i'm facing problem while use code in fragment , did few changes of help..but still have few errors.. this code want transfer in fragment activity normal activity.. public class mainactivity extends activity { final static string shared_name_string="sharedp"; final static string user_name_string="user"; button button; edittext edittext; sharedpreferences sharedpreferences; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); edittext=(edittext) findviewbyid(r.id.usernameedittext); button=(button) findviewbyid(r.id.enterbutton); log.d("dictionary", "main activity started"); sharedpreferences=getsharedpreferences(shared_name_string, mode_private); string usernamestring=sharedpreferences.getstring(user_name_string, ""); edittext.settext(usernamestring); button.setonclicklistener(new onclicklistener()...

z3 - Automated tools for applying formal methods to verify security policy in existing software -

i new formal methods arena, feel have educated grasp on applications. however, seem encounter formal methods applied development process, software created. i'd able apply formal methods on existing software test whether adheres role based access controls (rbac) , separation of sensitive information following bell-lapadula (blp) method. what methods , tools know of offer automated solution rbac , blp-like verification of existing software/source code? cheers, m. forods there several formal tools rbac. some based on model checking (nusmv), noteworthy mohawk karthick jayaraman et.al.: http://people.csail.mit.edu/rinard/paper/tissec13.pdf there tools using smt based model checking: anna lisa ferrara, p. madhusudan, truc l. nguyen , gennaro parlato vac - verifier of administrative role-based access control policies

ios - Today extension: syncing data with container app -

context i've been playing around today extensions using this example project . the app quite simple: in containing app, have list of todo items, can mark completed in today widget, see same list, can switch between completed, , incomplete items using segmented control. my goal following: whenever there data change, either in container app, or widget, want both reflect changes: if mark item completed in container app, pull down notification center, widget should updated when same in widget, return app, app's state should updated the implementation i understand, container app, , extension run in separate processes, means 2 constraints: nsuserdefaultsdidchangenotification useless. managing model instances in memory useless. i know, in order access shared container, both targets must opt-in app groups entitlements under same group id. the data access managed embedded framework, todokit . instead of keeping properties in memory, goes straight nsuser...

java - Please help me understand Arrays -

i in 4th week of programming , teacher moving quickly. confused. vaguely understand arrays is. teacher wants create array (a double) has 50 elements, need loop through array , have first 25 have if statement set index squared, else 3x index. need print out 10 per line. way on head , of course teacher not going available saturday or sunday (it due sunday). after got clarification on teacher wanted wednesday. have been going crazy trying figure out how this. not asking answer, solid direction. correspondence email teacher while asking clarification."you’re on right track not quite there. index variable isn’t set number; reference value in array. in statement: array[count] = 5; count index variable , value basing our calculations on. since changes, our output more like: 0 1 4 9 16 25 36 49 64 81 100 121 .. .. .. .. .. .. .. .. .. .. .. .. .. 75 78 81 84 87 .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. notice should full 10 line making line 3 have 5 e...

java - NullPointerException when trying to create a Bitmap -

i receiving nullpointerexception when try put application stack. below stack trace application failure: 06-04 15:03:08.715 e/androidruntime(22756): process: com.example.jalexander.copyright, pid: 22756 06-04 15:03:08.715 e/androidruntime(22756): java.lang.runtimeexception: unable stop activity {com.example.jalexander.copyright/com.example.jalexander.copyright.mainactivity}: java.lang.nullpointerexception 06-04 15:03:08.715 e/androidruntime(22756): @ android.app.activitythread.performstopactivityinner(activitythread.java:3202) 06-04 15:03:08.715 e/androidruntime(22756): @ android.app.activitythread.handlestopactivity(activitythread.java:3253) 06-04 15:03:08.715 e/androidruntime(22756): @ android.app.activitythread.access$1100(activitythread.java:139) 06-04 15:03:08.715 e/androidruntime(22756): @ android.app.activitythread$h.handlemessage(activitythread.java:1227) 06-04 15:03:08.715 e/androidruntime(22756): @ android.os.handler.dispatchmessage(handler.java:102)...

remove lines between two pattern (inclusive of the pattern) using awk or sed -

my output file below judi#cat file ---abc--- word1 word2 word3 word4 word5 word6 ---end_abc--- ---def--- line1 line2 line3 line4 ---end_def--- judi# i need remove lines in between pattern abc , end_abc (inclusive pattern, replace new content , new content in file content of file varies, need use pattern judi#file1 ---abc--- worda1 worda2 worda3 ---end_abc--- judi# desired result has judi# ---abc--- worda1 worda2 worda3 ---end_abc--- ---def--- line1 line2 line3 line4 ---end_def--- judi# i tried below command sed '/abc/,/end_abc/{/abc/!{/end_abc/!d}}' file > file 2 but getting below mentioned error sed: command garbled: /abc/,/end_abc/{/abc/!{/end_abc/!d}} sed '/end_abc/a ##here' file | sed '/abc/,/end_abc/d' | sed '/##here/r file1' | sed '/##here/d' >file2 output judi#cat file judi#file1 ---abc--- worda1 worda2 worda3 ---end_abc--- judi# ---def--- line1 line2 line3 line4 ---end_def--- judi# a ##here...

vectorization - R - Vectorized implementation of ternary function -

i have 3 vectors x , y , z of equal length n . need create n x n x n array of function f(x[i],y[j],z[k]) . straightforward way sequentially loop through each element of each of 3 vectors. however, time required compute array grows exponentially n . there way implement using vectorized operations? edit: mentioned in comments, have added simple example of what's needed. set.seed(1) x = rnorm(10) y = seq(11,20) z = seq(21,30) f = array(0, dim=c( length(x),length(y),length(z) ) ) (i in 1:length(x)) (j in 1:length(y)) (k in 1:length(z)) f[i,j,k] = x[i] * (y[j] + z[k]) thanks. you can use nested outer : set.seed(1) x = rnorm(10) y = seq(11,20) z = seq(21,30) f = array(0, dim = c( length(x),length(y),length(z) ) ) (i in 1:length(x)) (j in 1:length(y)) (k in 1:length(z)) f[i,j,k] = x[i] * (y[j] + z[k]) f2 <- outer(x, outer(y, z, "+"), "*") > identical(f, f2) [1] true a microbenchmark including expand.grid sol...

Xcode snapshot fails when using git lfs -

i have git set git-lfs extension . when using xcode 6 search , replace uses git internally take snapshot of project before doing replace. using lfs snapshot fails message: error: copy-fd: write returned broken pipe error: cannot feed input external filter git lfs clean %f error: external filter git lfs clean %f failed 1 error: external filter git lfs clean %f failed fatal: xxxx: clean filter 'lfs' failed is possible configure xcode use version of git lfs extension installed? or update version of git used xcode add lfs extension? i tried installing git-lfs in same directory git used xcode not help. cp git-lfs /applications/xcode.app/contents/developer/usr/bin i'm guessing you've installed git-lfs via homebrew, it's in /usr/local/bin , , updated path match. problem gui apps don't inherit updated path shell, because parent process launchd . when xcode tries run git , git fails because can't locate git-lfs . this answer talks various wa...

xcode - Swift: filter protocol array by comparing types -

(first post) usually im able find answers here or elsewhere no luck time =( question: in swift, how filter array of protocol type implementing type supplied function parameter? protocol aprotocol { var number:int { set } } class aclass: aprotocol { var number = 1 } class anotherclass: aprotocol { var number = 1 } var array:[aprotocol] = [ aclass(), anotherclass(), aclass() ] func foo (parameter:aprotocol) -> int { return array.filter({ /* p in p.self == parameter.self */ }).count } var bar:aprotocol = // aclass() or anotherclass() var result:int = foo(bar) // should return 2 or 1, depending on bar type maybe not right approach @ all? thanks! here think want: return array.filter { (element: aprotocol) -> bool in element.dynamictype == parameter.dynamictype }.count but recommend this, same, without useless instance of aclass() passed in answer on top. way faster: func foo <t: aprotocol>(type: t.type) -> int { ret...

ios - Missing navigation in master-detail application with two table controllers -

i'm working on master-detail application ( swift ) 2 uitableviewcontroller 's master , detail. when click cell in master , i'm redirected detail , part works expected, in details view don't see navigation bar, problem. question how can show navigation in detail view ? you can select each table view controller in story board, go editor => embed in => navigation controller . if each detail view, should able see navigation bar appear. also, have taken @ answer: https://stackoverflow.com/a/16254273/2730985 embed uiviewcontroller in navigationcontroller using segues ?

android - Gradle Could not resolve all dependencies -

i trying 1 simple thing: import of google's libraries in order use gmail api. aware of these jars not exist on mavencentral. therefore updated google repositories sdk manager , instructed gradle in sdk. removed version numbers in end of dependencies , replaced them + did not resolve problem , therefore fall original build.gradle file. my build.gradle file looks this: buildscript { repositories { mavencentral() def androidhome = system.getenv("android_home") maven { url "$androidhome/extras/android/m2repository/" } } dependencies { classpath 'com.android.tools.build:gradle:0.14.0' } } apply plugin: 'com.android.application' android { compilesdkversion 22 buildtoolsversion "22.0.1" defaultconfig { applicationid "com.hellobusiness.hotels" minsdkversion 14 targetsdkversion 22 versioncode 1 versi...

Android output is showing editable text -

here code: package com.ricky.amnestyapp; import java.util.arraylist; import java.util.list; import org.apache.http.namevaluepair; import org.apache.http.message.basicnamevaluepair; import org.json.jsonarray; import org.json.jsonexception; import org.json.jsonobject; import android.app.activity; import android.app.progressdialog; import android.content.intent; import android.os.asynctask; import android.os.bundle; import android.util.log; import android.view.view; import android.widget.button; import android.widget.edittext; public class editdiseasesactivity extends activity { edittext txtname; edittext txtprice; edittext txtdesc; edittext txtcreatedat; string pid; // progress dialog private progressdialog pdialog; // json parser class jsonparser jsonparser = new jsonparser(); // single product url private static final string url_product_deti...

deployment - Ansible vs Jenkins -

our team needs automated deployment tool , have concentrated on 2 major options: ansible , jenkins. could please consult me pros , cons of each , also, if know better deployment tool, please recommend them , state why. some information our structure: debian os (some programmers use windows 8 , debian on vm). our version/code management tools svn , github (hopefully soon, github). main programming language php. ansible , jenkins supplement each other. you should start writing ansible playbook provisioning , deployment. when it's ready , tested local machine can setup jenkins job use playbook. jenkins can use different triggers github commit webhook or cron-like scheduler. in setup rely on ansible , use jenkins tool run ansible playbook when needed. seems perfect separation of concerns.

jpa - jsf - foreign key in datatable -

i'm showing list of orders in datatable , , 1 of columns must show customer_id of order: customer_id fk in manytoone relationship. customer entity @entity public class customer { ///other columns @onetomany(mappedby = "cliente", fetch=fetchtype.eager) private list<order> orders; order entity @entity @table(name = "orders") public class order implements serializable{ /** * */ private static final long serialversionuid = 1l; @id @generatedvalue(strategy = generationtype.auto) private long id; @column (nullable = false) private string state; @column (nullable = false) @temporal(temporaltype.timestamp) private calendar openingdate; @column (nullable = true) @temporal(temporaltype.timestamp) private calendar closingdate; @column (nullable = true) @temporal(temporaltype.timestamp) private calendar evadingdate; @manytoone(cascade={ cascadetype.pe...

image - MATLAB ConnectedComponentLabeler does not work in for loop -

i trying set of binary images' eccentricity , solidity values using regionprops function. obtain label matrix using vision.connectedcomponentlabeler function. this code have far: files = getfiles('images'); ecc = zeros(length(files)); %eccentricity values sol = zeros(length(files)); %solidity values ccl = vision.connectedcomponentlabeler; i=1:length(files) = imread(files{i}); [l num] = step(ccl, i); j=1:num l = changem(l==j, 1, j); %* end stats = regionprops(l, 'all'); ecc(i) = stats.eccentricity; sol(i) = stats.solidity; end however, when run this, error says indicating line marked *: error using connectedcomponentlabeler/step variable-size input signals not supported when outputdatatype property set 'automatic'.' i not understand matlab talking , not have idea how rid of it. edit i have returned bwlabel function , have no problems now. the error bit hard understand, can ...

compiler errors - OpenMP support on OpenBSD -

i'm trying build crypto++ on openbsd 5.7 x86_64 openmp support. compile failing error message: g++ -ddebug -g3 -os -fpic -fopenmp -march=native -dcryptopp_disable_sss3 -c nbtheory.cpp nbtheory.cpp: error: omp.h: no such file or directory openbsd's compiler supports -fopenmp option (another 150 files compile ok flag), i'm not sure should do. i have opensbd sources , ports installed, i'm not able find header: $ find / -name omp.h 2>/dev/null $ i tried googling, turned bunch of evasive answers openmp support. see, example, openmp gcc4? . do need install somewhere? or openbsd not support it? if need compile/install library proper somewhere, find it?

web services - WCF / WSDL file seems to be malformed -

ok. have functional wcf rest service. can use fiddler , send json , expected responses. so far good. but when try add service reference in .net project throw error when try create service (please refer adding wcf service not add meaningful configuration.svc.info - think i’ve found root cause it’s sufficiently different decided open question.) note it’s not visual studio. can add references other services fine , multiple different installs of vs won’t work service. i think root cause wsdl file incorrect. there sample microsoft provides here - https://msdn.microsoft.com/en-us/library/windows/desktop/dd323317(v=vs.85).aspx , live example here - http://www.webservicex.com/globalweather.asmx?wsdl the upshot both examples have lot more have when calling wsdl https://marius.activistmanager.com/1_0_0.svc?wsdl but when use single page wsdl kinds of information - https://marius.activistmanager.com/1_0_0.svc?singlewsdl i think it’s problem in wcf service’s web.config file set ...

c++ - How come my destructor is not destroying my object and it still retains its member variable values? -

in code don't understand why derived class object not being destroyed though called destructor explicitly. don't know if because didn't include delete or scope can me out? added comments in code illustrate issue in header file have: #ifndef test_test_h #define test_test_h #include <iostream> #include <string> using namespace std; class test{ public: test(); void setname(); string getname(); private: string name; }; class book:public test{ public: book(); ~book(); void setbook(); string getbook(); private: string bookname; }; #endif in implementation file have: #include "test.h" test::test() { cout<<"calling base construtor"<<endl; name="hi"; } book::book() { cout<<"calling derived constructor"<<endl; bookname="yolo"; } test::~test() { cout<<"calling test destructor"<<endl; } book::~book()...

Facebook Share button (add "via page" to share) -

Image
is there way include "via facebook page" when sharing blog post on website? when clicks share button, share personal accounts, add link facebook page "via my-page" when clicks share button on blog site (wordpress)? regards after clicking on share button can choose that: then can choose page exactly, if have more one.

Define function in Haskell with computations in arguments -

how can define function in haskell this: x(0) = 1 x(2*k) = sin(k) * cos(k) x(2*k+1) = cos(k/2) - tan(2*k) haskell not allow define function computation in arguments. raise "parse error in pattern" error. if try define in terms of x(k) , this: x(k) = sin(k/2) * cos(k/2) x(k) = cos((k/2-1)/2) - tan(k/2-1) i have 2 definitions x(k) , not valid. you can define follows: f 0 = 1 f | = sin(k) * cos(k) | otherwise = cos(k/2) - tan(2*k) k = fromintegral $ div 2 i replaced x f because x looks more variable function. furthermore used i incoming parameter. div 2 means divide i 2 (and floor result), such 0 maps 0 , 1 0 , 2 1 . 1 can use fromintegral convert floating ; otherwise cannot take sin , etc. now there 2 cases (except f 0 case): 1 i even ( 2*k ) , 1 i odd (in case otherwise ). can use guards this. case, use sin(k) * cos(k) , other 1 cos(k/2)-tan(2*k) . note k/2 use floating point, if i 7 , k 3 , calculate cos(1.5...

How does pruning choice points in the code below make it more efficient (Prolog)? -

in code given below, there ! (cut) prunes choice point efficiency. pretty reverse predicate , agent_do_moves predicate essential. solve_task(task,cost):- agent_current_position(oscar,p), solve_task_a(task,[b(0,0,p)],[],r,cost,_newpos),!, % prune choice point efficiency reverse(r,[_init|path]), agent_do_moves(oscar,path). the cut in above examples has following effect: ideally, commits search might happen within solve_task_a/6 first answer found. frees resources finding further answers improves space consumption. scope problems however, @ same time, might hide further answers agent_current_position/2 . of course, not make sense have further answers goal, might error happens sleep while, become active still undiscovered in worst possible situation. for reason, preferable write instead of cut ..., once( solve_task_a( ... ) ), ... this limits scope precisely want express. steadfastness problem but not possible source of p...

ios - Adaptive Layout - calculate second row of views based on view width -

Image
i programmatically adding dynamic number of uibutton labeled hashtags compact view using adaptive layout. there way adaptive layout automatically calculate when width of view met , new line needed, or need calculate myself, manually anchor next row of buttons under previous , on? my current source gives me following image, second row needed. appreciate direction on this. auto layout cannot this, if want use individual buttons, you'll have calculate yourself. alternative use collection view automatically layout buttons (cells).

java - Having trouble with string concatenation -

i trying concatenate string + else, this: string example = " " (int = 0; < 5; i++) { if (condition ok) { example = example + "\nanother text"; } } joptionpane.showmessagedialog(null, example); in mind, should've print " (new line)another text" seems work last entry in "another text". like, if condition inside "for" loop ok 3 times, prints " (new line)another text(3)" instead of " (new line) text(1) (new line) text(2)... any idea of may happening? edit: after realizing code fine, followed afzalex recommendation , found out error in condition. bro i used below program got expected output. string example = " "; (int = 0; < 5; i++) { if (i == 1 || == 3) { example = example + "\nanother text"; } } system.out.println(example); output: another text text so, wrong joptionpane.showmessagedialog(null, example); if...

How can I access a Button Press from a different Form? C# -

so creating text editor, , want have popup when user attempts close application asking whether sure want this, in windows' notepad. not using messageboxes, instead using custom form. how can info button press in form2 , access in form1? thanks in advance responses. if there's other info can provide useful, please let me know! edit mean: have created form 3 buttons: save, don't save, , cancel. want info they've pressed. return of button , go there? you need have property pull info out of on secondary form. you'll still want use showdialog() , can check dialog result. memory code may not build, should give idea. on form2 public string text { { return this.sometextboxontheform.text; } set { this.sometextboxontheform.text = value; } } //called "save" button. public void save() { this.dialogresult = dialogresult.ok; this.close(); } //called either "dontsave" button or "cancel" button. public void cancel...

Java: Is it possible to disable Windows DPI scaling from within java? -

windows scaling messing ui on javafx app. there way within java let windows know specific app should not scaled? thanks i haven't tried javafx yet, that's recurrent issue can influenced program (exe) properties. try selecting editor (netbeans.exe or eclipse.exe), selecting properties, , switching compatibility tab. on tab should see option labeled "disable display scaling on high dpi settings". if do, select it, run program, , see if works. if does, means after compile program rest of world, ensure launcher has said scaling disabled before distributing. slick2d, , swing, have had similar issues. it should possible change program properties internally nio.2; don't know enough of details off top of head. let me know if works.

python - Missing Significance level for Pearson Chi-Squared Test -

Image
i'm trying switch on stata , r python's statsmodels. find can of need missing when running negative binomial regression -- specifically, significance level chi-squared test. example, model this: mod1 = smf.glm(formula='like_count ~ source + followers_count + \ mission_focus_patient_advocacy + assets + hashtag_count, data=df, \ missing='drop', hasconst=none, family=sm.families.negativebinomial()).fit() from can run mod1.summary() , main model results, seen below: typically report number of observations, there, log-likelihood value, there, pearson chi-squared value, there, along 3 pieces of missing information: 1) significance level chi-squared test, 2) pseudo-r2 value such mcfadden pseudo-r-squared (i know should not reviewers want see it), , 3) results of likelihood-ratio chi-squared test (to show poisson model not work instead). my question is, how can these things? know can access specific model results individually, including: mod1.llf ...

regex - sed - replace a variable of power N by the product of N variables -

from sed replace variable of power product of 2 variables , generalize "power 2" case "n power case". the command line in "power 2" case : sed 's/\([^(*+\/^-]*\(([^)]*)\)\?\)\^2/\1\*\1/g' so cos(2*a)^2+sin(3*b)^2+m1^2*m2^2*cos(4*c) is replaced : cos(2*a)*cos(2*a)+sin(3*b)*sin(3*b)+m1*m1*m2*m2*cos(4*c) now, want transform : cos(a)^3 +m1^4 to cos(a)*cos(a)*cos(a)+m1*m1*m1*m1 is there way store exponent "n" , print n times variable powered with star symbol ? it (we store exponent in pattern \2 ) : sed 's/\([^(*+\/^-]*\(([^)]*)\)\?\)\^\([0-9]*\)/ "print n times ( pattern \2 ) factors \1 " \1\*\1*\1*\1 /g' if somenone has solution other tools (other linux commands), take. echo "cos(a)^3 +m1^4" | sed ' # encapsulate between + s/.*/+&+/ :a # each power object /\^/!b end # isolate power object h s#\(.*[-+/*^]\)\([^-+/*^]*\)^\([0-9]\{1,2\}\)\(.*\)#\1\ \2\ \4#...

Spring cache with Redis: NullPointerException -

when added @cacheable annotation service method , executed it, got following error: java.lang.exceptionininitializererror @ org.springframework.data.redis.connection.jedis.jedisconnectionfactory.getconnection(jedisconnectionfactory.java:252) @ org.springframework.data.redis.connection.jedis.jedisconnectionfactory.getconnection(jedisconnectionfactory.java:58) @ org.springframework.data.redis.core.redisconnectionutils.dogetconnection(redisconnectionutils.java:128) @ org.springframework.data.redis.core.redisconnectionutils.getconnection(redisconnectionutils.java:91) @ org.springframework.data.redis.core.redisconnectionutils.getconnection(redisconnectionutils.java:78) @ org.springframework.data.redis.core.redistemplate.execute(redistemplate.java:178) @ org.springframework.data.redis.core.redistemplate.execute(redistemplate.java:153) @ org.springframework.data.redis.cache.rediscache.get(rediscache.java:104) @ org.springframework.data.redis.cache.re...

asp.net - importing CSS <link> property is not working on server -

i kept .css files in folder . importing on aspx page . when running on localhost working fine when hosting on server not working . when declaring on each aspx page , rewriting same css file working fine . question why not importing file on server on localhost working fine . i had problem hosting server not reaching proper files though imported successfully. did backed files, deleted them , replaced them backup. added ../ before folders in links root folder, navigated css folder there, , worked. may have root dir being different. if works great, if not oh well.

escaping - In C++, how can I cout a logo that features many special characters? -

i have logo features many special characters, such escape characters, , want print terminal. how should without compiler throwing "unknown escape sequence" errors? here example code (that features 1 problematic character -- not, say, hundreds): void print_logo(); int main(){ print_logo(); return 0; } void print_logo(){ std::cout << "\_ hello _/\n"; } note manually escaping of special characters in logo not option. how raw literals? #include <iostream> int main() { const char* tree = r"===( * , _/^\_ < > * /.-.\ * * `/&\` * ,@.*;@, /_o.i %_\ * * (`'--:o(_@; /`;--.,__ `') * ;@`o % o,*`'`&\ * (`'--)_@ ;o %'()\ * ...

Why parsing Gremlin query in Java isn't generic? -

i'm parsing gremlin query in java (well, i'm writing scala, , using groovy compiled jars java). the query string variable given user input . in other words - cannot tell query be, i'm assuming it's valid gremlin query (syntactically , logically). i started simple gremlin.compile(query) returns pipe on i'm iterating. however, according the example , 1 must invoke .setstarts prior iterating pipe. , must know runtime type s in pipe<s,e> . it feels api isn't generic enough, following line example pipe.setstarts(new singleiterator<vertex>(graph.getvertex(1))); will work cases, vertex iteration 1 example ( g.v() ) throw castexception. is there way work-around it? perhaps using underlying script engine (like next examples in link above) me achieve more generic code? i found workaround. feels bit ugly job. i'm using scriptengine bindings of 'g' graph, user can start his/her queries g. . (not helps generics, mak...

add value to each element in array python -

i have array this a= np.arange(4).reshape(2,2) array([[0, 1],[2, 3]]) i want add value each element in array. want result return 4 array like array([[1, 1],[2, 3]]) array([[0, 2],[2, 3]]) array([[0, 1],[3, 3]]) array([[0, 1],[2, 4]]) [a + i.reshape(2, 2) in np.identity(4)]

Playframework 2.4 Singletons, Object -

before playframework 2.4 used create object singleton class, , see singletons can achieved using @singleton annotation. but, difference? is using dependency injection @inject() ? i afraid playframework 2.4 dependency injection enter in unnecessarily complicated way. @singleton part of jsr 330 standard , indeed dependency injection only. tells di framework create 1 instance of given class , use single instance across application. docs: new instances created every time component needed. if component used more once, then, default, multiple instances of component created. if want single instance of component need mark singleton. you can think of directive di framework create 1 instance. nothing holds creating multiple @singleton annotated classes hand using new . singleton objects in scala in contrast true singletons , cannot instantiated hand.

android - Put a string into a dialog from a slected list item from a expandable list child -

i've been trying pull details of item selected, strings.xml. dialog pop when select item expandable list view (child). sadly little success. this expandable list fragment navigationdrawerfragment. works great. dialog pulls template text. case 2: rootview = inflater.inflate(r.layout.fragment_item_list, container, false); // listview explistview = (expandablelistview) rootview.findviewbyid(r.id.lvexp); // preparing list data preparelistdata(); listadapter = new expandablelistadapter(this, listdataheader, listdatachild); // setting list adapter explistview.setadapter(listadapter); // listview on child click listener explistview.setonchildclicklistener(new expandablelistview.onchildclicklistener() { @override public boolean onchildclick(expandablelistview parent, view v, int groupposition, int childposition, long id) { // custom dialog fin...

Using Braintree and Stripe in Android app -

i have developped android app , thing left implement payment solution sell goods. have been searching while , found stripe , braintree. seems pretty same in many aspects. however, wondering 1 best use user of app: instance, stripe require each user has stripe account? performances , number of forms fill-in user? sum up, 1 more user-friendly? neither requires customer have account solution. part ease of use customer perspective come how design app / form. braintree offers pre-built design (drop in) android, stripe's built in offering (checkout) offered on ios. both allow use own form collect cc info. both support apple pay / android pay (when comes out). braintree supports paypal , venmo. to end user in cases enter card number, expiration, cvc code, 1 form, how simple make you.

database - Query family tree and marriage information in Neo4j -

Image
i have family tree in neo4j database how can query tree starting root node (126 in case) , husband, wife information of each node (similar image)? i later need extract data in code in similar json format root = { name: "...", children: [{ name: "...", children: [] }, { name: "...", children: [] }], marriage: [{ name: "first wife" }, { name: "second wife" }] }; thanks after researching more cypher, found solution answer own question this cypher query. query root user id 682 match p=(root:person {user_id: 682})-[:father_child|mother_child *1..5]-> (child:person)<-[:father_child|mother_child]-(:person) nodes(p) all_nodes, relationships(p) all_relationships, p p return extract(n in all_nodes | n.user_id) `path`, extract(r in all_relationships | type(r)) `relation`, length(p) `length` order `length`; the sample result this +------------------------...

performance - Why in C++ overwritingis is slower than writing? -

i have run piece of code manages video stream camera. trying boost it, , realized weird c++ behaviour. (i have admit realizing not know c++) the first piece of code run faster seconds, why? might possible stack full? faster version double* temp = new double[n]; for(int = 0; < n; i++){ temp[i] = operation(x[i],y[i]); res = res + (temp[i]*temp[i])*coeff[i]; } slower version1 double temp; for(int = 0; < n; i++){ temp = operation(x[i],y[i]); res = res + (temp*temp)*coeff[i]; } slower version2 for(int = 0; < n; i++){ double temp = operation(x[i],y[i]); res = res + (temp*temp)*coeff[i]; } edit realized compiler optimizing product between elemnts of coeff , temp . beg pardon unuseful question. delete post. this has nothing "writing vs overwriting". assuming results indeed correct, can guess "faster" version can vectorized (i.e. pipelined) compiler more efficiently. the difference in in version allocate s...

android - 12 requests are being fired to the server instead of once every 5 seconds in the AsyncTask class -

i sending simple json string {"tesla": "48.846305"} every 5 seconds server noticed many requests 12 being fired server in 1 second want send data once every 5 seconds. how can fix that? i appreciate help. output: 06-14 12:01:29.643: i/system.out(7915): output of : doinbackground {"tesla":23.91065752874712} 06-14 12:01:29.824: i/system.out(7915): output of stringbulder: {"status":280} 06-14 12:01:29.834: i/system.out(7915): output of : doinbackground {"tesla":23.91065752874712} 06-14 12:01:29.984: i/system.out(7915): output of stringbulder: {"status":280} 06-14 12:01:29.984: i/system.out(7915): output of : doinbackground {"tesla":23.91065752874712} 06-14 12:01:30.134: i/system.out(7915): output of stringbulder: {"status":280} 06-14 12:01:30.144: i/system.out(7915): output of : doinbackground {"tesla":23.91065752874712} 06-14 12:01:30.284: i/system.out(7915): output of stringbulder: {...