Posts

Showing posts from January, 2013

spring - Thread safety with @Scheduled and @Async, Java -

i took code: private queue<object> myqueue = new concurrentlinkedqueue(); public enqueue(object obj) { myqueue.add(obj); } @scheduled(fixedrate=1000) public void publish() { final list objstopublish = lists.newarraylist(); final int listsize = myqueue.size(); (int = 0; < listsize; i++) { objstopublish.add(myqueue.poll()); } expensivewriteoperation(objstopublish); } however, it's problem if publish() takes away control during other operations running in software, tried make expensive call asynchronous, so: private queue<object> myqueue = new concurrentlinkedqueue(); public enqueue(object obj) { myqueue.add(obj); } @scheduled(fixedrate=1000) public void publish() { final list objstopublish = lists.newarraylist(); final int listsize = myqueue.size(); (int = 0; < listsize; i++) { objstopublish.add(myqueue.poll()); } work(objstopublish); } @async void work(list objstopublish) { expensivewriteoperation(objstopublish);...

Difficulty using set/endlocal in Batch across files -

i'm trying call 1 bat file another, while keeping target variables local itself(mostly). code below failed attempt, var want missing, local still around. i've found info on using setlocal here , how think have it. info i'm using push var past setlocal here . it's possible i'm missing these. appreciated! the calling bat: @set errmsg=old message @call target.bat test_job errmsg @echo.jobname = %jobname%, should undefined @if defined errmsg echo.error occurred: %errorlevel% %errmsg% the target bat: @setlocal @echo off :start set jobname=%~1 set errmsgvar=%~2 :main call:error "new error message" echo.should have never returned here endlocal :exit @echo on @exit /b %errorlevel% :error "errormesage" endlocal & set "%errmsgvar%=%~1" echo.%errmsg% ^<-- testing only, don't know actual var (goto) 2>nul & goto:exit the result: c:\projects\batch>caller.bat new error message <-- testing only, don't kno...

Powershell - Parsing a result text file to a .CSV file -

i'm new powershell , need guidance, please. trying read text file below , create custom .csv file allow easy database managing. currently have tried using: attempt #1 get-content d:\parsingproject\cdmv3\cdmv3.txt $sequentialread = $array | select-string -pattern "sequential read :" $sequentialreadresults = $sequentialread -split "sequential read :" $csvcontents = @() # create empty array csv file $row = new-object system.object # create object append array $row | add-member -membertype noteproperty -name "seuqential reads" -value $sequentialreadresults $csvcontents += $row # append new data array $csvcontents | export-csv -path d:\parsingproject\cdmv3\mycsv.csv attempt # 2 (this 1 incomplete) $input_path = 'd:\parsingproject\cdmv3\cdmv3.txt' $output_file = 'd:\parsingproject\cdmv3\cdmv3_scores.txt' $regex = ‘[a-z\s]+[a-z]+[:\s}+[\d]+.[0-9]+\s[a-za\/]{1,4}’ select-string -path $input_path -pattern $regex -allmatches | %...

bash - How do I properly add a return character to this script? -

here script use run grunt "globally". in bash shell , wants more context wan return character bit more "silent" when run beast watch . beast() { cd ~/root_install/grunt local a="$1" if [ $# -eq 0 ] grunt & fi if [ $# -eq 1 ] grunt "$a" & fi cd ~/root } i want return character @ part: grunt "$a" & after & when run grunt 1 of exit codes below. 0 - no errors! 1 - fatal error 2 - missing gruntfile error 3 - task error 4 - template processing error 5 - invalid shell auto-completion rules error 6 - warning what can grab grunt "$a" &>/dev/null pick result using $? so can if [ $? -eq 0 ] controls on return code. &>/dev/null abbreviation 2>&1 it redirects file descriptor 2 , 1 (stderr & stdout) /dev/null

sql server - Group a Group in SQL -

i have following query: select inspections.pipe_segment_reference, (count(*) * conditions.structural_grade) structural_rating ( select inspections.pipe_segment_reference, conditions.structural_grade conditions inner join inspections on conditions.inspectionid = inspections.inspectionid conditions.structural_grade not null ) group inspections.pipe_segment_reference, conditions.structural_grade; which outputs 22, 2 22, 4 79, 2 79, 5 79, 3 i want further group pipe_segment_reference output of 22, 6 79, 10 i tried adding additional select around query above can't work. you're on right track adding additional select around working query. try this... select derivedyourinitialquery.pipe_segment_reference, sum(derivedyourinitialquery.structural_rating) newtotal ( select inspections.pipe_segment_reference, (count(*) * conditions.structural_grade) structural_rating ( select inspections.pipe_segment_reference...

python - Why is my WTForm HiddenField not being set to a default value? -

i have employeeform 1 of fields comprising of photoform shown below: class employeeform(form): name = stringfield('full name', validators=[datarequired()]) title = stringfield('job title', validators=[datarequired()]) email = stringfield('company email', validators=[datarequired()]) department = stringfield('department', validators=[datarequired()]) photo = formfield(photoform) depending on whether use_s3 config variable set true or false want 2 fields on photo object automatically set default values so: class photoform(form): image = s3imageuploadfield(base_path=app.config['upload_folder'],namegen=photo_name_generator) if app.config['use_s3']: image_storage_type = hiddenfield('s3') image_storage_bucket_name = hiddenfield(app.config['s3_bucket_name']) else: image_storage_type = hiddenfield('empty string') image_storage_bucket_name = hid...

php - Is there any better way to fill form input values in the above search form? -

i have search form below 1 field {!! form::open(array('method' => 'post', 'action' => 'customercontroller@searchcustomers', 'class' => "form-horizontal form-label-left")) !!} {!! csrf_field() !!} <input type="text" class="form-control" name="customer"> <button type="submit">search</button> {!! form::close() !!} below code in controller $allcustomers = \app\models\customer_model ::where('customer', 'like', '%'.$customer.'%') ->get(); return view('customer.list', array('allcustomers' => $allcustomers)); what trying ? when form submitted search, in view , should able view keyword again in textbox. doing below. return view('customer.list', array('allcustomers' => $allcustomers, 'key' => $customer)); and in form, doing below. ...

JS Popup interrupts execution of javascript -

suppose have http://www.w3schools.com/js/tryit.asp?filename=tryjs_prompt page. have event listener on click action, this: document.addeventlistener('click', function() { mymagichere(); }); now in case of clicking on button "try it" mymagichere() interupted js popup. want mymagichere() performed in case of clicking on button. there way/workaround how handle situation? try set usecapture parameter of addeventlistener true . listener executed in capture phase before being executed event target. document.addeventlistener('click',function(){ mymagichere(); }, true); this concept of capturing , bubbling events. can see more in question

c - Scanf changes wrong array when it is in do-while loop -

i need suggestions code. this code in program checks if number in range between 1 , 20. problem occurs in these few lines because when enter in while loop, scanf() changes numbers in 2 arrays, not in one. one numbertoguess array , second array in numbers "randomly" generated (i had used srand(time(null)) ). function random generator called once, before code. i guess because when while loop occurs takes last address buffer, not sure how fix it. while(numbertoguess[i]<1 || numbertoguess[i]>20) { printf("try again:\n"); for(i=0;i<4;i++) { scanf(" %d", &numbertoguess[i]); } } edit: had found solution , , unrelated posted code. problem occurred on part had declared arrays. size of arrays smaller should be(instead of 4 , 3). when loop variable (i) equal 3 , scanf jumped memory location, location of second array , changed 1. on second array , when loop equal 3 , out of array bounds , printed "random value...

jquery - Target for Hover to an already Hovered element -

Image
i trying accomplish hover effect in when div hover tick mark appeared using following code: #asked-question-answers .question.ref-ans:hover::before{ content: '\e8a7'; speak: none; display: inline-block; font: normal normal normal 24px/1 'material-design-icons'; text-rendering: auto; -webkit-font-smoothing: antialiased; transform: translate(0,0); position: absolute; left: 20px; margin-top: 20px; font-size: 34px; color: #ccc; } now want apply hover selected on tick mark using following(failed try) code gray tick becomes green: #asked-question-answers .question.ref-ans::before:hover{ color: green; } as mentioned paulie_d , cbroe, not able define hover action on pseudo elements. can instead create tick mark absolute positioned element in html markup opacity:0; . #asked-question-answers .question.ref-ans #tickmark { position: absolute; top: ...; left: ...; opacity: 0; /...

node.js - What is a good pattern for implementing access control in a GraphQL server? -

background: i have set of models, including user , various other models, of contain references user. exposing these models querying via graphql api generated graffiti , backed mongo database using graffiti-mongoose adaptor. current rest api (which migrating graphql) uses json web tokens authenticate users, , has custom permission logic on server side handle access control. problem: i'd restrict access objects in graphql based upon current logged-in user. models should accessible reads unauthenticated calls. other models should accessible user created them. what's best way manage access control objects via graffiti-generated api? in general, there patterns of access control graphql? , in particular, there examples or libraries doing graffiti? notes: i understand pre- , post- hooks have been implemented graffiti-mongoose, , can used basic binary checks authentication. i'd see how more detailed access-control logic worked graphql api. in future, we...

osx - How do I connect to a docker container running on a different host on a mac? -

i have set docker on mac using kinematic. have mysql container running. so, 'schematic', believe, looks this: (mac1 (virtualbox docker host (mysql container))). mac1 ip: 10.10.10.100 mysql container: 192.168.99.100 running on port 32500 (mapped 3306) i can access mysql server via 192.168.99.100:32500 mac1 without issues. now, when go mac2 on network, cannot access mysql container. so, mac2 ip: 10.10.10.200 cannot see 192.168.99.100:32500. mac2 gets ping response, not sure if getting way mysql container. i'm thinking of installing proxy on mac1, wanted check first. none of questions posed here seemed account kinematic install on mac, , ones referring boot2docker didn't address question either. any insights welcome! in advance. if looking simplest way expose container port network, map virtual box port onto mac1 , access outside.

automated tests - Is there a Protractor Reporting Tool that works with a cucumber framework? -

Image
using protractor cucumber , need plug in or tool (free if possible) create user friendly test report or @ least file test report can generated from. thank you! the easiest thing compliment current setup free , open-source serenity/js . serenity/js next generation acceptance testing library, in basic scenario, can act integration layer between protractor , cucumber. this enables to: run tests in parallel , still aggregated, user-friendly test reports. enhance test reports screenshots of app's ui without additional plugins. fix common problems related cucumber/webdriver controlflow synchronisation , inaccurate reporting single config change. try screenplay pattern in part of project while keeping other tests working used to. way minimise risk of disrupting work of team while improving tool set. the below setup instructions explained in detail in the manual , , reports you'll this: setup install serenity-js module npm , save development dependen...

Rails 4, Devise & Mandrill emails -

i'm trying make app in rails 4. for past 3 years, i've been struggling figure out devise/omniauth (i still trying work). stepping aside main problems while try , find live through this, i've tried setup emails mandrill. i found tutorial, trying follow along: https://nvisium.com/blog/2014/10/08/mandrill-devise-and-mailchimp-templates/ i have mailer called mandrill_devise_mailer.rb class mandrilldevisemailer < devise::mailer def confirmation_instructions(record, token, opts={}) # code added here later end def reset_password_instructions(record, token, opts={}) options = { :subject => "reset password", :email => record.email, :global_merge_vars => [ { name: "password_reset_link", # content: "http://www.example.com/users/password/edit?reset_password_token=#{token}" content: "http://www.cr.com/users/password/edit?reset_password_token=#{token}"...

c# - Azure Mobile Service - Entity Framework Code First drop and create database not working -

problem: changing model in code first mobile services project , publishing azure causes following error: system.data.sqlclient.sqlexception (0x80131904): cannot open database "master" requested login. login failed. login failed user 'xxxxxxxxxxxxxxxxxx'. steps reproduce: visual studio community 2015 new project -> web application -> mobile service publish straight azure (create new mobile service - select cheapest tier db) send in fiddler http://whatever.azure-mobile.net/tables/todoitem receive 200 ok 2 items seeded db default project make small change model (e.g. add following todoitem class) public string changed { get; set; } publish changes azure send in fiddler http://whatever.azure-mobile.net/tables/todoitem this time 500 internal server error received , error quoted @ start appears twice in mobile service logs in azure i have checked , database still exists without change model, assume azure wasn't able drop reason. in default ...

No such file or directory error when compiling C++ file with OpenCV headers -

i'm on red hat linux. i'm having (probably newbie) problem includes in c++ file. created following simple opencv script, #include "opencv2/highgui/highgui.hpp" using namespace cv; int main(int argc, char ** argv){ mat img = imread( argv[1], -1 ); if ( img.empty() ) return -1; namedwindow( "example1", cv::window_autosize ); imshow( "example1", img ); waitkey( 0 ); destroywindow( "example1" ); } then in terminal entered g++ my_simple_script.cpp and got errors newfile.cpp:1:39: error: opencv2/highgui/highgui.hpp: no such file or directory newfile.cpp:3: error: 'cv' not namespace-name newfile.cpp:3: error: expected namespace-name before ';' token newfile.cpp: in function 'int main(int, char**)': newfile.cpp:6: error: 'mat' not declared in scope newfile.cpp:6: error: expected ';' before 'img' newfile.cpp:7: error: 'img' not declared in scope newfile....

tiddlywiki5 - Why heroku app doesn't save new file with Tiddlywiki? -

have met issue me before? have deployed tiddlywiki5 heroku app @ https://jameswiki.herokuapp.com . displayed , worked expected @ runtime. however, after server (web dyno) sleeping , wakeup (often after 1 hour inactive), clear. have checked console in heroku when creating new tiddle, still said new tiddle has been saved, in fact, no new tiddle saved tiddlers folder. below script install , run it: in package.json { ... "scripts": { "start": "tiddlywiki . --server", "postinstall": "npm install -g tiddlywiki" } } in procfile web: tiddlywiki . --server $port $:/core/save/all text/plain text/html "" "" 0.0.0.0 help me fix issue. thanks. heroku's filesystem ephemeral - exists while dyno exists. when dyno restarts or ends (as when app goes sleep), new 1 have fresh, empty filesystem. if want files persist, need save them off database or amazon s3 long-term ...

sas - linking crsp and compustat in R via WRDS -

i using r connect wrds. now, link compustat , crsp tables. in sas, achieved using macros , ccm link table. best way approach topic in r? progress update: i downloaded crsp, compustat , ccm_link tables wrds. sql <- "select * crsp.ccmxpf_linktable" res <- dbsendquery(wrds, sql) ccmxpf_linktable <- fetch(res, n = -1) ccm.dt <- data.table(ccmxpf_linktable) rm(ccmxpf_linktable) i converting suggested matching routine wrds event study sas file r: ccm.dt[,typeflag:=linktype %in% c("lu","lc","ld","ln","ls","lx") & usedflag=="1"] setkey(ccm.dt, gvkey, typeflag) (i in 1:nrow(compu.dt)) { gvkey.comp = compu.dt[i, gvkey] endfyr.comp = compu.dt[i,endfyr] permno.val <- ccm.dt[.(gvkey.comp, true),][linkdt<=endfyr.comp & endfyr.comp<=linkenddt,lpermno] if (length(permno.val)==0) permno.val <- na suppresswarnings(compu.dt[i, "permno"] <- permno.val) } ho...

javascript - Invalid ELF header Node js with couchbase db -

i've seen handful of posts issue results seem specific users configuration. i'm using couchbase db express js server. when run code locally (windows) works fine. database self hosted on linux server. when deploy code our testing environment ( linux ), i'm getting error when try run "node server.js": /var/www/html/btrnode/node_modules/couchbase/node_modules/bindings/bindings.js:83 throw 8 error: /var/www/html/btrnode/node_modules/couchbase/build/release/couchbase_impl.node: invalid elf header @ module.load (module.js:356:32) @ function.module._load (module.js:312:12) @ module.require (module.js:364:17) @ require (module.js:364:17) @ .... i'm lost on in situation. mentioned before, seemed me fixes in other peoples situation system configuration. i'm not sure post here see configuration might help, can sure add if needed. if there more general solution or error i'm committing that'd helpful know to. question : ...

UPDATE query from Access to SQL Server -

i have query below access , need convert sql server: update (case_info inner join case_price on case_info.case_type = case_price.case_type) inner join [casechange|input] on case_info.case_number = [casechange|input].case_number set case_info.ff_revenue_amt = [ff_payment], case_info.cm_revenue_amt = [cm_payment] (( (case_info.scheduled_date) between [case_price].[pop_start] , [case_price].[pop_end]) , ((case_info.discontinue_30)=no)); access: update t1 inner join t2 on t1.foo=t2.bar set t1.field = t2.otherfield ... sql server: update t1 set t1.field = t2.otherfield t1 inner join t2 on t1.foo=t2.bar ... that should started. see update table using join in sql server?

asp.net mvc - EditorFor htmlAttributes not working for type bool (MVC 5.2) -

since mvc 5.1 possible add html attributes editor templates follows: @html.editorfor(m => m.foo, new { htmlattributes = new { id = "fooid", @class="fooclass" } }) if property foo of type string , generate input markup correctly, including custom attributes. but if property foo of type bool (or bool? ) attributes ignored... am missing here?. feature still not supported templates generates "select" markup? i know question asked while ago ran exact same issue now. turns out different developer had created custom editor template boolean in our solution able customize text of drop-down. code supposed work editors out of box not work automatically custom editors ... have implement yourself. if issue, need modify custom editor template fetch htmlattributes out of viewdata , pass them along underlying dropdownlistfor (or whatever helper using). here custom editor template looks now: @model bool? @using system.web.mvc; @{ var html...

r - Why is the time complexity of this loop non-linear? -

why time complexity of loop non-linear , why slow? loop takes ~38s n=50k, , ~570s n=200k . there faster way this? rprof() seems indicate writing memory slow. df <- data.frame(replicate(5, runif(200000))) df[,1:3] <- round(df[,1:3]) rprof(line.profiling = true); timer <- proc.time() x <- df; n <- nrow(df); <- 1 ind <- df[1:(n-1),1:3] == df[2:n,1:3]; rind <- which(apply(ind,1,all)) n <- length(rind) while(i <= n) { x$x4[rind[i]+1] <- x$x4[rind[i]+1] + x$x4[rind[i]] x$x5[rind[i]+1] <- x$x4[rind[i]+1] * x$x3[rind[i]+1] x$x5[rind[i]+1] <- trunc(x$x5[rind[i]+1]*10^8)/10^8 x$x1[rind[i]] <- na <- + 1 };x <- na.omit(x) proc.time() - timer; rprof(null) summaryrprof(lines = "show") the purpose of algorithm iterate on data frame , combine adjacent rows match on elements. is, removes 1 of rows , adds of row's values other row. resulting data frame should have n less rows, n number of matching adjacent row...

Complex table Join at sql -

Image
pls want data articles table according presskit table data i need how join between articles table , presskit table while have different intermediate tabled between them? i want data select articleid , articaletile articles dbo.magazineid in ( select dbo.magazines.magazineid dbo.magazines inner join dbo.presskitmagazines on dbo.magazines.magazineid = dbo.presskitmagazines.magazineid presskitid = @presskitid ) , classid in ( select class.classid dbo.class inner join dbo.presskitclass on class.classid = presskitclass.classid presskitid = @presskitid ) select articleid, articletitle articles join dbo.presskitmagazines pm on a.magazineid = pm.magazineid , pm.presskitid = @presskitid join dbo.presskitclass pc on a.classid = pc.classid , pc.presskitid = @presskitid you not need involve magazines , class or presskit because not need return name s associat...

Angular 2 DataService in TypeScript for ASP.NET 5 not displaying data -

this displays hello world app.component.ts bootstrapping correctly. either no data returned dataservice or can't displayed. there no compiler errors. there popup window in typescript alert() in javascript check see if data being returned dataservice? app.component.ts import { component } 'angular2/core'; import { dataservice } './data.service'; @component({ selector: 'app', template: `<h1>hello world</h1> <li *ngfor="#customer of customers"> <span>{{customer.firstname}}</span> </li> ` }) export class appcomponent { public dataservice: dataservice; customers: any[]; constructor() { } ngoninit() { this.dataservice.getcustomers() .subscribe((customers: any[]) => { this.customers = customers; }); } } data.service.ts import { injectable } 'angular2/core'; import { http, response } 'angular2/http'; import 'r...

java - how to use Iterator in object arraylist -

here got public class planet { arraylist<person> person = new arraylist<>(); iterator<person> itr = person.iterator(); public string getfemalename() { (int = 0;a < person.size();a++) { if (person.getgender == "female") { return person.get(a).getname(); } } } } now i'm having 2 problems, 1st want return female's name,but seems have return there no female in arraylist. 2nd how use iterator instead of using loop. for case when no female present , putting return null in end of function job, because first return statement won't executed @ all. for second question, using iterator .. replace for loop while(itr.hasnext()) { person newperson=itr.next(); if(newperson.getgender().equals("female") return newperson.getname(); }

javascript - How to determine if google auth2.signIn() window was closed by the user? -

im implementing auth using , showing loading icon in react when user clicks button sign in , auth2 account selection/login window shows. however if user closes window, there doesnt seem event fired i.e signin() function returns promise never resolves, have thought google return error promise if window closed. result there no way me stop showing loader icon , reshow login menu. i wondering if had solution this? although api provides mechanism detecting when user clicks deny button, there not built-in way detecting user abruptly closed popup window (or exited web browser, shut down computer, , on). deny condition provided in case want re-prompt user reduced scopes (e.g. requested "email" need profile , let user proceed without giving email). if response sign-in callback contains error, access_denied , indicates user clicked deny button: function onsignincallback(authresult) { if (authresult['error'] && authresult['error'] == '...

php - I want to display different prices for logged in (wholesale) and logged out (retail) customers in woocommerce website -

i developing e-commerce website, want display different price loggedin users , different loggedout users. can please let me know how can in woocommerce. you need custom code. gets placed in theme functions.php file or custom plugin code. function custom_get_price( $price, $product ) { $discount = 0.5; if( is_user_logged_in() ) $price = $price * $discount; return $price; } add_filter( 'woocommerce_get_price', 'custom_get_price',10,2); this code hooks woocommerce get_price() function in abstract-wc-product.php file. some resources on adding custom code wordpress https://www.woothemes.com/2014/09/properly-add-woocommerce-custom-code/ https://dev7studios.com/adding-code-customisations-wordpress-the-right-way/ https://docs.woothemes.com/document/introduction-to-hooks-actions-and-filters/

java - Number list from a Map -

i have map simplifying in essense contains key values of data such as: yahya, 4 john, 4 blake, 2 jill 2 janoe, 6 jilly 12 zapon, 5 zoe, 4 hamed, 1 i need order following output: 1. jilly, 12 pts 2. janoe, 6 pts 3. zapon, 5 pts 4. john, 4 pts 4. yahya, 4 pts 4. zoe, 4 pts 7. blake, 2 pts 7. jill, 2 pts 9. hamed, 1 pts i have used comparator order map values according value: public <k, v extends comparable<v>> map<k, v> sortbyvalues(final map<k, v> map) { comparator<k> valuecomparator = new comparator<k>() { public int compare(k k1, k k2) { int compare = map.get(k2).compareto(map.get(k1)); if (compare == 0) return 1; else return compare; } }; map<k, v> sortedbyvalues = new treemap<k, v>(valuecomparator); sortedbyvalues.putall(map); return sortedbyvalues; } and read : how element position java map , order hashmap alphabetically value , more not sure h...

visual studio - "Scanning new and updated MEF components" -

i can reproduce problem @ will. below steps: environment: windows 10 professional 64bit run vs_community_enu.exe install choose microsoft web , developer tools let done installing open first time, can see asp.net web application close visual studio open second time, show upgrade: "scanning new , updated mef components..." , 2 or 3 more of undated new project no long shows asp.net web application along other templates how can fix problem? uninstalled , reinstalled 5 times , same thing happen again. installed vs2015.1.exe nothing happened delete contents of following folder: %localappdata%\microsoft\visualstudio\14.0\componentmodelcache

bash - Redirecting output of list of commands -

i using grep pull out lines match 0. in multiple files. files not contain 0. , want output "none" file. if finds matches want output matches file. have 2 example files this: $ cat sea.txt shrimp 0.352 clam 0.632 $ cat land.txt dog 0 cat 0 in example files both lines output sea.txt , land.txt file "none" using following code: $ grep "0." sea.txt || echo "none" the double pipe ( || ) can read "do foo or else bar", or "if not foo bar". works perfect problem having cannot output either matches (as find in sea.txt file) or "none" (as find in land.txt file) file. prints terminal. have tried following others without luck of getting output saved file: grep "0." sea.txt || echo "none" > output.txt grep "0." sea.txt || echo "none" 2> output.txt is there way save file? if not there anyway can use lines printed terminal? you can group commands { }...

Why android 5.0 occur error java.lang.RuntimeException: start smooth zoom failed? -

this code set zoom of camera: // 10 set zoom value camera if (p.iszoomsupported() && p.issmoothzoomsupported()) { // phones mcamera.startsmoothzoom(zoomvalue); } else if (p.iszoomsupported() && !p.issmoothzoomsupported()) { p.setzoom(zoomvalue); mcamera.setparameters(p); mcamera.setparameters(p); mcamera.startpreview(); } but occur exception on canvas spark (q380) android 5.0: java.lang.runtimeexception: start smooth zoom failed @ android.hardware.camera.startsmoothzoom(native method) jat android.app.activity.dispatchtouchevent(activity.java:2775) @ com.android.internal.policy.impl.phonewindow$decorview.dispatchtouchevent(phonewindow.java:2326) @ android.view.view.dispatchpointerevent(view.java:8687) @ android.view.viewrootimpl$viewpostimeinputstage.processpointerevent(viewr...

c++ - Iterating through a list of a custom class -

i'm trying iterate through list contains objects of type 'window' (a custom class wrote). loop supposed use gettitle() method of window class on each element , print out title in console. for reason when try access method through iterator tells me method not exist.. this code: void center::printwindowlist() { (std::list<window>::iterator = windowlist.begin(); != windowlist.end(); ++it) std::cout << ' ' << *it.gettitle(); } hope can help it's issue of operator precedence. try doing it->gettitle() or (*it).gettitle() .

Realm: Swift `let` property cannot be marked as dynamic -

i using xcode 7.2, swift 2.1.1. have realm model object below class b: object { dynamic let lists = list<a>() } but swift compiler gives me error saying: property cannot marked dynamic because type cannot represented in objective-c i saw realm's documentation says: realm model properties need dynamic var attribute in order these properties become accessors underlying database data. there 2 exceptions this: list , realmoptional properties cannot declared dynamic because generic properties cannot represented in objective-c runtime, used dynamic dispatch of dynamic properties, , should declared let but declaring let doesn't seem solve case now. missing? the documentation quoted includes following (emphasis mine): list , realmoptional properties cannot declared dynamic because generic properties cannot represented in objective-c runtime, […], , should declared let . this means property should declared so: let lists...

android - Cannot get URL (with sql query) to be handled by DefaultHttpClient in java -

i've been struggling half day trying learn , stuck. goal query finance data yql yahoo finance tables. have set code androidhive example , able running correctly sample query. sample query grabs json object directly main url provide. yql, need convert sql query format httpclient recognize, , app keeps hanging , never returning response. first, tried taking exact query string yql replicate search, me this: https://query.yahooapis.com/v1/public/yql?q=select%20symbol%2cchange%20from%20yahoo.finance.quote%20where%20symbol%20in%20(%22sh%22%2c%22dog%22%2c%22rwm%22)&format=json&env=store%3a%2f%2fdatatables.org%2falltableswithkeys&callback= that gives me null result when set url = above, , run following: defaulthttpclient httpclient = new defaulthttpclient(); . . . httpget httpget = new httpget(url); httpresponse = httpclient.execute(httpget); if androidhive example url in code, works fine. if enter above url in browser, works fine. clearly, url not being enter...

google chrome - Why is SVG scrolling performance so much worse than PNG? -

a site i'm working on displays large number (>50) of complex svg images in scrolling dialog window. when viewing site in chrome, scrolling performance of dialog window poor - noticeably laggy , slow. however, if replace svg images png images, scrolling smooth , responsive. here's demonstration of difference: https://jsfiddle.net/nathanfriend/42knwc1s/ why svg scrolling performance worse png scrolling performance? after browser renders svg image, assume doesn't need rerender image until image manipulated in way (like resizing). scrolling element contains svg images cause images rerendered every frame of scroll animation? ` i think kind of chromium bug, i've found issue on so, because started experiencing on mac. works ok on opera instance. i don't think here able explain why it's slow if bug. i've created chromium bug, please star if want is...

python - Testing point with in/out of a vector shapefile -

Image
here question. 1. intro a shapefile in polygon type represent study area http://i8.tietuku.com/08fdccbb7e11c0a9.png some point located in whole rectangle map http://i8.tietuku.com/877f87022bf817b8.png i want test whether each point located within/out polygon , further operation(for example, sum grid point amount within study area) 2. idea i have 2 methods information on stack overflow. 2.1 idea rasterize shapefile raster file , test. i haven't done yet, have asked 1 question here , answer. 2.2 idea b i have tried using poly.contain() test scatter point's location, result wasn't match reality. 3. code based on idea b: for example: original data represent pt (a pandas dataframe) contain 1000 grids x,y. shapefile shown study area, want filter original data leaving point within area. 3.1 preparation # map 4 boundaries xc1,xc2,yc1,yc2 = 113.49805889531724,115.5030664238035,37.39995194...

How can I get Mono 2.11+ installed on Travis-CI? -

i build c# project on travis-ci like this : # .travis.yml before_install: - sudo apt-get update -qq - sudo apt-get install -qq mono-devel gtk-sharp2 install: - xbuild source/pash.sln travis uses precise (ubuntu 12.04 lts) seems choice them, includes mono 12.10. c# project hits bug in mono 2.10. bug appears fixed in mono 2.11+. i read ubuntu slow pick new builds of mono because depends on it, , can break much. that's fine, travis dependencies aren't problem - machine goes away @ end of build! i have considered compiling new mono in .travis.yml don't want put burden on travis servers. building mcs (mono c# compiler) fix. downloading , installing newer mono somewhere (where?) checking recent mono in git repo. suggestions? if you're going use higher standard distro packages provide, recommend go way , not use unstable 2.11.x series, official/beta 3.x ones. so, grab preview debian/ubuntu 3.0.6 packages ppa: http://www.meebey.net/pos...

node async - Meteor didn't stop fibers execution -

i want upload csv file , insert db after huge validation , process. using fibers asynchronous call. fiber process keep executing fiber returns future.wait(); . meteor.methods({ uploadcsv: (calender) { if (meteor.isserver) { var future = npm.require('fibers/future'); var future = new future(); calender = parse(calender); future["return"](savecalender(calender)); //huge process , validation console.log(future); // { value: 1, resolved: true } return future.wait(); } } }); savecalender function executes every time. did missed stop fiber execution or how stop fiber execution?

java - How to make sprites move from one place to another place -

i'm using libgdx create game got problem: how make sprite move 1 location marked click location marked click? need smooth animation. here's code have done: main application implements applistener , inputlistener. public class lgame implements applicationlistener { public static field field; private spritebatch bat; private listener listener; @override public void create() { field = new field(); bat = new spritebatch(); listener = new listener(); gdx.input.setinputprocessor(listener); } @override public void render() { bat.begin(); bat.draw(field.gettexture(), 0, 0); for(int = 0; <= 31; i++) if(!field.getfigure(i).iseaten()) bat.draw(field.getfigure(i).gettexture(), field.getfigure(i).getposx()*64, field.getfigure(i).getposy()*64); bat.end(); } "render" method iterate collection "field" contained objects on scene. public class listener implements inputprocessor { private int inx; private i...

Does a JavaScript Anonymous function have access to other parameters passed along with it? -

let's have function takes 2 parameters, regular variable , function. function example(vara, function(){ //do vara? }) can use vara in definition of anonymous function? if run function , pass in vara, anonymous function know vale of vara is? answer no! your definition incorrect. function example(vara, function(){ //do vara? }); during function definition, not know callback , should be: function example(vara, callback){} now in following example: function test(vara){ function notify(){ console.log(vara); } notify(); } test(10) vara accessible because in same scope, if this: function test(vara, callback){ callback(); } test(10, function(){ // throw error, because there no variable called vara console.log(vara); }) and have pass arguments callback. function test(vara, callback){ callback(vara); } test(10, function(vara){ console.log(vara); })

css - CSS3/jQuery Flip Down animation -

i saw elegant , neat animation on site: http://adam.co/ notice how 'i making great ideas happen' comes view. trying figure out how that. could guide me on how produce similar effect website? it simple without libraries etc.. can pretty done css3. apply 'loaded' class or when page loads , define animation animate width (or scalex) , background positions. @-webkit-keyframes flip-in { 0%{ background-position: 5px -80px; -webkit-transform:scalex(0); } 50% { background-position: 5px -80px; -webkit-transform:scalex(1); } 100% { background-position: 5px 5px; } } .loaded #text-block { -webkit-animation-name: flip-in; -webkit-animation-duration: 0.75s; -webkit-animation-timing-function: ease-in-out; } take (i put webkit styles in example, use chrome or safari): http://jsfiddle.net/adamco/guju4/ the staggered effect simple enough too. can reuse same animation , incr...

math - php multiply int values seperated by comma and dot -

in current application user can have "prepaid" amount of money on account. value stored in cents. in case of user tries transfer money 1 account should able use values like: "1,53", "1.53" , "1". need check if entered amount below amount he's able transfer. if (($request->amount * 100) <= $user->calculateamount()) the function $user->calculateamount() returns values example "351" stands 3,51€ (saved in cents). know problem ",", using "." works fine, user should able use both. there better way or did need use str_replace()? you can use this: http://codepad.org/nw4e9hqh currently there no other method parse float.

Project not synced in android studio 22.0.1 buildversion tool ubuntu -

i want sync project in build 22.0.1 when set gradle file below taking process sync continuously android { compilesdkversion 22 buildtoolsversion "22.0.1" defaultconfig { applicationid "com.example.sphere65.myapplication2" minsdkversion 15 targetsdkversion 22 versioncode 1 versionname "1.0" } buildtypes { release { minifyenabled false proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile filetree(dir: 'libs', include: ['*.jar']) testcompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:22+' compile 'com.android.support:design:22+' }

c++ - C++Builder does not call destructor on throw-catch-continue -

for code: #include <stdio.h> int constrcalls=0, destrcalls=0; struct z { z() { constrcalls++; } ~z() { destrcalls++; } }; int main(int argc, char**) { bool startup= true; { z z; try { if( startup ) { startup= false; throw( 1 ); } else { break; } } catch(int) { continue; } } while(true); printf( "constrcalls=%d destrcalls=%d", constrcalls, destrcalls); return 0; } g++ output "constrcalls=2 destrcalls=2" , ok embarcadero c++builder 2010, c++builder 10 seattle output "constrcalls=2 destrcalls=1" , after throw-catch-continue destructor not called! can c++builder works right? thanks. sadly... the c++builder 6, rad studio 2009 , xe7 update 1, c++ compiler generates bad exception handling code (and in likelihood compilers in between--those com...