Posts

Showing posts from July, 2011

java - How does all annotations work in TestNg without main() method -

i have doubt in testng java. completly new testng. doubt is, how test cases executing using testng in java without having main() method? please suggest me if have ideas. following code example of sample test case using testng in java. if notice, can find 1 thing there no main() method in code. then, how testcases executing? i have doubt. main() method needed selenium webdriver , testng combination execute script? or can execute testcases without main() method? if can execute testcases without main(), how possible? package com.first.example; import org.testng.annotations.test; public class demoone { @test public void firsttestcase() { system.out.println("im in first test case demoone class"); } @test public void secondtestcase() { system.out.println("im in second test case demoone class"); } } this valid doubt many testers have. because main() method needed run java program , while writing tests in tes...

sql - Can you have a foreign table name like a foreign key? -

i'm playing ideas. want foreign key want table key should used in row. foreign keys can refer different tables. you'd returning 1 result given query needed dereference 'pointer'. i know store table name , use 2 select statements it, inserting result of first select table , key next call index right table, can done single select on database? sql like? edit: let me see if can come example. mediatable id | name | owner| type | fkey mp3 id | artist | album | title | bitrate | codec | data movie id | title | resolution | imdburl | audiocodec | videocodec | data ok contrived ... leta want search mediatable titles (in mp3 or movie tables) mediatable.owner = "ekl" assuming fkey foreign key of id field. can "mediatable.type" select table fkey should apply to? yes, know not best way particular example, easier explaining 2 larger projects want this. basically, want parameterise foreign key , add table refer. theoretically, can ...

node.js - Easy way to reference Documents in Mongoose -

in application have user collection. many of other collections have author (an author contains user._id , user.name), example post collection. since need _id , name display e.g. posts on ui. this works fine, , seems approach, since everytime deal posts don`t have load whole user object database - can load post.author.userid/post.author.name. now problem: user changes or name. author objects scattered around in database still have old author. questions: is approuch solid, or should reference userid everywhere need it? if i'd go solution i'd remove author model , need make user database call everytime want display current users`s name. if leave author is, way implement solution situations user.name change? i write service checks every model has authors of current user._id , updates them of course, sounds tedious. although i'm not sure there's better solution. any pro tipps on how should deal problems in future? yes, sometime databa...

sql server - SQL - select data that have dates greater than a month in a year -

i have table called quiz , has 3 columns: enteryear entermonth quizmark 2013 7 9.5 2013 8 8.5 2013 9 9.75 2013 10 10 2013 11 7.75 2013 12 8.5 2014 1 5 2014 2 8.75 2014 3 10 now, want select entries enter after sept. of 2013 (including sept). tried wrong: select * quiz q q.year>=2013 , q.month>=9 this omitted entries in 2014 since months less 9, want them in result since after sept. of 2013. so then, tried this select * quiz q convert(date, cast(q.year varchar(4))+'/'+cast(q.month varchar(2))+'/01')>='2013/9/01' which showed result half second , disappeared giving error message: msg 241, level 16, state 1, line 1 conversion failed when converting date and/or time character string." can correct code achieve result, appreciated! ...

python - Fast basic linear algebra in Cython for recurrent calls -

i'm trying program function in cython monte-carlo simulation. function involves multiple small linear algebra operations, dot products , matrix inversions. function being called hundred of thousands of times numpy overhead getting large share of cost. 3 years ago 1 asked question: calling dot products , linear algebra operations in cython? have tried use recommendations both answers, first scipy.linalg.blas still goes through python wrapper , i'm not getting improvements. second, using gsl wrapper slow , tends freeze system when dimensions of vectors large. found ceygen package, looked promising seems installation file broke in last cython update. on other hand saw scipy working on cython wrapper lapack, looks still unavailable ( scipy-cython-lapack) in end can code own c routines operations seems kind of re-inventing wheel. so summarize: there new way kind of operations in cython? (hence don't think duplicate) or have found better way deal sort of problem haven...

php - How to Update Two table Data one after other In codeigniter? -

Image
how update plan vendor_plan_task_status_mapp table. the model plan update public function updateplandata(){ $planid = $this->input->post('plan_id'); $data = array( 'plan_title' => $this->input->post('plan_title'), 'plan_price' => $this->input->post('plan_price'), 'plan_desc' => $this->input->post('plan_desc') ); $this->db->where('plan_id', $planid); $this->db->update('tbl_plan', $data); $this->db->where('plan_id',$planid); $this->db->delete('plan_task_mapping'); foreach ($this->input->post('task_id') $key => $value) { $data2 = array( 'plan_id' => $planid, 'task_id' => $value ); // echo "index {$key}'s value {$value}."; ...

freeze - Visual Studio 2010, HP Fortify freezing -

Image
i've run hp fortify scan on large project of approximately 500k lines of code appears stuck on "loading issues" modal no further progress 12 hours. i can see analysis results listing items under critical , high, because "loading issues" modal not completing, cant them. do know why happening , how can resolved ?

ios - How to create a singleton class in swift? -

this question has answer here: using dispatch_once singleton model in swift 27 answers i need create singleton class in swift. can me code? know singleton classes helpful in creating generic code. class singleton { static let sharedinstance = singleton() }

java - Differences between Infrared signals transmitting with Android 5.0 and 5.1 -

i trying develop remote control app on android. have tested app samsung galaxy s5 running on android 5.0 , worked intended. however, ran problems while testing on samsung galaxy s6 edges running android 5.1. the pattern trying send is: new int[] {8700, 4320, 560, 520, 560, 500, 560, 500, 560, 520, 540, 1600, 560, 520, 540, 520, 560, 500, 560, 1600, 560, 1600, 560, 1600, 560, 1600, 560, 500, 560, 1600, 560, 1600, 560, 1600, 560, 1640, 520, 1600, 560, 1600, 560, 1600, 560, 1600, 560, 500, 560, 500, 560, 520, 560, 500, 560, 500, 560, 500, 560, 520, 540, 520, 560, 1600, 560, 1600, 560, 1600, 560, 39080, 8660, 2140, 560, 39080} here readings arduino: actual remote: {8700, 4320, 580, 480, 560, 500, 580, 480, 560, 520, 540, 1600,...} samsung s5 (5.0): {8720, 4260, 600, 460, 580, 420, 620, 460, 500, 540, 560, 1560,...} samsung s6 edge (5.1): {8300, 4180, 500, 560, 460, 500, 500, 520, 500, 540, 480, 1600, ...} based on reading, have noticed duration on pulse shorter whi...

How to add xml-stylesheet tag to XML file using python? -

i'm trying add xml-stylesheet tag in front of existing xml file using python. eg. i'm trying add <?xml-stylesheet type="text/xsl" href="audit_stylesheet.xsl" ?> to beginning of xml file. if change line to "<?xml-stylesheet type=\"text/xsl\" href=\"audit_stylesheet.xsl\" ?>" and use https://stackoverflow.com/a/5917395/4843078 should go

php - Mysqli Retrieve data and display them - best way -

which 1 of options below better option 1: //control file: $smpt = $con->query("select id,name customers"); //fetch resuts $results = array(); while ($row = $result->fetch_assoc()) { $results[] = $row; } $smpt->close(); //note: php version < 5.3.0 can't use $results->fetch_all('mysqli_assoc'); //view file: foreach($results $key=>$value) { //display results } unset($results); option 2: //control file: $smpt = $con->query("select id,name customers"); //fetch resluts //view file: while($row = $result->fetch_assoc()) { //display results } $smpt->close(); i trying separate logic presentation... current using option 2 because option 1 script go through 2 loops. 1 fetch data , other display them. 1 better use? thanks option 1 allows re-use $data variable can display results twice, cost of potentially have large amount of data stored in variable. can clear using unset($data) once 100% ...

Ruby - Hash - Combination -

i have hash 5 elements, instance: my_hash = {a: 'qwe', b: 'zcx', c: 'dss', d: 'ccc', e: 'www' } my goal return every time in loop hash without 1 element like: my_hash = {a: 'qwe', b: 'zcx', c: 'dss', d: 'ccc' } then my_hash = {a: 'qwe', b: 'zcx', c: 'dss', e: 'www' } and on using array use combination method when use hash? possible you can convert array , convert hash later: my_hash.to_a.combination(4).to_a.sample.to_h # => {:a=>"qwe", :b=>"zcx", :c=>"dss", :e=>"www"} my_hash.to_a.combination(4).to_a.sample.to_h # => {:a=>"qwe", :c=>"dss", :d=>"ccc", :e=>"www"}

How to compare lines in data (.csv) file based on two values, then roll-up the data using Python? -

i have .csv file has 25 columns. in data, column 18 people_id, , column 19 donation date. have pre-sorted data using linux people id's appear together, sorted donation date in descending order. here i'm not sure how proceed. need find lines have same people_id , donation date, sum various values, , output single line output. essentially, every line in file either different customer, or different donation date same customer. best use dictionary using people_id key? how syntactically? i thinking this: with open("file.csv") csv_file: row in csv.reader(csv_file, delimiter=','): if row[18] in data_dict: # something i'd recommend object-oriented approach. import csv class transaction: def __init__(self, fields): self.name, self.age, self.car, self.ident = fields # whatever fields have # keep in mind these strings, # may need process them before analysis def calculation(self): return ...

merge - rename the multiple columns in R -

i have 1000 files column similar column names.for example : df1 date price close df2 date price close and on... if try merge them based date merge columns have retained old names , want rename them in loop so merge data set looks date price close price close i want like date price1 close1 price2 close2. is there easy way it? have tried couple of things not giving me correct output this using plyr package: mod_join = function(mypath){ filenames=list.files(path=mypath, full.names=true) datalist = lapply(filenames, function(x){read.csv(file=x,header=t)[,c('date','high','low')]}) join_all(datalist,by = "date") } this using merge command on data frame: merge2 = function(mypath){ filenames=list.files(path=mypath, full.names=true) datalist = lapply(filenames, function(x){read.csv(file=x,header=t)[,c('date','high','low')]}) reduce(function(x,y) {merge(x,y,by.x...

android - Overlap ViewPager tabs with a RelativeLayout -

Image
i have activity contains viewpager 2 tabs. when user presses button, want opaque relativelayout overlay appear user can select different options. the problem overlay not overlap viewpager's tabs , instead stops short. my xml: <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <relativelayout android:layout_width="match_parent" android:layout_height="match_parent"> <linearlayout android:id="@+id/footer" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_alignparentbottom="true" android:background="@color/light_gray" > <textview ..../> ...

java - Tokenize Timestamp with jFlex and handle ISO format -

i trying solve date tokenization issue various date format, , 1 of them maybe in iso8601 format, using 't' delimiter. , want able know character 't' timestamp when has digit preceding , following it. for instance, if have array string[] timestamp = {"time: 12/45/60", "2015-07-13t05:30:59"} i want splitted result of (time) (:) (12) (/) (45) (/) (60) (2015) (-) (07) (-) (13) (t) (05) (:) (30) (:) (59) i using jflex make tokenizer, , wrote .flex file such: %% %class lexer specialt = (\dt\d) parameter = [:jletterdigit:]+ delimiter = [^a-za-z0-9]|{specialt} %% [:digit:]+ {return new datetoken(yytext(), "int");} {delimiter} {return new datetoken(yytext(), "delimiter");} {parameter} {return new datetoken(yytext(), "text");} however, tokenizer parse out symbols, not 't'. has suggestions? thank much. it works me, or rather works grammar describes things. ...

actionscript 3 - Access of undefined propety and other errors (AS3) -

ok trying work on making scripts external .as files. had them on timeline , worked fine when put them in file don't work @ all. code of right now so got script working externally thank :) need addchild stage. use import scripts.resources.main; var main:main = new main; addchild(main); in external script addchild in main function now. package scripts.resources { import flash.events.event; import flash.events.mouseevent; import flash.net.urlrequest; import flash.net.urlvariables; import flash.net.urlloader; import flash.net.urlrequestmethod; import flash.events.outputprogressevent; import flash.display.sprite; import flash.display.movieclip; import flash.display.stage; import flash.events.eventdispatcher; public class main extends eventdispatcher{ private var _stage:stage; var url:string = "php/data_user.php"; //declare our graphic vars var stmbar:resourcebar; var tenbar:resourcebar; var potbar:resourcebar; var spdbar:resourcebar...

java - Why can't take Annotation on a Field together with getField() and setField()? -

example throw exception below, example b successful. why can't take annotation on field getfield() , setfield() ? pojo should have field, get() , set() . com.sun.xml.internal.bind.v2.runtime.illegalannotationsexception: 1 counts of illegalannotationexceptions class has 2 properties of same name "wodogname" problem related following location: @ public java.lang.string wodog.pojo.wodog.getwodogname() @ wodog.pojo.wodog problem related following location: @ private java.lang.string wodog.pojo.wodog.wodogname @ wodog.pojo.wodog example a: @xmlelement(name = "wodogname") private string wodogname; public string getwodogname() { return wodogname; } public void setwodogname(string wodogname) { this.wodogname = wodogname; } example b: @xmlelement(name = "wodogname") private string wodogname; public void setwodogname(string wodogname) { this.wodogname = wodogname; } you have an...

python - How to convert Django's TimeField to Postgres' timestamp with time zone -

in django app, program gets time of event user, user inputs 10:30 time of event. program uses modelformset_factory create whole bunch of forms: #forms.py class eventform(modelform): class meta: model = event fields = ['entry', 'time', 'work'] localized_fields = ('time', ) widgets = { 'work': textarea(attrs = {'cols': 40, 'rows': 8}), } #models.py class event(models.model): ''' each day there many events, e.g. @ 10 am, framer orders material, etc. ''' entry = models.foreignkey(entry) time = models.timefield() work = models.textfield() #views.py: eventformset = modelformset_factory( event, form = eventform, exclude = ('entry',),extra = 5) eventset = self.eventformset(request.post) all_errors = eventset.errors # errors returns [{}, {}, {}, {}, {}], data free of error. try: eventset.is_valid() excep...

java Array assignment slowly than List.add() -

package test; import java.util.arraylist; import java.util.list; public class arrayandlist { public static void main(string[] args) { int num = 10000000; integer[] marray = new integer[num]; list<integer> mlist = new arraylist<>(num); // array init test long icurr = system.currenttimemillis(); (int = 0; < num; i++) { marray[i] = i; } system.out.println("array init:" + (system.currenttimemillis() - icurr)); // list init test icurr = system.currenttimemillis(); (int = 0; < num; i++) { mlist.add(i); } system.out.println("list init:" + (system.currenttimemillis() - icurr)); // array test long mextimestamp = system.currenttimemillis(); long r1 = 0; (int = 0; < num; i++) { r1 += marray[i]; } system.out.println("array get:" + (system.currentti...

javascript - Retrieve data from server with SSE named something else than "data:" -

so i'm writing basic custom jquery plugin handle animating progress bars based on server-sent events (as now: plan on handling websocket , long-polling ajax too). i'm willing know if there way data sent server named differently. until now, have read server must output like: header('content-type: text/event-stream'); header('cache-control: no-cache'); for($i = 0; $i < 100; $i++) { echo 'data:'.$i."\n\n"; // must data: , not else! flush(); sleep(1); } so can retrieved using var stream = new eventsource('/api'); stream.onmessage = function(e) { console.log(e.data); // outputs $i sent server every second } therefore, i'm wondering data sent server has named data: read client-side or can have name? (and read client-side e.anothername ). not go towards creating json object server-side complicate manually setting plugin. the purpose behind is, in order make progress bar progress, need percentage can ...

javascript - Remove image on image click -

demo here i want remove image , not whole div on clicking cross button. took reference here. $('.remove-img').click(function(e) { $( ).parent().remove(); }); traverse parent() .find() image excluding current image. can use remove() use $('.remove-img').click(function (e) { $(this).parent().find('img').not(this).remove(); //if want remove images //$(this).parent().find('img').remove(); }); demo

java - Efficient way to modify a list of objects using maps -

i have list of objects, these objects can shift position in list or removed, object saving, each of them have unique id, lets call id "key". check membership in list have additional map mapped <object.getkey(), object> currently call method key, , map.contains(key) // delete list.remove(map.get(key)) // edit object oldobj = list.get(map.get(key)) // modify old obj, immutable need set // old position new object list.set(map.get(key), newobject) for sure code shit, not able wrap head around clean solution this, want avoid o(n) searches on list happening in case of list.remove , list.get! one of solutions think of map key list position in case map has delete operation or insert operation i'd have update whole map position of change! again o(n). suggestions on efficient way this? you haven't specified need list, assuming you're looking collection predictable order, consider using linkedhashset - retains order of insertion while stile al...

c - FFTW real-to-real transform strided array -

Image
i have matrix stored in row-major order. trying compute dct of ub-matrix using fftw, , nonsense. in following paragraphs describe problem , solution, , in understanding why not work. given i , l , compute dct of sub-matrix consists of rows k k mod l == i . example, assume l = 3 , i = 2 . in following matrix, sub-matrix wish transform marked in red (2 mod 3 = 2, 5 mod 3 = 2, 8 mod 3 = 2). the source , destination arrays have same layout, , transformed matrix should stored in same location in destination array. void transform(double* src, double* dest, size_t rows, size_t cols, size_t l, size_t i) { int rank = 2; fftw_iodim64 dims[] = { { rows / l, l, l }, { cols, rows, rows } }; fftw_r2r_kind kind = fftw_redft10; fftw_plan plan = fftw_plan_guru64_r2r(rank, dims, 0, null, src + l, dest + l, &kind, fftw_estimate | fftw_unaligned | fftw_preserve_input); fftw_execute(plan); fftw_destroy_plan(pla); } update i tested simple case ...

javascript - API search help JSON/PHP -

first i'm new json , php. i'm sorry if question simple. alright, using movies json api , except 1 thing, the url request search query : /api/movies.json?search='then search here' did in file_get_content('/api/movies.json?search='.$search_movie); i'm trying add search input , button once pressed change search_movie variable whats inside input , refresh page. how can or there better way ? i recommend using guzzle this. extremely easy use , if ever want more advanced functionality available you. here nice article describing step step how started: http://www.sitepoint.com/guzzle-php-http-client/ .

c++ - Error deploying QT project with Qwt -

i'm deploying qt project windows machine , worked fine. yesterday add qwt library project , when deploy executable won't start giving error (on qtcreator works fine) the procedure entry point ?staticmetaobject@qgraphicseffect@@2uqmetaobject@@b not located in dynamic link library qt5widgets.dll i think included needed library. i've tried use windeployqt , i've included defines += qwt_dll on top of .pro file read here still give me error. maybe miss dependent dll. have idea on how resolve this? i had same issue. couldn't understand dependency walker, working apps showed missing dlls. i used qwt in program , compiled in qt 5.5 msvc2013 32bit on 64bit windows 10. after changing 'qt' folder name 'qthidden', sugested here , attempted application run dlls in same folder , getting weird error qwt you, althouth had added qwt.dll. to working did following: copied dlls in qthidden/5.5/mingw492_32/bin deploying folder ...

java - Maven not downloading dependencies in Eclipse -

Image
i setting project in eclipse . projects builds through command line(all mvn commands mvn package , mvn compile , mvn clean install ) work fine. while setting project on sts or eclipse . see of dependencies not getting downloaded though present in pom.xml . however, searching them in maven repository , downloading jar local computer , adding them build path makes work on eclipse. is there need eclipse make sure downloads dependencies repository. my pom : <dependency> <groupid>org.apache.bookkeeper</groupid> <artifactid>bookkeeper-server-compat410</artifactid> <version>4.1.0</version> <scope>test</scope> <exclusions> <exclusion> <groupid>org.apache.bookkeeper</groupid> <artifactid>bookkeeper-server</artifactid> </exclusion> </exclusions> </dependency> <dependency> <groupid>org.apache.bookkeep...

javascript - how to get the text from an editable <td> from user input? -

i trying make game here, , i'm still @ 10% of game far. called "sos" familiar? tic tac toe not "x" & "o" "s" , "o" in 5x5, , ill using javascript. have editable td's <table id="mytable" border="1" style="border-collapse: collapse; width:30%;" cellpadding="8"> <!-- 1st row --> <tr> <td contenteditable="true"></td> <td contenteditable="true"></td> <td contenteditable="true"></td> <td contenteditable="true"></td> <td contenteditable="true"></td> </tr> <!-- 2nd row --> <tr> <td contenteditable=...

.htaccess: how to restrict access to specific images from my mobile site -

for mobile site want restrict access of images "lady bug.gif" "bluemoon.gif" etc. these images won't shown in http://m.mysite.org faster , less clutter mobile experience. how can this? not working example: rewriteengine on <files bluemoon.gif> order allow,deny deny </files> i think better off internally rewriting small 1px image, rather blocking access. if block access (404, 403, etc) end errors in front end. options +followsymlinks rewriteengine on rewritecond %{http_host} =m.mysite.org rewriterule (lady\sbug|bluemoon)\.gif$ /images/mobile-placeholder.gif [l] note if have spaces in filenames need replace these \s in rewriterule pattern (a regular expression) - above.

ios - AlertController appears twice when saving video -

here code: let library = alassetslibrary() library.writevideoatpathtosavedphotosalbum(nsurl(string: path), completionblock: { (url, error) -> void in if error != nil { let error = uialertcontroller(title: "error!", message: "your video not saved!", preferredstyle: uialertcontrollerstyle.alert) error.addaction(uialertaction(title: "shit!", style: uialertactionstyle.default,handler: { action in navigationcontroller!.popviewcontrolleranimated(true) })) self.presentviewcontroller(error, animated: true, completion: nil) } else { let alertcontroller = uialertcontroller(title: "done!", message: "your video saved!", preferredstyle: uialertcontrollerstyle.alert) alertcontroller.addaction(uialertaction(title: ...

java - How to register a servlet with enabled "async-supported" in Spring-Boot? -

i'm planing migrate old app spring-boot. want stop using web.xml descriptor , register old pure servlet ("async-supported" enabled) , associated servletcontextlistener. spring boot automatically register servlet beans in application context servlet container. default async supported set true there's nothing beyond creating bean servlet . if, whatever reason, want take more control on servlet's registration, then, rather exposing servlet bean, can wrap in servletregistrationbean .

javascript - Extracting arguments using regular expressions -

i'm trying use regex extract arguments function definition array. example func(a) -> ['a'] func(a,b) -> ['a','b'] func(a, b) -> ['a','b'] the regex below correctly matches arguments block /\((?:(\w+),?\s*)+\)/ however, last matched capturing group returned i.e. results are: func(a) -> ['a'] func(a,b) -> ['b'] func(a,b,c) -> ['c'] this seems useful pattern capturing part of repeating unit. there way correctly achieve expected result? my saved regexr session can found here the regex /\((\w+(?:,\s?\w+)?)\)/ return a, b func(a, b) , a,b,c func(a,b,c) hopefully wanted, depending on language you're doing for, can split them each , put them array indexing later.

java - CDI: Interface from jar cannot be resolved as Local Wildfly 8.0 -

i trying migrate existing java 7 application jboss 7.1 wildfly 8.0 , facing problems cdi. the structure of project following: ear | |--> base.service.impl.war |--> mad.impl.war --> contains sessionserviceimpl.class |--> lib | |-> base.api.jar |-> base.api.impl.jar --> contains sessionservice.class sessionservice plain java interface no annotations. sessionserviceimpl looks this: @stateless @ejb(name = sessionservice.jndi_name, beaninterface = sessionservice.class) public class sessionserviceimpl implements sessionservice { } the ejb seems registered: info [org.jboss.as.ejb3.deployment.processors.ejbjndibindingsdeploymentunitprocessor] (msc service thread 1-1) jndi bindings session bean named sessionserviceimpl in deployment unit subdeployment "com.mad.impl.war" of deployment "com.deployment.ear.ear" follows: java:global/com.server.deployment.ear/com.mad.impl/sessionserviceimpl!com.b...

python 2.7 - SUDS - How to get a top level tag attribute -

i have structure in results of command test = client.service.xxx <soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:header /> <soapenv:body> <n:statusresponse xmlns:n="http://www.abcdefg/tatatata.xsd" n:result="0"> <n:id /> <n:seqno /> <n:user /> <status> <n:code>1</n:code> <devstatus n:devid="1" n:val="0" n:st="1000" /> <devstatus n:devid="2" n:val="0" n:st="1000" /> </status> </n:statusresponse> </soapenv:body> </soapenv:envelope> if set on log logging logging.basicconfig(level=logging.info) logging.getlogger('suds.transport').setlevel(logging.debug) i found: <soapenv:envelop...

node.js - Uncaught Error: Cannot find module 'cheerio' Nodewebkit -

i trying develop node webkit application , trying use cheerio library. have imported using var cheerio = require("cheerio"); however when run program, following error: uncaught error: cannot find module 'cheerio' module.js:329 my node_modules folder contains cheerio folder , have included in package.json file well. tried installing cheerio globally , face error.

ios - Load while push to another viewController -

when push detail viewcontroller after clicking collectionview cell take time load detailview controller. mainviewcontroller.m -(void)collectionview:(uicollectionview *)collectionview didselectitematindexpath:(nsindexpath *)indexpath{ detailviewcontroller *objdetailviewcontroller = [self.storyboard instantiateviewcontrollerwithidentifier:@"detailviewcontroller"]; objdetailviewcontroller.objproduct = [arrlist objectatindex:indexpath.row]; [self.navigationcontroller pushviewcontroller:objdetailviewcontroller animated:yes]; } detailviewconteroller.m - (void)viewdidload { [super viewdidload]; [self setinitialvalues]; [self productdetailapi];//ws call } is api call running on main thread? should make network calls on background thread not block ui thread.

c# - identify if excel cell has more than 2 decimal places -

Image
i have multiple excel files, need create small tool(c#) need create log file tell, excel file , cell has more 2 decimal places in it. possible highlight on excel cell has more 2 decimal places yes it's possible, tried iterate through active(cell has value) cells microsoft.office.interop.excel.application excel = new microsoft.office.interop.excel.application(); workbook wb = excel.workbooks.open(path); worksheet excelsheet = wb.activesheet; var test = excelsheet.cells[x, y].value.tostring(); int chk = getdecimalcount(decimal.parse(test)); tool ready

c++ - Find a single approximating boundary for multiple objects in binary image -

Image
an example case of image given below. use binary version of image further processing. contour of object perform shape matching. have written code returns boundary contour given binary image. however, problem arises when image not contain 1 single object case here, can see lower portion of leg palm not attached body. interested in finding contour approximating entire object. so, far opencv has not helped. my contour function using opencvblobslib library , looks this. detects blobs , filters out small blobs. then, checks see if there 1 contour left. works long objects connected, make robust can handle multiple object case well. vector<point> getcontour(mat binaryimg) { cblobresult res(binaryimg, mat(),numcores); // possible bounding box using object cblobresult resfiltered; // shall filter bboxes if area less // alpha % of total area double originalimagearea = binaryimg.rows * binaryimg.co...

Bootstrap media object cannot align properly -

Image
i using bootstrap 3 media objects , have code here dynamically want have 4 columns in 1 row,but problem last row have spaces inbetween second row. here code. //content.php for(var i=0;i<12;i++){ mymdedia+= '<div class="media col-sm-3">'+ '<div class="media-left">'+ '<a href="#">'+ '<img src=".....">'+ '</a>'+ '</div>'+ '<div class="media-body">'+ '<h4 class="media-heading">'john doe'</h4>'+ '<p>live: '+data[i].address+'</p>'+ '</div>'+ '</div>'; ...

ruby on rails - Hutch & RabbitMQ: set timeout on re-queued messages -

when hutch consumer loses connection database requeue messages got , try handle (and save db) them later. i found can use requeue! method in consumer: def process(message) handle_message(message) rescue activerecord::connectionnotestablished => error rails.logger.warn("connection database broken: #{error}") requeue! ensure ::activerecord::base.clear_active_connections! end end but message instantly rabbit, , so, consumer stuck in trying process message when it's can't saved db. is possible put timeout on either hutch or rabbitmq site in situation? as answered here https://github.com/gocardless/hutch/issues/161 not without using scheduled delivery exchange , or abusing ttl , dead lettering.

How to parse /proc/cpuinfo on any linux distro in C -

i running ubuntu , don't understand why it's hard me number of cores on system in c! i've tried parsing /proc/cpuinfo success on system running ubuntu tried on system running arch linux fail because buffer small, , can't seem figure out how make work on both of systems. #include <stdio.h> #include <stdlib.h> int main() { file* fp; char *buffer, *tmp; size_t bytes_read, size; if((fp = fopen("/proc/cpuinfo", "r")) == null) { perror("open failed"); exit(exit_failure); } size = 1024; if((buffer = malloc(size)) == null) { perror("malloc failed"); free(buffer); exit(exit_failure); } while(!feof(fp)) { bytes_read = fread(buffer, 1, size, fp); if(bytes_read == size) { size += 128; if((tmp = realloc(buffer, size)) == null) { perror("realloc failed"); free(buffer); exit(exit_failure); }else { buffer = tmp; ...

jquery - Multiple date selecte in single input field? -

i want create date picker calender . having option select multiple dates single input field . please me if have before. <script> var drp; function makedatepicker(){ drp = $("#mydate").datepicker({}); } function getrange(){ $("#myoutput").html(""); $(drp.getdaterange()).each(function() { $("#myoutput").append($("<li>").html($.datepicker.formatdate("dd/mm/yy",this))); }); } $( document ).ready(function() { makedatepicker(); }); </script> thanks to select multiple date 1 input can use datepick.js allow select multiple date @ time. here link demo , download to see demo multiple date select click on "multiple" tab on this page you can select multiple dates using : <input type="text" id="multi999picker" size="60" class="is-datepick"> $('#multi...

php - How to relate SQL tables -

i have 2 tables want check data perform respective tasks according has been got. scenario tables jobs applications what want achieve is, if job, job1 has been applied user1, should stored in applications table. if user1 tries apply same job(job1), user1 should notified has applied job. want on how can go using php , sql i understand want achieve hard write entire code you.so going show direction on how go it.you need stored procedure following : checks if user has applied job : select count(applicationid) tblapplication userid=@userid && jobid=@jobid if(count >0) throw exception else insert... end this gives outline.do research on stored procedures first.

javascript - How to hide overflow characters of a div when resizing -

Image
this question has answer here: overflow:hidden dots @ end 5 answers i have few div elements, want hide overflow characters when div resizing this how every time resize page. can css? just add following css div contains text: div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } this add 3 dots @ end of line whenever text longer div. note: works 1 line text.

javascript - JQuery - Show/hide 2 divs with 1 button and change value of button -

i've trying make when click button hide 1 div , show @ same time change value of button reflect different content of divs. i've been able create 2 functions when put them seems break. here's show/hide function javascript : function change() { if (document.getelementbyid('tabs')) { if (document.getelementbyid('tabs').style.display == 'none') { document.getelementbyid('tabs').style.display = 'block'; document.getelementbyid('parklist').style.display = 'none';} else { document.getelementbyid('tabs').style.display = 'none'; document.getelementbyid('parklist').style.display = 'block';} } } and here's value change function javascript: function change( el ) { if ( el.value === "div1" ) el.value = "div2"; else el.value = "div1"; } and here's html both html...

c# - How can I run an application that depends on a SQL database on another machine with SQL Server? -

i have created crud application running well. connects sql on same machine. want publish c# app , install on pc not have sql. is possible run on pc, without installing sql server on it? if so, how do this? is possible run on pc? without database application "dead". you have 2 options. install sql server pc. connect sql server isntalled in pc. it's choice.

c++ - Is there a way to detect inline function ODR violations? -

so have code in 2 separate translation units: // a.cpp #include <stdio.h> inline int func() { return 5; } int proxy(); int main() { printf("%d", func() + proxy()); } // b.cpp inline int func() { return 6; } int proxy() { return func(); } when compiled result 10 . when compiled -o3 (inlining on) 11 . i have done odr violation func() . it showed when started merging sources of different dll's fewer dll's. i have tried: gcc 5.1 -wodr (which requires -flto ) gold linker -detect-odr-violations setting asan_options=detect_odr_violation=1 before running instrumented binary address sanitizer. asan can supposedly catch other odr violations (global vars different types or that...) this nasty c++ issue , amazed there isn't reliable tooling detecting it. pherhaps have misused 1 of tools tried? or there different tool this? edit : the problem remains unnoticed when make 2 implementations of func() drastically different don't compile...

ios - How to vertical align (center) the content of UITableView? -

i want center content of uitableview contains headerview , footerview created @ storyboard, , uitableviewcell s. how can achieve this? here i'm trying implement solve problem not work. - (void)viewwillappear:(bool)animated { [super viewwillappear:animated]; cgfloat height = self.tableview.frameheight - self.navigationcontroller.navigationbar.frameheight - [uiapplication sharedapplication].statusbarframe.size.height - (self.rowcount * self.rowheight); self.tableview.tableheaderview.frameheight = height / 2.0; } so subtracted height of navigationbar & statusbar , cells' height tableview's height height of empty area. height if empty area, divided 2 footer , header's view. in viewwillappear , in didrotatefrominterfaceorientation functions : cgfloat headerheight = (self.view.frame.size.height - (row_height * [self.tableview numberofrowsinsection:0]))) / 2; self.tableview.contentinset = uiedgeinsetsmake(headerheight, 0, -headerheight...

javascript - call to functiolity just one time in node js -

there method need run once when node application started ,i think put in server.js executable file application im not sure right way go,which other option can use in case? depending on when it's required run, may suitable put function separate javascript file, , execute part of npm start script within package.json ? based on comment below stating child process. appropriate execute server file, best practice abstract function out separate file, require server file , call it.

c# - Can't build in visual studio 2015 because 'Microsoft.Build.Tasks.v14.0.dll' cannot be found -

when attempting build in visual studio 2015, following file missing? project being built in vs2013. severity code description project file line error task factory "codetaskfactory" not loaded assembly "c:\program files (x86)\msbuild\14.0\bin\microsoft.build.tasks.v14.0.dll". not load file or assembly 'file:///c:\program files (x86)\msbuild\14.0\bin\microsoft.build.tasks.v14.0.dll' or 1 of dependencies. system cannot find file specified. the assembly has been renamed. change on codetaskfactory msbuild task assemblyfile parameter to...(in error there should targets file name task resides) assemblyfile="c:\program files (x86)\msbuild\14.0\bin\microsoft.build.tasks.core.dll" chances tried clever , use msbuild property this..(which doesn't work msbuild 14 12)... assemblyfile="$(msbuildtoolspath)\microsoft.build.tasks.v$(msbuildtoolsversion).dll" just fyi...there others such microsoft.build....

php - In magento 1.9.0.1 in checkout payment Information is not working -

i unable proceed payment information. when click on continue in 1 step checkout though added fieldset id. var payment = new payment('co-payment-form', '<?php echo $this->geturl('checkout/onestep/savepayment') ?>'); var onestep = new onestep( '<?php echo $this->geturl('checkout/onepage/savecart') ?>', '<?php echo $this->geturl('checkout/onepage/success') ?>', 'checkoutsteps'); u better go onepage checkout settings more options such shipping multi addresses , changing delivery address while doing payment...if doing onepage checkout means have copy files frontend/base/default path , there need modify content .