Posts

Thread 1 Signal SIGABRT iOS -

import uikit @uiapplicationmain class appdelegate: uiresponder, uiapplicationdelegate { var window: uiwindow? func application(application: uiapplication, didfinishlaunchingwithoptions launchoptions: [nsobject: anyobject]?) -> bool { // override point customization after application launch. return true } func applicationwillresignactive(application: uiapplication) { // sent when application move active inactive state. can occur types of temporary interruptions (such incoming phone call or sms message) or when user quits application , begins transition background state. // use method pause ongoing tasks, disable timers, , throttle down opengl es frame rates. games should use method pause game. } func applicationdidenterbackground(application: uiapplication) { // use method release shared resources, save user data, invalidate timers, , store enough application state information restore application current state ...

java - Android how to use Environment.getExternalStorageDirectory() corretly -

android how use environment.getexternalstoragedirectory() how can use environment.getexternalstoragedirectory() read/write image sd card ? or there better way it? i did use source download e save image: try { url url = new url(urlbaseimagem + icone); urlconnection conection = url.openconnection(); conection.connect(); // useful can show tipical 0-100% progress bar int lenghtoffile = conection.getcontentlength(); // // download file inputstream input = new bufferedinputstream(url.openstream(), 8192); // output stream //file sdcard = environment.getexternalstoragepublicdirectory(download_service); file sdcard = environment.getexternalstoragedirectory(); file directory = new file(sdcard.getabsolutepath() + "/cardapioweb/rest/"); if(directory.exists() == false){ directory.mkdirs(); } file outputfile = new file(direc...

unity3d - Camera rotation within a prefab -

Image
i trying create multiplayer game in unity3d using diablo camera system. wherever click on screen. system working fine in singleplayer did not need include camera in player prefab. facing problem camera rotation affected rotation of prefab parent. hierarchy looks this: there script added camera looks this: using unityengine; using system.collections; public class maincameracomponent : monobehaviour { public gameobject reaper; private vector3 offset; void start () { offset = transform.position - reaper.transform.position; } // update called once per frame void lateupdate () { transform.position = reaper.transform.position + offset; } } when run game camera stays behind character, while want stay @ same rotation. if order character walk north see back, if walk south wanted see front. notice how shadow changes, (thus rotation) face of model. tldr: want child camera ignore rotational change of parent , static. whilst letting camera position guided parent. far k...

Java exceptions contract of Iterator remove -

i'm implementing iterator utilises iterator, of not know, whether supports remove() method or not. consider following edge case: underlying iterator not support remove() , iterator next() has not yet been called. do violate interface contract, if remove() throws – in situation – illegalstateexception instead of unsupportedoperationexception ? (as next() called, underlying remove() can called, throw appropriate unsupportedoperationexception .) if so, how refactor code check whether underlying iterator supports remove() or not? an example: <t> iterator<t> getsetviewiterator(collection<t> collection) { iterator<t> uniqueitr = new hashset<>(collection).iterator(); return new iterator<t>() { private t current = null; private boolean hasremoved = true; @override public boolean hasnext() { return uniqueitr.hasnext(); } @override public t nex...

r - When using ggplot2, can I set the color of histogram bars without potentially obscuring low values? -

Image
when calling geom_histogram() color , , fill arguments, ggplot2 confusingly paint whole x-axis range, making impossible visually distinguish between low value , 0 value. running following code: ggplot(esubset, aes(x=exectime)) + geom_histogram(binwidth = 0.5) + theme_bw() + scale_x_continuous(breaks=seq(0,20), limits=c(0,20)) will result in this visually unappealing. fix that, i'd instead use ggplot(esubset, aes(x=exectime)) + geom_histogram(binwidth = 0.5, colour='black', fill='gray') + theme_bw() + scale_x_continuous(breaks=seq(0,20), limits=c(0,20)) which result in the problem i'll have no way of distinguishing whether exectime contains values past 10, few occurrences of 12, example, hidden behind horizontal line spanning whole x-axis. use coord_cartesian instead of scale_x_continuous . coord_cartesian sets axis range without affecting how data plotted. coord_cartesian , can still use scale_x_continuous set breaks , coord...

javascript - Angular 2 retrieve selected checkboxes -

i have checkbox (a customer may have many accessories): customer.component.html: <div class="checkbox" *ngfor="let accessory of accessories"> <label> <input type="checkbox" [(ngmodel)]="accessory.selected" (ngmodelchange)="oncheckboxchange(accessory)"> {{ accessory.name }} </label> </div> customer.component.ts: oncheckboxchange(accessory: any) { if (accessory.selected == true) { this.selectedaccessories.push(accessory); } else { let = this.selectedaccessories.indexof(accessory); if (i != -1) { this.selectedaccessories.splice(i, 1); } } } i have method can save selected checkboxes in 1 array example: customer: customer; accessories: any[]; selectedaccessories: any[]; ngoninit() { this.accessoryservice.get().subscribe( accessories => this.accessories = accessories ) if (this.routeparams.get('id')) { let id = th...

escaping in awk and bash script -

i'm trying change numbers in column 2, 3, , 4 of files. that, have following script for in 0.8 0.9 1 1.1 1.2; original=10.9398135077 fraction=`bc <<< "$i*$original"` convert=0.529177 awk '{printf "%-2s %10.5f %10.5f %10.5f\n", $1, ($2*"\$fraction"*"\$convert"), ($3*"\$fraction"*"\$convert"), ($4*"\$fraction"*"\$convert")}' temp2_${i}.txt > coord_${i}.txt done and temp2_0.8.txt looks following: cu -0.000000000 0.000000000 -0.000000000 cu 0.500000000 -0.000000000 0.500000000 cu 0.000000000 0.500000000 0.500000000 cu 0.500000000 0.500000000 0.000000000 s 0.398420013 0.398420013 0.398420013 s 0.898420013 0.398420013 0.101579987 s 0.398420013 0.101579987 0.898420013 s 0.101579987 0.898420013 0.398420013 s 0.601579987 0.601579987 0.601579987 s 0.898420013 0.101579987 0.601579987...