Posts

Showing posts from March, 2012

Angular-meteor ORM-like one-to-many relationship without infinite-digest issues -

i'm working on user-roles relationship, , code works except produces infinite digest error on angular side, think has performance implications. in user class (es2015), have: get roles() { return roles.findbyids(this._roleids).fetch() } and problem above getter returns new object every time, in angular's eyes, they're not equal. tried track by , follows: <ul> <li ng-repeat="role in user.roles track role._id"> {{role.name}} </li> </ul> which throws following exception: uncaught error: [$rootscope:infdig] 10 $digest() iterations reached. aborting! watchers fired in last 5 iterations: [[{"msg":"fn: regularinterceptedexpression","newval":20,"oldval":19}],[{"msg":"fn: regularinterceptedexpression","newval":21,"oldval":20}],[{"msg":"fn: regularinterceptedexpression","newval":22,"oldval":21}],[{"msg

java - Tomcat application cannot see my $PATH variable -

there tomcat application thats been running on 1 of our servers (written else in our lab gone). know little tomcat , how works, i've narrowed problem down 2 solutions. the error i'm getting on webpage is: java.io.ioexception: cannot run program "hmmtop": error=2, no such file or directory server information tomcat version jvm version jvm vendor os name os version os architecture apache tomcat/6.0.26 1.6.0_65-b14-462-10m4609 apple inc. mac os x 10.6.8 x86_64 before os x update script worked fine. cannot find program called 'hmmtop'. program, 'hmmtop' located : /users/saierlab/bin/hmmtop, , exist. solution 1) tried changing file named 'myfile.java' use absolute path, looks this: string command = "/users/raven/bin/hmmtop -if=" + this.filename + ".fa"; this file located in "/usr/local/tomcat/webapps/avehas/web-inf/classes" however, when change nothing reflected. i'm not sure how c

java - Securely Storing Keys in Android Keystore -

i making android application communicates server. i'm using token based authentication on server, , pass information client server, using asymmetric encryption. this how process goes generated public , private key exists before hand public key used encrypt information, , passed server client app uses private key decrypt information however, not know how securely store private key in keystore. if store during runtime, key out in code, , if send private key during rest connection, there's no point of having encryption because hacker can find both keys. can me on creating best possible solution? thx in advance!

javascript - Calling global function in Riot.js expression -

i trying call function declared in global namespace expression in riot.js. this not work: <strong>created { getdatestring(item.created) } { item.creator }</strong> i can call global moment() function (from moment.js): <strong>created { moment(item.created) } { item.creator }</strong> the overall javascript file containing function is loaded... if call getdatestring() this.on('mount') works: this.on('mount', function() { getdatestring(new date()); }); i don't understand how namespacing works in riot.js, , can't figure out why call getdatestring() failing in expression succeeding in mount function. can tell me i'm doing wrong? make sure globalfunction() declared @ global. scope of <script> tag inside tag definition not global. take care it. <my-tag> <p>{ someglobalfunction(message) }</p><!-- work --> <p>{ localfunction1(message) }</p><!-- won't w

Use BatteryMeterView.java in android app -

i use batterymeterview.java aosp own app create battery icon responds level change, charging state, etc. i found source on github. possible integrate app create icon , percent text? i'm thinking .xml with <com.example.app.batterymeterview android:id="@+id/battery_icon" android:layout_width="8dp" android:layout_height="15dp" /> and batterymeterview.java file inside com.example.app also can use file in non open-source projects according current licence? time! this should be possible, need include resources , make decision on whether or not want have batterycontroller , ignore demomode . , make decision of whether want hasoverlappingrendering() . license details read more @ http://www.apache.org/licenses/license-2.0 , you're interested in redistribution part.

regex - A tiny template language -

i pass string "partial" sql statement like: "select %fields% ... %order% %limit%" then want replace %fields% either real list of fields (which array) or count(*) . likewise replace %order% either order ... (which generate) or empty string , %limit% either limit ... (which generate) or empty string. i want way prevent these sequences replaced. example may "turn off" replacing if percents doubled: %%fields%% should not replaced list of fields replaced literal %fields% . note not insist namely on syntax. instead of percent signs may use other escape syntax (for example ${fields} or {{fields}} ). i want easy , (what more important) efficient way this. note use perl. maybe, should not invent own template language regexps , use perl module template::tiny ? efficient? #!/usr/bin/perl use strict; use warnings; sub myreplace { ($tmpl, $hash) = @_; %hash2; foreach $key (keys %$hash) { $hash2{"%$key%"} = $hash-

javascript - What is the scope of the callback on my vanilla JSONP -

a little backstory, i'm using twitch (game streaming service) api pull list of followers channel on site. in order around cors rules i'm using jsonp. personally, prefer use vanilla javascript on libraries learned how excellent article on over https://cameronspear.com/blog/exactly-what-is-jsonp/ . below simplified javascript (the actual code isn't extremely necessary, maybe it'll clarify question afterward): //function pull jsonp function pulljsonp(url) { var jsonpinstance = document.createelement('script'); jsonpinstance.src = url; jsonpinstance.onload = function () { this.remove(); }; var head = document.getelementsbytagname('head')[0]; head.insertbefore(jsonpinstance, null); } //end function pull jsonp function storecurrentfollows(offset) //function wrap entire operation { function pullstartsessionfollows(jsondata) //callback jsonp down below { function pushnameelements(followentry)

Hashmaps password lock java -

i have made password lock thing in java test skills in learning hash maps. code: package com.zach.password; import java.util.hashmap; import java.util.random; import java.util.scanner; public class password { public static void main(string[] args) { @suppresswarnings("resource") scanner in = new scanner(system.in); random r = new random(); hashmap<string, string> names = new hashmap<string, string>(); hashmap<string, integer> passwords = new hashmap<string, integer>(); hashmap<string, integer> randnums = new hashmap<string, integer>(); while(true) { system.out.println("please enter name!!"); string name = in.nextline(); if(names.containskey(name)) { int tries = 2; while(tries != 0) { if(tries != 0) { system.out.println("what password?"); int

Pass a return value from a method,which is a json array, to android asynctask, doInBackground method as an argument -

the json array passed doinbackground return value of following method. public jsonarray json_encode(){ string[] log_data; log_data= this.credentials(); jsonobject json_var=new jsonobject(); try{ json_var.put("username" ,log_data[0] ); json_var.put("password" ,log_data[1] ); } catch(jsonexception e){ e.printstacktrace(); } jsonarray json_array=new jsonarray(); json_array.put(json_var); return json_array; } i need pass return json array doinbackground method argument. how it? both methods in different class , method's return value passed (json array) in first class (main_activity),the second class aysnctask class ( class background_thread extends asynctask ) , need pass return array doinbackground method of second class. well, if want value in doinbackground() :- public class youractivity extends activity { ... jsonarray mjsonarray; ...

xcode - NSView with a KVC property in Swift -

i have custom nsview class defined as: class myview: nsview { var sometext: nsstring override func didchangevalueforkey(key: string) { println( key ) super.didchangevalueforkey( key ) } // other stuff } what want able outside of class change value of sometext , have didchangevalueforkey notice sometext has changed can, example, set needsdisplay true view , other work. how this? are sure need kvc this? kvc works fine in swift, there’s easier way: var sometext: nsstring { didset { // work every time sometext set } }

cqrs - Replay event store in Rebus -

im working rebus (0.84) , need build simple console app replay events (rebuilding query store). task pretty simple when comes simple ihandlemessages<t> (get handlers , call them), things got complicated when introduced sagas in code. maybe 1 of have working solution ? best use actual rebus , replay events through somehow synchronously configured bus - in case rebuild query side , long living sagas.

parse.com - C# How to get count of objects where some field is "undefined"? -

Image
i trying objects field "fblogged" false or undefined, query ignores objects "undefined" value, how fix it? have tried conditions like whereequalto("fblogged",null); or whereequalto("fblogged",""); and not works.

java - Programatically setting TextView background -

i've defined background textview : <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape= "rectangle" > <solid android:color="#000"/> <stroke android:width="1dp" android:color="#ff9"/> </shape> now i'm trying set textview programmatically: textview.setbackground((drawable)findviewbyid(r.drawable.cellborder)); this isn't working though, it's telling me can't cast view drawable . there way this? you have use getresources().getdrawable(r.drawable.cellborder); which return drawable . if use findviewbyid() try find view in view hierarchy , return that. view not drawable , can't cast it.

Ruby on Rails <%= %> within a <%= link_to %> -

i'm new ruby on rails. i'm following guide using haml. don't haml i've skipped using that. problem i'm trying have <h2><%= forumthread.title %></h2> link forumthread_path. with haml set be: %h2= link_to forumthread.title, forumthread_path how can achieve same result without haml? thanks lot in advance! i think want this: <h2><%= link_to forumthread.title, forumthread_path(forumthread) %></h2> which generate same thing as: <h2><a href="<%= forumthread_path(forumthread) %>"><%= forumthread.title %></a></h2> see link_to documentation , first argument 'title' link, , second path link.

r - Putting data frames into a list and then extracting them into seperate data frames -

this question has answer here: unlist list of dataframes 2 answers i have made 3 data frames , put them list using command given below # create 3 data frames bag <- round(data.frame(v1=rnorm(10),v2=rnorm(10,1,2)),2) book <- data.frame(a1=rnorm(10),a2=rnorm(10,1,2),a3=rep("na",10)) table <- round(data.frame(c1=rnorm(10),c2=rnorm(10,1,2)),2) # create list list1 <- setnames(lapply(ls(pattern="bag|book|table"), function(x) get(x)), ls(pattern="bag|book|table")) i have performed operations on data frames in list , want extract data frames individual frames before going list. looking solution not have mention names of data frames again instead use same. example, first df in list should extracted in df named "book" , same others. can extract them one-by-one , rename them step looks redundant , not think efficient. i

c++ - Why can templates only be implemented in the header file? -

quote the c++ standard library: tutorial , handbook : the portable way of using templates @ moment implement them in header files using inline functions. why this? (clarification: header files not only portable solution. convenient portable solution.) it not necessary put implementation in header file, see alternative solution @ end of answer. anyway, reason code failing that, when instantiating template, compiler creates new class given template argument. example: template<typename t> struct foo { t bar; void dosomething(t param) {/* stuff using t */} }; // somewhere in .cpp foo<int> f; when reading line, compiler create new class (let's call fooint ), equivalent following: struct fooint { int bar; void dosomething(int param) {/* stuff using int */} } consequently, compiler needs have access implementation of methods, instantiate them template argument (in case int ). if these implementations not in header, wouldn

vb.net - read specific values from text file -

i have following visual basic code, part of custom class. want simple , effective way(use little computer resources) assign "value1" value(100) "_field1","value2" value(8) "_field2" etc. nice ideas? thanks private sub readcrnfile() 'read files , assing values properties dim sr new io.streamreader(_filename) _field1 = sr.readtoend() _field2 = sr.readtoend() _field3 = sr.readtoend() sr.close() end sub where _filename full path text file looks this: value1: 100 value2: 8 value3: 80 change _field1 , _field2 , _field3 variables list(of string) (i.e. named field ) , access each field using index ( field(0) , field(1) , field(2) ). dim field new list(of string) private sub readcrnfile() each line in file.readalllines(_filename) = 1 3 if line.contains("value" & i) field.add(line.substring(line.indexof(":") + 2))

swift - Button on Table View Cell connected to local function -

i have table view cell loaded data parse request. loads "friend requests", showing requesting friends name , 2 buttons, "accept" , "reject" here cellforrowatindexpath func: func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell { let cell:notifications_jlr_cell = self.tableview.dequeuereusablecellwithidentifier("cell") as! notifications_jlr_cell cell.txtrequestdesc.text = searchresults[indexpath.row].requesteename + " has requested friend" cell.btnapprove_outlet.addtarget(self, action:selector("approve"), forcontrolevents: uicontrolevents.touchupinside) return cell } the table loads fine, , addtarget line, once "approve" button clicked, runs func: func approve() { println("approve") } however, when fetching parse data, have set in array, objectid friend request, want refer in approve() function how can pass objectid

python - Slicing a 2D array to match entries from a 3D array? -

my task today slice 2d array matches correctly entries in 3d array. example, have 3d array below: [[[ 1.06103295e+02 0.00000000e+00 0.00000000e+00] [ 0.00000000e+00 1.06103295e+02 0.00000000e+00] [ 0.00000000e+00 0.00000000e+00 1.06103295e+02]] [[ 5.09297818e+05 5.09296818e+05 5.09296818e+05] [ 5.09296818e+05 5.09297818e+05 5.09296818e+05] [ 5.09296818e+05 5.09296818e+05 5.09297818e+05]] [[ 5.09297818e+05 5.09296818e+05 5.09296818e+05] [ 5.09296818e+05 5.09297818e+05 5.09296818e+05] [ 5.09296818e+05 5.09296818e+05 5.09297818e+05]] [[ 1.06103295e+02 0.00000000e+00 0.00000000e+00] [ 0.00000000e+00 1.06103295e+02 0.00000000e+00] [ 0.00000000e+00 0.00000000e+00 1.06103295e+02]]] using "numpy.reshape" command, changed 2d array dimensions (12, 3). [[ 1.06103295e+02 0.00000000e+00 0.00000000e+00] [ 0.00000000e+00 1.06103295e+02 0.00000000e+00] [ 0.00000000e+00 0.00000000e+00 1.0610329

android - Why does DbFlow can not save objects without being assigned to a variable? -

code below works expected customer x = new customer(); x.name = "yasin"; x.save(); but leads app crash new customer() { { name = "yasin"; } }.save(); error detail in logcat: com.raizlabs.android.dbflow.structure.invaliddbconfiguration: table: com.example.yasin.myapplication.mainactivityfragment$1$1 not registered database. did forget @table annotation? why happen? bug dbflow or there don't know java language? the error getting because in second case extending customer class using anonymous class , dbflow require classes manages annotated, not case anonymous class created. leads error. solution add constructor taking name parameter can like: new customer("the name").save();

javascript - JQuery/Ajax & Spring Rest Multi-part form submit -

i quite new jquery , trying asynchronous multipart form uploading. form consist of few data fields , file type. have set server side code (spring) this: @requestmapping(method = requestmethod.post) public @responsebody upload multiplesave(multiparthttpservletrequest request) { upload upload = new upload(); iterator<string> iterator = request.getfilenames(); while (iterator.hasnext()) { multipartfile file = request.getfile(iterator.next()); try { system.out.println(messageformat.format("file length: {0}", arrays.tostring(file.getbytes()))); system.out.println("file type: " + file.getcontenttype()); upload.setcontent(file.getbytes()); upload.setdocid(id++); upload.seterror(null); upload.setname(file.getname()); upload.setsize(file.getsize()); file

ios resignFirstResponder of UITextView in cell from accessory toolbar -

i trying edit uitextview inside cell keyboard preserves 'return' key line break & adds 'cancel' & 'done' button in accessory toolbar. looks fine 'sender' parameter in selector pointing uibarbuttonitem , not uitextview in cell program breaks error. how tell selected cell's uitextview resignfirstresponder? // cell accessory toolbar if (!cell) { [tableview registernib: [uinib nibwithnibname:@"customcell" bundle:nil] forcellreuseidentifier:@"customcell"]; cell = [tableview dequeuereusablecellwithidentifier:@"customcell"]; [cell.textview setdelegate:self]; uitoolbar* toolbar = [[uitoolbar alloc]initwithframe:cgrectmake(0, 0, 320, 50)]; toolbar.barstyle = uibarstyleblacktranslucent; toolbar.items = [nsarray arraywithobjects: [[uibarbuttonitem alloc]initwithtitle:@"cancel" style:uibarbuttonitemstylebordered target:self acti

PHP equivalent of angularJS routing -

in angularjs have index page includes header , footer directly, , div such <div ng-view></div> or <section ui-view></section> partial html pages injected based on routing file in app.js. example: .config(function ($stateprovider, $urlrouterprovider) { $stateprovider .state('home', { url: "/home", templateurl: "home/index.html" }) .state('about', { url: "/about", templateurl: "about/index.html" }) .state('contact', { url: "/contact", templateurl: "contact/index.html" }) $urlrouterprovider.otherwise('/home'); }) then whenever clicks hyperlink different part of site, router decides partial gets injected index page. problem urls include hashtags (example.com/#/home) , can rid of configuring website's server run html5mode, can't particular site. so i'm wondering php equiv

How to share host network bridge when using docker in docker -

i'm using https://github.com/jpetazzo/dind docker image have docker in docker. when starting docker containers inside parent docker, possible use bridge of parent docker can share network between containers inside docker container , parent docker container? what want access containers inside parent docker container host directly ip assign domain names them. update -> main idea i'm upgrading free online java compiler allow users run program using docker. i'm using dind (docker in docker image) launch main container have inside java program receive requests , launch docker containers inside of it. want give users option run programs expose port , let them access containers using subdomain. graphically have hierarchy internet -> host -> main docker container -> user docker container 1 -> user docker container 2 -> user docker container n and want give use

Interact with kafka docker container from outside of docker host -

i have built kafka docker container , orchestrate using docker-compose. calling docker ps following putput: container id image command created status ports names 5bde6f76246e hieutrtr/docker-kafka:0.0.1 "/start.sh" hour ago hour 7203/tcp, 0.0.0.0:32884->9092/tcp dockerkafka_kafka_3 be354f1b8cc0 hieutrtr/docker-ubuntu:devel "/usr/bin/supervisor hour ago hour 22/tcp producer1 50d3203af90e hieutrtr/docker-kafka:0.0.1 "/start.sh" hour ago hour 7203/tcp, 0.0.0.0:32883->9092/tcp dockerkafka_kafka_2 61b285f39615 hieutrtr/docker-kafka:0.0.1 "/start.sh" 2 hours ago 2 hours 7203/tcp, 0.0.0.0:32882->9092/tcp dockerkafka_kafka_1 20c9c5cce

paypal - How to pay users on Android -

i know best way this: users of android app gain points use app. can 'check out' points money paypal or bank account the app should take money out of app's paypal account , transfer users bank or paypal account. any suggestions? the payment app users not happen on android app. instead, payment can triggered either user actions (for example clicking on "pay" button) or other events "user has gained enough points , payment done @ end of month", etc. the payment app users' paypal account can done calling paypal payouts api or mass pay api on server . payouts api rest api , mass pay classic uses nvp/soap. check here docs: https://developer.paypal.com/docs/payouts/ the payouts api , mass pay api can used pay lot of people in call, it's recommended list of users , pay them @ same time, say, @ end of week or month. or, in cumbersome way, can have script telling users , how pay periodically, month, , ask customer service person

php - Date column doesn't show right datestamp upon form submit to DB -

for reason or date , time in date column shows 0000-00-00 00:00:00 when submit form db. way can date right updating manually. started doing , i'm not sure changed. i'm having real hard time troubleshooting this. edit form: <?php if(!defined('in_admin')) exit; ?> <div class="page"> <h1 class="edit"><?=ucfirst($mode)?> post</h1> <span class="error-text"><?=$response_text?></span> <form action="admin.php?mode=<?=$mode?>&id=<?=$post['post_id']?>" method="post"> <p> <label for="title">post title:</label><br /> <input type="text" size="80" id="title" name="data[post_title]" value="<?=htmlspecialchars(stripslashes($post['post_title']))?>" /> </p> <p> <label for="title"

node.js - Cannot download Google Cloud Storage file with Node gcloud package -

i have gcloud set in application , seem authenticated. can run following without problem: googlecloud = require('gcloud')({ /* credentials */ }); googlecloud.storage().createbucket('mybucket', function (err, res) {}); i can following retrieve bucket , file without problem: var bucket = googlecloud.storage().bucket('mybucket'); var file = bucket.file('myfilename.ext'); and when file.getmetadata() , see empty object convert expected information. however, when attempt download file, problems. var pathtofilename = 'public/test.pdf'; file.download({ destination: pathtofilename }, function (err) { console.log(err); }); { [error: enoent, open '/public/test.pdf'] errno: 34, code: 'enoent', path: '/public/test.pdf' } i have tried prepending pathtofilename / , ./ , , ../ no success. same error have have gotten in past configuration not authorized or file name incorrect (although unable create buckets , metadata)

arm - Inline aarch64 assembly UMOV source syntax -

below attempt @ implementing fast popcount aarch64 using neon: #include <stdio.h> int count_bits(unsigned long long val) { unsigned long long p = 0; int c = 0; __asm__("dup %0.2d, %2 \n\t" "cnt %0.8b, %0.8b \n\t" "addp d0, %0.2d \n\t" "umov %1, d0 \n\t" : "+w"(p), "+r"(c) : "r"(val) : "d0"); return c; } int main(int argc, const char *argv[]) { printf("test: %i\n", count_bits(-1ull)); return 0; } and error: $ gcc test.c -o test error: operand 2 should simd vector element -- `umov x0,d0' i'm not sure addp instruction, specifier suggests adds 2 dwords, result of cnt instruction stored 8 bytes ( %0.8b in addp doesn't work). shouldn't rather use uadalp summing components ? error: operand 2 should simd vector element -- `umov x0,d0' ("simd vector elemen

How to compress imported column types in R -

my code importing specific file far looks like df <- read_excel("file path", col_types = c("numeric", "text", "numeric", "numeric", "numeric", "numeric", "text", "text", "text", "text", "text", "text", "text", "text", "text", "text", "text", "text", "text", "text", "text", "text", "text", "text", "text", "text", "text", "text", "text", "text", "text", "text", "text", "text", "text", "text", "text", "text", "text", "text", "text", "text", "text", "text", "text"

PHP, remove all global variables in the global scope -

i want able flush variables in global scope using single function 1 call unset(). want keep variables exist in _get, _post, _request, _cookie, _server, _env, _files, _session, , remove variables exist in $globals[variable]. $globals contained... <php> array ( [globals] => array *recursion* [_post] => array ( ) [var_3] => array ( ) [_get] => array ( ) [_cookie] => array ( ) [_server] => array ( [https] => on [appl_md_path] => /docs/ [appl_physical_path] => /www/docs/ [instance_id] => 1 [instance_meta_path] => / [logon_user] => [request_uri] => /test.php [url] => /test.php [script_filename] => /www/docs/test.php [document_root] => /www/docs/ [php_self] => /test.php [http_host] => localhost ) [_env] => array ( ) [_files] => array ( ) [_request] => array

Can I use the result of a select statement from mysql to compare it with a variable? -

i have following code in stored procedure: set cont_email = select email contacts id=in_id; if in_customer_email = cust_email **do something** so, wondering if instead of creating local variable , storing result select statement paste directly in if statement so: if in_customer_email = (select email contacts id=in_id) **do something** also, wondering how can use ors in mysql. can this? if in_customer_email = customer_email or in_customer_name = customer_name i have seen use of or this: select customer_id, customer_name customers (customer_name = 'apple' or customer_name = 'samsung') but never inside of if statement, wasn't sure. and lastly, has been ages since use if var1 = var2 , since used assigning not compare, wondering if correct or have use double equal sign var1 == var2 . thanks. variable vs. nested statement? if in_customer_email = (select email contacts id=in_id) **do something** this legal query -- no need

jsf 2 - Invoke method with varargs in EL throws java.lang.IllegalArgumentException: wrong number of arguments -

i'm using jsf 2. i have method checks matching values list of values: @managedbean(name="webutilmb") @applicationscoped public class webutilmanagedbean implements serializable{ ... public static boolean isvaluein(integer value, integer ... options){ if(value != null){ for(integer option: options){ if(option.equals(value)){ return true; } } } return false; } ... } to call method in el tried: #{webutilmb.isvaluein(otherbean.category.id, 2,3,5)} but gave me a: severe [javax.enterprise.resource.webcontainer.jsf.context] (http-localhost/127.0.0.1:8080-5) java.lang.illegalargumentexception: wrong number of arguments is there way execute such method el? no, not possible use variable arguments in el method expressions, let alone el functions. your best bet create multiple different named methods different amount of fixed arguments. public static boolean isvaluein2(integer val

java - Where the tomcat location when running application with broadleaf -

i trying run simple demo application of broadleaf. running app, want access using pc except this. have change settings in tomcat not able find tomcat located , server.xml file located can kind of changes in server in order make running on pc using public ip. the latest version of broadleaf (broadleaf-4.0.0-ga) uses tomcat7-maven-plugin demo site, run embedded tomcat instance. if need custom server.xml please refer question . you can find tomcat-maven config in pom.xml of site project. <plugin> <groupid>org.apache.tomcat.maven</groupid> <artifactid>tomcat7-maven-plugin</artifactid> <configuration> <path>/</path> <port>${httpport}</port> <httpsport>${httpsport}</httpsport> </configuration> </plugin> update required changes link above.

arraylist - java.util.ConcurrentModificationException with nested loop remove call -

trying code run receiving java.util.concurrentmodificationexception error when running. think because using nested loops on same arraylist , deleting index of both "concurrently". how avoid problem? in advance . for(iterator<missile> iteratori = missiles.iterator(); iteratori.hasnext();) { missile missile = iteratori.next(); if(missile.type == 2) { for(iterator<missile> iteratorj = missiles.iterator(); iteratorj.hasnext();) { missile missilej = iteratorj.next(); if(missilej.equals(missile)){ continue; } double cal1 = missilej.xpos - missile.xpos; double cal2 = missilej.ypos - missile.ypos; double radius = math.sqrt(cal1*cal1 + cal2*cal2); if(radius < missile.blastradius) { //collision detection throwing array out of bounds errors

node.js - Porting express generated folder vs fresh npm install? -

i "express generated" folder on ubuntu , synced git. now, have need work on mac. can pull folder git onto mac, assume important stuff (for instance node_modules) ported , continue working on there? or have fresh npm install using package.json? if there native addons in modules (compiled modules) you'll need fresh install (at least on those) wont binary-compatible.

c++ - SFML only draws some sprites -

i'm having strange problem 1 sprite loading isn't here main.cpp window.draw(universe.getplayer()->draw()); //draw player std::list<abstractblock*>::const_iterator i; std::list<abstractblock*>* values = universe.getloadedblocks(); (i = values->begin(); != values->end(); ++i){ window.draw((*i)->draw()); //draw blocks } window.display(); here can see player drawing , blocks in universe drawing. however, player draws , blocks don't draw @ all. have made sure loop working. because draw() returns void can't see if working or not. here dirtblock.cpp (i'm inheriting abstractblock) dirtblock::dirtblock(int x, int y, float rotation, b2world *world){ bodydef.position.set(x, y); bodydef.lineardamping = .03f; bodydef.type = b2_dynamicbody; fixdef.density = .1f; b2polygonshape shape; shape.setasbox(16, 16); fixdef.shape = &shape; body = world->createbody(&bodyd

javascript - Remove blank space below and above google graph? -

Image
i have used google graph on particular page after few contents. number of rows(data) in google graph increases, space between content , graph increases. have tried modify height, no result. here code - function drawchart() { var data = new google.visualization.datatable(); data.addcolumn('string', 'projects'); data.addcolumn('number', 'hours'); var monthdata = jquery(".slick-active").html(); var monthtemp = monthdata.tostring().split(" "); var month = getmonthfromstring(monthtemp[0]); var year = monthtemp[1]; var tag = $("#tagval").val(); var jsondata = jquery.ajax({ url: "/report/additionalprojecthours", type: "post", datatype: "json", async: false, data: {month: month, year: year, tag:tag}, beforesend: function (request) {

class - How to get Model Object using its name from a variable in Laravel 5? -

i trying information model using name sent parameter blade using ajax call. $.get("{{ url('auditinformation')}}", {modelname: modelname,versions:versions,currentdata:currentdata[index]}); now need retrieve information using modelname model. so when tried this: $auditinfo=input::all(); $modelname=$auditinfo['modelname']; $values=$modelname::find(1); i got response class 'designation' not found but if use $modelname=new designation(); $values=$modelname::find(1); then shows data want. so understand model ( class ) object. is there way assign object $modelname using $auditinfo['modelname'] . thanks if want way, should use model's namespace. for example, if 'destination' model's namespace app\destination, should use : $auditinfo=input::all(); $appprefix = 'app'; $modelname=$appprefix . '\' . $auditinfo['modelname']; $values=$modelname::find(1);

swift - Rotating UITextView programmatically -

Image
there weird problem, if create uitextview , rotate right after creating it, lines or characters not visible! try this: mytextview.font = uifont.boldsystemfontofsize(20) mytextview.text = "hello world wht hell\nhello mrs lorem ipum!" let maxsize = cgsizemake(700, 700) let frame = mytextview.sizethatfits(maxsize) mytextview.frame = cgrectmake(200, 200, frame.width, frame.height) view.addsubview(mytextview) mytextview.transform = cgaffinetransformmakerotation(cgfloat(m_pi_2)) result: you see? of lost! if remove mytextview.transform = cgaffinetransformmakerotation(cgfloat(m_pi_2)) , run through button it's fine: you can view code on git: https://github.com/maysamsh/rotatetextview as workaround, try set uitextview in simple uiview , , rotate uiview . it should because way, uitextview should react it's not rotated (so can set inset constraints superview) then have care form of superview. other solution mytextview.font = uifont.boldsy

ios - In what cases will a 'release' call recur? -

i have segmentation fault ( sigsegv ) following stack-trace: thread 6 crashed: 0 libobjc.a.dylib objc_msgsend (in libobjc.a.dylib) + 16 1 coredata -[nsmanagedobject release] (in coredata) + 160 2 libobjc.a.dylib object_cxxdestructfromclass(objc_object*, objc_class*) (in libobjc.a.dylib) + 148 3 libobjc.a.dylib objc_destructinstance (in libobjc.a.dylib) + 92 4 coredata _pfdeallocateobject (in coredata) + 28 5 myapp -[job dealloc] (in myapp) (job.m:113) 6 coredata -[_pfmanagedobjectreferencequeue _queuefordealloc:] (in coredata) + 272 7 coredata -[nsmanagedobject release] (in coredata) + 160 8 coredata -[_pfarray dealloc] (in coredata) + 100 9 libobjc.a.dylib (anonymous namespace)::autoreleasepoolpage::pop(void*) (in libo

scala - Why does using custom case class in Spark shell lead to serialization error? -

for life of me can't understand why not serializable. i'm running below in spark-shell (paste mode). i'm running on spark 1.3.1, cassandra 2.1.6, scala 2.10 import org.apache.spark._ import com.datastax.spark.connector._ val driverport = 7077 val driverhost = "localhost" val conf = new sparkconf(true) .set("spark.driver.port", driverport.tostring) .set("spark.driver.host", driverhost) .set("spark.logconf", "true") .set("spark.driver.allowmultiplecontexts", "true") .set("spark.cassandra.connection.host", "localhost") val sc = new sparkcontext("local[*]", "test", conf) case class test(id: string, creationdate: string) extends serializable sc.parallelize(seq(test("98429740-2933-11e5-8e68-f7cca436f8bf", "2015-07-13t07:48:47.924z"))) .savetocassandra("testks", "test", somecolumns("id", "creationda

csv - Getting wrong results with awk -

i have dataset trying select rows values in column called ambienf greater 20. first, find column number: $ csvcut -n head.csv | grep ambienf 287: ambienf next, @ values: $ csvcut -c name,ambienf head.csv | head -n 25 | csvlook |-----------+-------------------| | name | ambienf | |-----------+-------------------| | 87892625 | | | 87881401 | 31.3340396881104 | | 87881407 | 23.3398342132568 | | 87881397 | | | 87892628 | | | 87892632 | | | 87881394 | 28.8716373443604 | | 87790338 | | | 87797472 | | | 87788161 | 32.2283515930176 | | 87790894 | 32.7088813781738 | | 87871678 | 25.5556793212891 | | 87767487 | 33.3377380371094 | | 87759792 | | | 87751064 | | | 87772221 | | | 87751071 | | | 87751061 | | | 87751067 | | | 87772224

tortoisesvn - Merge info not getting recorded in mergeinfo property -

i have merge code branch trunk using svn merge tool (not svn merge command using ui). use tortoisesvn . when run following command svn propget svn:mergeinfo <<url_to_trunk>> cannot see merge information getting recorded in mergeinfo property. if use command branch url cannot see recorded merge info. i read following line in snv book . the svn:mergeinfo property automatically maintained subversion whenever run svn merge. does mean mergeinfo property updated when merge done using svn merge command command line , not merge using ui? if not why cannot see merge info using svn propget svn:mergeinfo <<url_to_trunk>> ? the svn:mergeinfo property should correctly added merged files when using tortoisesvn. should run "svn propget" command on merged files in working copy, see svn:mergeinfo property.

c# - Multi-Mapper in Dapper one to many relations -

Image
i trying value of database relation 1 many have object this student [table("student")] public class student : istudent { public int id { get; set; } public string lastname { get; set; } public string firstmidname { get; set; } public datetime? enrollmentdate { get; set; } [write(false)] public ienumerable<enrollment> enrollments { get; set; } } enrollment [table("enrollment")] public class enrollment { public int id { get; set; } public int courseid { get; set; } public int studentid { get; set; } public string grade { get; set; } public virtual course course { get; set; } public virtual student student { get; set; } } course [table("course")] public class course { public int id { get; set; } public string title { get; set; } public int credits { get; set; } public virtual ienumerable<enr