Posts

Showing posts from June, 2012

arduino - Is there a reason this break statement doesn't break out of the for loop? -

i'm going crazy. know loop entered, there must i'm doing prevents break exiting loop. ideas? for (int j = 0; j < 12; j++) { if (users[i][1][j] != arr[j]){ serial.println("mismatch"); break; } else if (j == 11){ serial.println("entire card read correctly"); return i; } } for loop - break nonfunctional the code being reentered outside loop.

perl - Why is IO::Socket::Socks unreliable when creating a proxy chain? -

i want use module create connection using multiple socks proxies, module using unreliable , slow compared using external solution such proxychains. after connecting through chain of proxies, while loop begins sending data through proxy chain. however, program crashes error: "out of memory". have advice on how fix code? appreciated. while ($sock) { $sock->syswrite ( "get / http/1.1\r\n" ); } when @ wireshark capture, initial request sent without problems following requests have duplicate http requests in each packet. see: wireshark capture edit: tried using io::async, requests aren't sent. my $loop = io::async::loop->new; $handle = io::async::handle->new( write_handle => $sock, on_write_ready => sub { $request = "get / http/1.1\r\n" print $sock $request; } ); $loop->add( $handle ); $loop->loop_forever; edit: able fix script establishing new chain each request send. possible send connect request through socks

c# - Implicitly convert type 'string' to 'bool' -

Image
i have deal question: filter student in list result "pass". when write code in picture below, return wrong caution this: cannot implicitly convert type 'string' 'bool'. although used convert.toboolean(t.result) can't work? help me! to filter student in list result "pass" need add condition as: lst.where(t => t.result=="pass").tolist(); you can same boolean property instead string, property definition like: public bool result { { return score > 25; } } so iterative condition filtering student in list result "pass" (score > 25) lst.where(t => t.result).tolist();

html - Change text size for mobile users -

using fullpage.js, created 'slides' page looks great in browser, on iphone not scale text fit screen (and it's not zoomable either). it ends looking this in css file, have font set @ 1.2em, there way make text scale more readable size on iphone? if you'd view on phone: link example thanks so for every resolution can set different css meaning. example @media screen , (max-width: 300px) { body { background-color:lightblue; } } it means if resolution not more 300 use different background body. if dont want have in same same css can link this: <link rel="stylesheet" type="text/css" href="tablets.css" media="screen , (min-width: 600px) , (max-width: 800px)">

Java Generic Lists and Arrays performance -

i'm wondering why performance bad when working generic lists , arrays in java. i had below create generic array, taking on 2 seconds create array 50 elements. final t[] returnclasses = (t[]) array.newinstance(classoft, data.getcount()); after reading number of areas java.lang.reflect.array shouldn't used hasn't been optimised , use lists instead changed code below. list<t> returndatalist = new arraylist(data.getcount()); after change there no performance increase. when comparing timings creating explicitly typed list times returned 0ms what efficient way create collection (must retain order) when using generics? if makes difference method declared as public <t> list<t> method(data data, class<t> classoft) logging done below code calendar = calendar.getinstance(); list<t> returndatalist = new arraylist(data.getcount()); log.d("test", "create array time = " + (calendar.getinstance().gettimeinmillis()

kubernetes - kibana in the kebernets cluster doesn't work -

i'm facing issue following when append logging addon kubernete cluster ,the kibana doesn't work,any clue troubleshoot it? thank in advance. kubectl pod/kibana-logging-v1-mertn --namespace=kube-system name ready status restarts age kibana-logging-v1-mertn 0/1 crashloopbackoff 8 21m kubectl logs pod/kibana-logging-v1-mertn --namespace=kube-system elasticsearch_url=http://elasticsearch-logging.kube-system:9200 {"@timestamp":"2016-04-19t02:39:08.559z","level":"error","message":"service unavailable","node_env":"production","error":{"message":"service unavailable","name":"error","stack":"error: service unavailable\n @ respond (/kibana-4.0.2-linux-x64/src/node_modules/elasticsearch/src/lib/transport.js:235:15)\n @ checkrespforfailure (/kibana-4.0.2-linux-x64/

java - How to change front size and Set it mid AlertDialog.Builder by ArrayList -

this code want change front size , let in mid, example seldom explain . help. painlist = new arraylist<>(); painlist.add(getstring(r.string.painl1)); painlist.add(getstring(r.string.painl2)); new alertdialog.builder(clear.this) .settitle("aaa") .setitems( painlist.toarray(new string[painlist.size()]), new dialoginterface.onclicklistener() { @override public void onclick(dialoginterface dialog, int which) { if (which == 0) { intent go = new intent(); go.setclass(clear.this, pain.class); startactivity(go); } if (which == 1) { intent go = new intent(); go.setclass(clear.this, clear.class); startactivity(go); } } }).show(); thanks!! you must use style dialog. example create my_dialog_style.xml in values res folder: <?xml version="1.0" encoding="utf-8"?> <resources> <style name="mydialogst

unix - How can openat avoid TOCTTOU errors? -

according advanced programming in unix environment , openat() provides way avoid time-of-check-to-time-of-use (tocttou) errors. i’m confused how. far know, openat relies on file descriptor, file descriptor needs opened first - introduce tocttou? the posix specification openat() says: int openat(int fd , const char * path , int oflag , ...); […lengthy spiel on regular open() …] the openat() function shall equivalent open() function except in case path specifies relative path. in case file opened determined relative directory associated file descriptor fd instead of current working directory. if file descriptor opened without o_search , function shall check whether directory searches permitted using current permissions of directory underlying file descriptor. if file descriptor opened o_search , function shall not perform check. the oflag parameter , optional fourth parameter correspond parameters of open() . if openat() passed specia

memory - C++ calling one function repeatedly system hang -

i getting serious issue 1 function in c++. function double** fun1(unsigned l,unsigned n, vector<int>& list, vector<string>& dataarray) { double** array2d = 0; array2d = new double*[l]; string alphabet="acgt"; (int = 0; < l; i++) { array2d[i] = new double [4]; vector<double> count(4, 0.0); for(int j=0;j<n;++j) { for(int k=0;k<4;k++) { if (toupper(dataarray[list[j]][i])==alphabet[k]) count[k]=count[k]+1; } } for(int k=0;k<4;k++) array2d[i][k]=count[k]; count.clear(); } return array2d; } the value of l around 100 , n=1, dataarray size (50000 x l) , list contain 1 number between 0-49999. calling function main program many number of times (may more 50 million times). upto number of times going smooth after 2/3 minute around system hangs. unable find problem co

php - how to insert bulk data at a time in laravel? -

hi trying insert multiple rows in database @ time. can save single row @ time. have done following: public function addnewpricerevision($data){ $pricerevision=new productpricerevision( [ 'product_id'=>$data->product_id, 'invent_price'=>$data->invent_price, 'revised_price'=>$data->revised_price, 'effective_date'=>$data->effective_date, 'deleted'=>$data->deleted, 'remark'=>$data->remark, 'user'=>$data->user, 'date'=>$data->updated_at, ] ); $pricerevision->save(); return common::getjsonresponse(true, 'new price revision created successfully!', 200); } try convert objects arrays , create array multiple arrays: $data = array($data1->toarray(), $data2->toarray()); if need add timestamps, must manually: $date = date('y-m-d h:i:s'); $data1 = $data1->toarray

ios - How to open particular post on the click on push notification -

in app implemented push notification. when app in running state , if push notification come handle code. func application(application: uiapplication, didreceiveremotenotification userinfo: [nsobject : anyobject]) { print(userinfo) myid = (userinfo["id"] as? string)! print(myid) if let notification = userinfo["aps"] as? nsdictionary, let alert = notification["alert"] as? string { var alertctrl = uialertcontroller(title: "notification", message: alert string, preferredstyle: uialertcontrollerstyle.alert) alertctrl.addaction(uialertaction(title: "ok", style: uialertactionstyle.default, handler: nil)) // find presented vc... var presentedvc = self.window?.rootviewcontroller while (presentedvc!.presentedviewcontroller != nil) { presentedvc = presentedvc!.presentedviewcontroller } presentedvc!.presentvi

java - Spring Nested Transaction Generic Example -

can body provide insight here.. i have been having hard time, while getting through spring @transactional(propagation nested) i have been searching on net , here, unable find generic example of specific type regarding this.. @transactional(required) mtdone(user userobj1, user userobj2) { somebean.mtdtwo( userobj1); somebean.mtdthree(userobj2); } @transactional(nested) mtdtwo(userobj1) { //calling dao , insert data database daoobj.save(userobj1); //this data must not rolled back, // though exception thrown in next method } @transactional(required) mtdthree(userobj2) { //calling dao second time , insert data database daoobj.save(userobj2); /////some exception thrown here } so want save methodtwo data db, , must not rolled though exception thrown in next method.. i want achieve using transaction(nested) please give me suggestions..

SQL server Table partition with history data -

i have table in sql server 2008 r2 db 110 mill rows.to improve performance of canned report, suggesting partition table. user query fetches inception date data in runs. which means partition date/month not helpful if there no specific date range data select. can please suggest how can implement partition gain performance. thanks.

R: Applying a Function to an xts Object -

i have xts object: anchor_date <- as.date("2016-04-19") end_date <- as.date(anchor_date + years(5)) number_days <- end_date - anchor_date xts_object <- xts(rep(na, number_days + 1), as.date(anchor_date) + 0:number_days) i have function takes square of time between date , start date in years: time_squared_func <- function(start_date, date) { time_squared <- as.numeric(((date - start_date) / 365) ^ 2) return (time_squared) } i want apply function xts object, using constant start_date = first day in series, have date argument date in row of xts object. result should 0 in first row, gradually increasing 1 on 2017-04-19, 4 on 2018-04-19 etc... https://codereview.stackexchange.com/questions/39180/best-way-to-apply-across-an-xts-object this suggests vapply faster apply or lapply, if possible using vapply ideal, working fine. thank you. using lapply , rbind require(lubridate) anchor_date <- as.date("2016-04-19") en

batch file - How can I set the number of clients on my WiFi using CMD/BAT/VBS? -

is possible set number of clients using cmd - netsh command or other command. if possible using vbscript. want change number of clients according needs. when type following code: netsh wlan show hostednetwork it shows maximum number of clients can connect to, want change total number of clients want connect according requirement no 1 else can connect.

javascript - How to pass the Scala Map[String,Map[String,String]] to Js Object -

i wanted pass scala map values javascript json onject in play framework view i "syntaxerror: json.parse: unexpected character @ line 1 column 10 of json data" when check following code val maptobepasstojs = map( "cg1" -> map( "path" -> "/var/logs/cdr1/cdr", "name" -> "cg-1" ), "cg2" -> map( "path" -> "/var/logs/cdr2/cdr", "name" -> "cg-2" ), "cg3" -> map( "path" -> "/var/logs/cdr3/cdr", "name" -> "cg-3" ), "cg4" -> map( "path" -> "/var/logs/cdr3/cdr", "name" -> "cg-4" ) ) <script type="text/javascript"> var achartlist = jquery.parsejson("@jsonobject(maptobepasstojs).tostring()"

Java - String Class, Scanner Class -

how read sentence (string) line of input, , print whether represents declarative sentence (i.e., ending in period), interrogatory (ending in question mark), or exclamation (ending in exclamation point) or not sentence (anything else)? import java.util.*; public class stringdemo { public static void main(string[] args){ scanner console = new scanner(system.in); // enter string: system.out.println("enter string: "); string dog = console.nextline(); dog = dog.touppercase(); system.out.println(dog + " has " + dog.length() + " letters , starts " + dog.substring(0, 1)); // enter string: system.out.println("enter string: "); string cat = console.nextline(); cat = cat.touppercase(); system.out.println(cat + " has " + cat.length() + " letters , starts " + cat.substring(0, 1)); // check contents here

ios - Uploaded Video did not show on vine app -

Image
i found this: https://github.com/vineapi/vineapi/blob/master/endpoints.md i have following process share video on vine app. 1.login: https://api.vineapp.com/users/authenticate authentication using above doc lin api. have received key(session key). for process. after use next api upload video thumbnail on vine. 2.thumnails https://media.vineapp.com/upload/thumbs/1.3.1.mp4.jpg thumbnails uploaded on vine , received server response uploaded thumbnails url in x-upload-key . can see above image. 3.upload video : https://media.vineapp.com/upload/videos/1.3.1.mp4 video data uploaded on vine , received server response uploaded video url in x-upload-key . can see above image. 4.create post: https://api.vineapp.com/posts post create on vine , received server response { code = ""; data = { created = "2016-04-18t09:27:20.000000"; permalinkurl = "https://vine.co/v/ifaqlt7w5qm"; postid = 1333777877887795200; videourl = &quo

java - Handle Nullpointerexception after SQL query has no result -

i've got mvc based java application 3 models: room , student , studentroom . studentroom contains object of room , student . now i've got problem if sql query returns no result , check value of student's name this if(studentroom.student.name != null) { } i'll nullpointerexception , don't know how handle it. should set student.name = ""; since query has no result? if(studentroom != null && studentroom.student != null && studentroom.student.name != null){ //.. access student } above solution looks bit weird. should better use getter/setter methods instead of directly accessing objects. apart can define methods isstudentavailable() in studentroom check whether has student in or not. should set student.name = ""; since query has no result ? it depends on use case. must better keep null raise exception instead of passing null check validations.

java - How to access the Impl classes of Twitter4J? -

using mongodb, need persist objects twitter4j. twitter4j uses interfaces, implemented in json versions. example: the api returns status (an interface), , status implemented statusjsonimpl . i can't save status mongodb, need implement statusjsonimpl . my issue is, class statusjsonimpl not public ( see here ) can't use in code. tried download source of twitter4j manually add " public " statusjsonimpl : can do: status status = twitter.updatestatus(lateststatus); string statusstringified = twitterobjectfactory.getrawjson(status); statusjsonimpl statusimplemented = (statusjsonimpl) twitterobjectfactory.createuserlist(statusstringified); singletonlaunchdb.getmongo().save(statusimplemented); but still java.lang.illegalaccesserror on class statusjsonimpl @ run time. i see other sa answers users routinely point other users impl classes... how use in code? your appreciated. status serializable. recover statusjsonimpl statusstringified c

calculate less number of hops C# -

good morning :) i'm working on c# , want write code can calculate less number of hops point particular point, picture show click here show picture i have points 1 12, if want calculate less number of hops point 12 1 1 counterclockwise not 11 hops clockwise. example clarify question, if want calculate less number of hops point 11 4 5 counterclockwise not 6 hops clockwise. notice : number of points may odd number. hope understand question .. try clockwise , anticlockwise , take minimum : private static int hops(int a, int b) { return math.min((12 + - b) % 12, (12 + b - a) % 12); } tests: // 5 console.writeline(hops(11, 4)); // 1 console.writeline(hops(12, 1)); edit : matthew watson has mentioned in comments, may want know whether clockwise or anticlockwise : private static int clockwisehops(int a, int b) { return (12 + b - a) % 12; } private static int anticlockwisehops(int a, int b) { return (12 + - b) % 12; } private static int hops(int a, int b

php - laravel5.1 basic http auth for API -

i'm working on web based api. don't need overloaded feature of laravel use table storing login details of http auth. protect 1 function (so middleware overloaded too) using hardcoded username & password http auth. all found @ moment doesn't work, isn't there simple code example how so? found in tutorials using users table, api overloaded, since need 1 account hardcode controller. pass username & password in headers every call, , check hardcoded credentials in controller's constructor. example: use use illuminate\http\request; class mycontroller extends controller { public function __construct(request $request) { parent::__construct(); $username = $request->header('username'); $password = $request->header('password'); if($username !== 'your hardcoded username' || $password !== 'hardcoded password') { throw new \exception; } } }

.net - Error in installing the C# Windows Application build -

i have created c# windows application project build , selected prerequisites microsoft .net framework 4.5(x86 , x64), microsoft report viewer 2012 runtime, microsoft system clr types sql server 2012 (x64) , selected option download prerequisites same location application.the build created successfully. but when try install build in client computer following error message occurs "an error occurred while installing system components 'application name' setup cannot continue until system components have been installed ". when checked install file says - verifying file integrity of reportviewer.msi. winverifytrust returned -2146762486. file not trusted the application installs without problem if connect internet , install application. want work without internet connection. thanks in advance.

java - save Image as PNG -

i'd save array point chart image(png), java program can show schatter diagram don't know how save it. perhaps imageio.write, , how? can give me advice solve problem. thank you public class graph extends application { public void start(stage primarystage) { pane root = new pane(); int[] mydata = { 12, 9, 0, 1, 38, 19, 21, 72, 33, 83, 14, 10, 65, 46, 10, 17, 27, 38, 65, 98, 8, 58, 38, 79, 37, 69, 26, 15}; numberaxis xaxis = new numberaxis(); numberaxis yaxis = new numberaxis(); scatterchart scatterchart=new scatterchart(xaxis,yaxis); xychart.series data=new xychart.series(); (int i=0; i< mydata.length; i++) { data.getdata().add(new xychart.data(i,mydata[i])); } scatterchart.getdata().addall(data); root.getchildren().add(scatterchart); scene scene = new scene(root, 600, 400); primarystage.setscene(scene); primarystage.show(); file file = new file("c:\\images\\image.png"); // , ????? } public static void main(string[] args)

java - Struts2, convert s:select list to display Tag column -

i have following selection list in jsp: <td> <s:select list = "models" listvalue = "modelname" listkey = "modelid" multiple = "true" name = "models" /> </td> i chose implement pagination display tag library, want convert in display column , show 1 ore more models list. how can this? below display table other columns: <display:table name = "cars" requesturi = "/listcar.action" pagesize = "10"> <display:column property = "name" title = "name" /> <display:column titlekey = "models" > <!--------------model list?--------------> </display:column> <display:column property = "year" title = "year" /> </display:table> first of all, need make displaytag pushing value in context

ios - How to make slide out menu with out storyboard? -

first thing want tell i dont have storyboard . want make slide out menu. did slide out menu storyboard, link , in real project have no storyboard . i'm using swrevealviewcontroller . i import swrevealviewcontroller project. can me? stopped problem, have solve this you can achive using btsimplesidemenu https://github.com/balram3429/btsimplesidemenu it in objective c, using bridge can achieve easily. just import in bridge file. #import "btsimplesidemenuclass.h" then var objbtsimplesidemenuclass = btsimplesidemenuclass() // noofitems - array title , image func setupsideoutmenu() { global.sharedinstance.writetolog(optionalvalue: "") objbtsimplesidemenuclass.delegate = self let ary : nsmutablearray = [] var = 0; < noofitems.count; i++ { let item = btsimplemenuitemclass.init(title: noofitems[i].valueforkey("itemname") as! string, image: noofitems[i].valueforkey("itemimage")) { (success,

WordPress php loop over CPT comparing values to previous item in array -

i query orders , loop on them 1 bye 1 , print looks like: (only copied 1 order) dump of 1 $order array ( [0] => array ( [attractie] => wp_post object ( [id] => 41 [post_author] => 1 [post_date] => 2016-02-29 14:30:33 [post_date_gmt] => 2016-02-29 14:30:33 [post_content] => content [post_title] => title [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => post-name [to_ping] => [pinged] => [post_content_filtered] => [post_parent] => 0 [menu_order] => 0 [

angularjs - Make checkbox checked when db is updated in angular-meteor -

Image
i listing menus settings collection check box. when check menu pushed user collection menu's id. but when navigate other page or refresh page checked check box gets unchecked itself. want avoid that. here menus listed settings collection checked condition checked users collection, whether menu pushed or not. my settings collection looks this: { "_id" : "gdfahpot5fxw78aw5", "name" : "url", "description" : "https://docs.mongodb.org/manual/reference/method/db.collection.update/", "type" : "url", "tag" : "this demo of url selected", "status" : false } and user collection this: "settings" : [ { "_id" : "gdfahpot5fxw78api", "name" : "image", "description" : "uploads/images-ihdszya8xqhsgfbo5-prof.jpg", "tag" : "this de

angularjs - Create new Project in Angular-js -

i new angularjs . want create new project in angular-js . , how can create using command prompt ? have tried ng new myproject . giving error like ng new myproject ? select project blueprint: (use arrow keys) > default template ui router template own template git how can create ? this options choose. can choose between default project setup, setup ui-router configured or can provide own template git. i new anggular may should try default template. give impressions on best practices , how structure application

Extract and Create Property in JSON file with RegEx -

i have following json file . dotted across file following: "properties": { "name": "darlington", "description": "<br><br><br> <table border=\"1\" padding=\"0\"> <tr><td>ccgcode</td><td>00c</td></tr> <tr><td>ccgname_short</td><td>darlington</td></tr>" } using regex, extract ccg code property , add in above becomes: "properties": { "name": "darlington", "ccgcode": "00c", "description": "<br><br><br> <table border=\"1\" padding=\"0\"> <tr><td>ccgcode</td><td>00c</td></tr> <tr><td>ccgname_short</td><td>darlington</td></tr>" } i've tried sorts , can't work. using sublime text. ^("description":&

Writing an Activity in Xamarin and another in Android Studio released as a single apk -

i'm considering how move forward project have have use android studio (because cannot bind given .aar in xamarin). there's logical break in project write half of in xamarin (document management) leaving other half (document capture) in android/java. i wanted see if community considers normal and/or possible , how go it. presume in terms of invoking fellow activities won't huge problem - normal (for example launching system camera activity). know options bundling 2 projects single apk , specific advice before start ... i know options bundling 2 projects single apk. you can start android studio project (java). start java project android library project in android studio. archive project create aar file. once have aar ready can create java binding library project in xamarin. can find tutorial same in xamarin's documentation . java binding library , android class library project binds java library projects c# use in xamarin projects. after creating ja

parallel processing - Profiling OpenMP-parallelized C++ code -

Image
what easiest way profile c++ program parallelized openmp, on machine on 1 has no sudo rights? i recommend using intel vtune amplifier xe profiler. the basic hotspots analysis doesn't require root privileges , can install without being in sudoers. for openmp analysis it's best compile intel openmp implementation , set environment variable kmp_forkjoin_frames 1 before running profile session. enable tool visualize time regions fork point join point each parallel region. gives idea had sufficient parallelism , did not. using grid grouping frame domain / frame type / function can correlate parallel regions happening on cpus allows finding functions didn't scale. for example, imagine simple code below runs balanced work, serial work , imbalanced work calling delay() function of these making sure delay() doesn't inline. imitates real workload kinds of unfamiliar functions may invoked parallel regions making harder analyze whether parallism or bad lookin

javascript - Moongose .geoNear aggregation, add basic query options -

i using mongoose library node.js , , geonear aggregation function. here piece of code, works charm : user.geonear({ type: "point", coordinates: [geo.lon, geo.lat] }, { spherical: true, maxdistance: 50, }, function(err, results, stats) { if (err) { // handle err } } now add basic query options, such excluding documents mongodb $nin option. example, search users around given position (as did in example) constraint of not matching given ids . how possible add kind of options query ? you can with aggregation framework. try: db.collection.aggregate( [ { '$geonear': { 'near': { 'type': 'point', 'coordinates': [ -77.395410 , 38.967995 ] }, 'spherical': true, 'distancefield': 'dist', 'maxdistance': 5000 } }, { $match:{_id:{$nin: [o

Android HttpURLConnection only get info in header, not download -

i use httpurlconnection headers url: https:///abc.com//test.mp4 httpconnection = (httpurlconnection) url.openconnection(); httpconnection.setconnecttimeout(10000); httpconnection.setreadtimeout(10000); httpconnection.setrequestmethod(constants.http.get); httpconnection.setrequestproperty("user-agent", constants.user_agent); httpconnection.connect(); final int responsecode = httpconnection.getresponsecode(); // stuck , file downloaded here // logcat showing: ssl=0x6bc1ba20 sslread buf=0x428cf908 len=1500,timeo=100 many time, phone fetch many many data network. // wait long time before disconnect. httpconnection.disconnect(); // content length, header,... here how header of url without download file ? thanks

javascript - Multiple fields in PHP contact form -

i'm creating form dynamically adds additional fields necessary. how can register dynamic fields in contact forms php? also, why remove button result in error bootstrap core jquery? the form: <form action="%3c?php%20bloginfo('template_url');%20?%3e/contactengine.php" class="form-horizontal cd-form" method="post"> <div class="col-md-12"> <h3>ditt navn og adresse</h3> </div> <div class="col-md-12 medlem-form"> <div class="form-group"> <label class="col-sm-12 control-label" for="inputemail3">fornavn*</label> <div class="col-sm-12"> <input class="form-control" id="fornavn" name="fornavn" placeholder="fornavn" type="text"> </div> </div> <div class="f

Performance suggestions in R -

i have piece of code: library("go.db") lookparents <- function(x) { parents <- subset(yy[x][[1]], labels(yy[x][[1]])=="is_a") (parent in parents) { m[index,1] <<- term(x) m[index,2] <<- term(parent) m[index,3] <<- -log2(go_freq[x,1]/go_freq_all) m[index,4] <<- log2(go1_freq2[x]) m[index,5] <<- x m[index,6] <<- parent index <<- index + 1 } if (is.null(parents)) { return(c()) } else { return(parents) } } gettreemap <- function(golist, xx, m) { print(paste("input list has",length(golist), "terms", sep=" ")) count <- 1 (go in golist) { parents <- lookparents(go) if (count %% 100 == 0) { print(count) } while (length(parents) != 0) { x <- parents[1] parents <- parents[-1] parents <- c(lookparents(x), parents) } count <- count + 1 } } xx <- c(as.list(gobpancestor

Elasticsearch exact highlighting -

i want recieve highlighted text list of highlighted words, not whole text or fragments. my query percolator query: {'doc': {'field_name': text}, "highlight": { "fields": { "field_name": {} } }, 'size': 100} for example, default receive field_name: ['some text ...<em>word1</em> ... text ...<em>word2</em> text...'] i want receive: field_name: ['word1', 'word2'] how can it? i wandering how , haven't implemented yet found question on stackoverflow think help. you should able find match on "highlight" key of elasticsearch response

java - Struts2 with maven no Action mapped for namespace and action name associated with context path -

Image
although common problem cannot figure out. i running strut2 maven project. project structure given bellow product.java package beans; public class product { private int id; private string name; private float price; public int getid() { return id; } public void setid(int id) { this.id = id; } public string getname() { return name; } public void setname(string name) { this.name = name; } public float getprice() { return price; } public void setprice(float price) { this.price = price; } } productaction.java package actions; import beans.product; public class productaction{ public product getproduct() { return product; } public void setproduct(product product) { this.product = product; } private product product; public string execute(){ return "success"; } } struts.xml <?xml version="

fineuploader image uploads include caption with uploaded files -

i have legacy app has 5 separate file uploads single db record. beside each file upload there field enter caption uploaded file. i considering replacing whole lot fineuploader gallery , allow ten files uploaded. however, useful on old system have caption each image alt tag of image when comes web display. i address multiple single file uploads using fineuploader , caption field each want away having many on page. i see there option change file name during upload might option lead long/messy file names , may cause issues accents , other characters. can suggest approach? i suggest considering use built-in edit filename feature, seems appropriate me , simplest approach. another approach involves following: add file input field fine uploader template. hold user-entered caption value. need css make appropriate project. initialize fine uploader autoupload option set false . allow users enter in captions , upload files clicking button (to added later). registe

php - Is Unit Test Applicable Here? -

public function addpic($loggedinid,$picid){ $chatcoverphotoobj = new cover_photo(); $out = $chatcoverphotoobj->add($loggedinid,$picid); if($out) return true; return false; } above sample code written in php , simple add record in table cover_photo record : "picid" corresponding loggedin user identified "loggedinid". i want know should write in unit test of function. or such function should not write unit test. please suggest? firsty, if system- / class under test using infrastructural concern -which in case database- tends integration test . unit test happening in complete isolation every possible dependencies mocked/stubbed out. the first problem see in code new() dependency of function. can't test code. i suggest better invert dependency , have interface in constructor of class, can receive concrete implementation of interface. once done, can mock out database part in test. lo

php - building search query in laravel5 gives error Syntax error or access violation: 1064 -

i want implement simple search functionality in laravel5 app use db; use app\models\user; use illuminate\http\request; use connectin\http\requests; class searchcontroller extends controller { public function getresults(request $request) { $query = $request->input('name'); if (!$query) { return redirect()-> route('home') -> with('info', "search must contain charactres"); } else{ $users = user::where(db::raw("concat (first_name, ' ', last_name), "), "like", "%{$query}%") ->orwhere('username', "like", "%{$query}%") ->get(); dd('search ok' . $users); } return view('search.results'); } } with code provided above error queryexception in connection.php line 673: sqlstate[42000]: syntax error or access violation: 1064 have error in sql syntax; check m

c++ - Detection returns huge number of keypoints -

using following code (snippet of relevant parts) try perform keypoint detection opencv 2.4.11: iplimage *fiducial; cv::siftfeaturedetector siftdetector; cv::surffeaturedetector surfdetector(400); std::vector<cv::keypoint> siftkeypoints,surfkeypoints; ... siftdetector.detect(fiducial,siftkeypoints); surfdetector.detect(fiducial,surfkeypoints); after calls detect() both vectors siftkeypoints , surfkeypoints come incredibly huge number of keypoints (658812288344697520). amazingly detect() has no return value inform error , not throw exception. so...what wrong here? thanks! solved, mismatch between debug-build , release-libraries.

javascript - Display name from array in auto-complete search bar -

i trying auto-complete search bar table remedy string remedyname . here javascript have in \pages\home.html.erb $(function() { var availabletags = "<%= @remedies_remedyname%>"; $( "#autocomplete" ).autocomplete({ source: availabletags }); }); here code in pages controller def home @remedies = remedy.all end here html in /pages/home <div class="carousel-caption searchbar"> <form class="search" action="/pages/searchremedy" method="get"> <input id="autocomplete" class="searchterm" name="searchremedy" placeholder=" search treatment type, or tell you'd treat..." /> <input class="searchbutton" type="submit" placeholder="search" /> </form> </div> you printing out ruby variable @remedies_remedyname javascript. not have defined instance variable. v

c# - Automapper mapping generic types -

i have 2 generic types need map public class a<t> { public list<t> results { get; set; } public int propertya { get; set; } public int propertyb { get; set; } } and public class b<t> { public list<t> resultcontent { get; set; } public int propertyc { get; set; } } i've tried map b using automapper follows: mapper.createmap(typeof(a<>),typeof(b<>)) .formember("resultcontent", f => f.mapfrom("results")) .formember("propertyc", f => f.mapfrom(?????)) it works fine resultcontent property. however, issue b.propertyc sum of properties a.propertya , a.propertyb. possible compute mapping of properties generic types? for have use converter , resolveusing() define operation performed. see instance answer more details.

internet explorer - Svg rotation animation with css not working on ie or edge -

i'm working on animation of spinner on svg. unfortunately, i'm having trouble ie or edge. every other browser supported. here codepen: http://codepen.io/skjnldsv/pen/oxyjoq as can see opacity animation works, not rotate. there kind of prefix i'm missing, or svg support broken in ie/edge? thanks here 2 svg, first 1 not working, second 1 ok. <svg xmlns="http://www.w3.org/2000/svg" height="50" width="50"> <style> .spinner { transform-origin: 25px 25px; -webkit-transform-origin: 25px 25px; animation: loading-spin .8s infinite linear; -webkit-animation: loading-spin .8s infinite linear } @-webkit-keyframes loading-spin { 100% { -webkit-transform: rotate(360deg); } } @keyframes loading-spin { 100% { transform: rotate(360deg); } } </style> <defs> <clippath id="a"&

Yellow highlight while using custom Toast in android -

i trying implement custom toast , below code wrote , hooked onclickelistner asusual button customtoastbutton = (button) this.findviewbyid(r.id.add_to_cart); customtoastbutton.setonclicklistener(new view.onclicklistener() { public void onclick(view v) { //get layoutinflater , inflate custom_toast layout layoutinflater inflater = getlayoutinflater(); view layout = inflater.inflate(r.layout.cart_toast, (viewgroup) findviewbyid(r.id.toast_layout_root)); //get textview custom_toast layout textview text = (textview) layout.findviewbyid(r.id.toasttext); text.settext("item been added cart"); //create toast object, set display duration, //set view layout that's inflated above , call show() toast t = new toast(getapplicationcontext()); t.setduration(toast.length_short);