Posts

Showing posts from March, 2011

javascript - How to access res.locals on client-side -

i'm attempting pass req.user details client-side angular code using res.locals in express route: 'use strict'; var path = require('path'); var player = function(req, res) { res.locals.player = req.player; res.sendfile(path.join(__dirname, '../assets', 'index.html')); }; module.exports = { player: player }; the html renders expected, i'm not sure how access res.locals.player now.

c - I can't remove the spaces from a string -

i'm doing this challenge on reddit. now problem on bottom of program (unfinished), posted whole thing in case might have top of it. now i'm trying remove spaces string user supposed enter, putting non-space characters character array. however, every time print try print string supposed removed spaces, prints first word. i, however, want print words 1 single combined word. for example, when try convert hello world! , it's supposed give me helloworld! , it's giving me hello . i've tried different methods pointers , whatnot , every time face same problem. what's going on here? #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> int main(void) { char stringtobepacked[100]; //this string user puts in char stringtobepackedwospaces[100]; //this gonna string without spaces int , o , p; //incrementers/counters double amtfchrsnstrng; //ask user sentence input: printf("please type

pickadate - jQuery - getting text from attribute -

i'm using plugin called pickadate , i'm trying aria label text chosen date , apply onto div. im able retrieve value once if click on day date in #date doesn't update? http://jsfiddle.net/mg6fxqbe/ var $elements = { datepicker: $('.js-datepicker'), }; $elements.datepicker.pickadate(); $('.picker__day').on('click', function () { var date = $(this).attr('aria-label'); $('#date').empty().text(date); }); as described in docs datepicker plugin can use onset event retrieve current date has been set. the onset event callback passed context argument provides details properties being “set”. within scope of 6 of these events, this refers picker. $('.js-datepicker').pickadate({ onset: function() { $('#date').text(this.$node.val()); } }); #date{ font-weight:bold; font-size:40px; margin:20px 0; } <script src="https://ajax.googleapis.com/ajax/

virtual machine - Moving VirtualBox vhd to another location causes issue with uuid issues with the vhd -

Image
i have installed 1 virtual machine disk on c: drive. got annoyingly full , had move vhd. location: c:\..\vms\vm1 f:\..\vms\vm2 then regenerated uuid hd (ran admin privileges): c:\..\virtualbox> .\vboxmanage.exe internalcommands sethduuid "f:\..\.vmdk" uuid changed to: 6d201451-721c-433b-98a3-6fef07e61feb however when try attach moved disk error (below). my vagrantbox.xml not contain uuid's specified in error. o have tried variations restart of whole here is: <?xml version="1.0"?> <!-- ** not edit file. ** if make changes file while virtualbox related application ** running, changes overwritten later, without taking effect. ** use vboxmanage or virtualbox manager gui make changes. --> <virtualbox xmlns="http://www.innotek.de/virtualbox-settings" version="1.12-windows"> <global> <extradata> <extradataitem name="gui/detailspageboxes" value="general,preview,system,

c# - Refactor multiple goto statements from the loop body -

i struggling replicate following fortran 77 subroutine c# method. main problem trying rid of fortran's goto statements. the fortran c# conversion looks fine, still goto statements remained. there way of them can replaced conditionals or other ways? thank you. here fortran subroutine: c program temp subroutine temp (acl,adu,aeff,c,cair,cb,cbare, + cclo,count1,csum,di,ed,emcl,emsk,enbal, + enbal2,ere,erel,esw,eswdif,eswphy,eswpot, + evap,facl,fcl,fec,feff,food,h,hc,he,ht,htcl,icl,j, + mbody,p,po,r1,r2,rbare,rcl, + rclo,rclo2,rdcl,rdsk,rob,rsum,sex,sigm,sw,swf,swm, + ta,tbody,tcl,tcore,tmrt,tsk,v,vb,vb1,vb2, + vpa,vpts,wetsk,wd,wr,ws,wsum,xx) real acl,adu,aeff,c(0:10),cair,cb,cbare, + cclo,csum,di,ed,emcl,emsk,enbal, + enbal2,ere,erel,esw,eswdif,eswphy,eswpot, + evap,facl,fcl,fec,feff,food,h,hc,he,ht,htcl,icl, + mbody,p,po,r1,r2,rbare,rcl, + rclo,rclo2,rdcl,rdsk,rob,rsum,sigm,sw,swf,swm,

javascript - Jquery focus on next td element with an input child -

i have table tr , td elements so. <tr> <td><input type="text"></td> <td><input type="text"></td> <td></td> <td></td> <td><input type="text"></td> </tr> some tds have input elements , don't. using jquery, how focus next input while skipping td's without input fields? i have tried this: $(':focus').parent().next("td:has(input)").focus(); with no success. the end goal able use keybindings have created cycle forwards , backwards through inputs without using 'tab' key. .next checks element's immediate next sibling, not check of successive siblings. if want check of it's siblings, 1 solution first element of .nextall $(':focus').parent().nextall("td:has(input)").eq(0).focus();

windows - Why is command start with parameter /wait not working properly? -

ok racking brain!!! have 1 batch file start batch file every time run batch file open command window title being batch file located. here batch file that's preforming start /wait command: ::------------------------------ configure power settings --------------------------- @echo off start /wait "%~d0\setup_postop\01 configure power settings\always on.bat" ::------------------------------ programs , features ------------------------------ start /wait "%~d0\setup_postop\02 uninstall unwanted software\programs , features.bat" the above batch file supposed run "always on" batch file open command window. here "always on" batch file trying start: @echo off echo not close!!! %windir%\system32\powercfg.exe /import "%~d0\setup_postop\01 configure power settings\alwayson.pow" 2f5ac084-2edf-444a-b1b9-8de872cf798e %windir%\system32\powercfg.exe /setactive 2f5ac084-2edf-444a-b1b9-8de872cf798e start /wait %windir%\system32\power

c# - Timer in foreach with ManualResetEvent -

when click button, cycle starts read database , send each row of query server. when response - cycle continues. code implemented follows private manualresetevent _mre = new manualresetevent(true); and thread startupload = new thread(() => { //read database foreach (datarow dr in dt.rows) { //send request _mre.waitone(); } }); startupload.start(); the problem when requests sent may not answer. in case normal. if not, answer comes, cycle stops. need inside loop timer, in case of stopping cycle due lack of response continue cycle in 30 seconds. the timer have do _mre.set(); important: you're setting manualresetevent initial state true , set false if you're willing stop current process , wait signal. edit: example private manualresetevent _mre = new manualresetevent(false); private void readthedatabase() { thread startupload = new thread(() => { // read data foreach (datarow

Drupal Generating nodes in a nightly cron Job -

what should best of generating nodes csv file in nightly cron job? there module doing or better programatically create content using node_save in hook_cron() function? you can use drupal feeds module achieve this. feeds can periodically import entities data source (eg. csv or rss feed). if node-processor of feeds module not fit requirements, should try create custom module suggested.

java - Remove element from ArrayList using ListIterator in loop inside loop -

my requirement remove arraylist this: arraylist<user> user = new arraylist<user>(); listiterator<user> outeriterator = null; listiterator<user> inneriterator = null; user outer = null; user inner = null; for(outeriterator = user.listiterator(); outeriterator.hasnext();) { outer = outeriterator.next(); for(inneriterator = user.listiterator(); inneriterator.hasnext();) { inner = inneriterator.next(); if(someoperationon(outer,inner)) { inneriterator.remove(); } } } above code giving exception exception in thread "main" java.util.concurrentmodificationexception as expected, because trying remove inneriterator while outeriterator iterator on same object(user). is there way remove element arraylist using listiterator in loop inside loop? in isolation, calling remove() on iterator proper way avoid concurrentmodificationexception when removing item collection you're iterating. ho

libxml2 - Perl libXML find node by attribute value -

i have large xml document iterating through. xml's use attributes rather node values. may need find numerous nodes in file piece 1 grouping of information. tied via different ref tag values. each time need locate 1 of nodes extract data looping through entire xml , doing match on attribute find correct node. there more efficient way select node of given attribute value instead of looping , compare? current code slow useless. currently doing numerous times in same file numerous different nodes , attribute combinations. my $searchid = "1234"; foreach $nodes ($xc->findnodes('/plm:plmxml/plm:externalfile')) { $id = $nodes->findvalue('@id'); $file = $nodes->findvalue('@locationref'); if ( $searchid eq $id ) { print "the file name = $file\n"; } } in above example looping , using "if" compare id match. hoping below match node attribute instead... , more efficient looping? my

laravel - Automatic eager loading? -

rather doing (which dozens of times across site): $posts = post::with('user') ->with('image') ->get(); is possible automatically call with('image') whenever with('user') called? in end, just: $posts = post::with('user') ->get(); and still eager load image ? add following in model: protected $with = array('image'); and should trick. the $ with attribute lists relations should eagerly loaded every query.

java - Cannot query for chrome's bookmarks when it is close -

in android app, user supposes search bookmarks in chrome browser. found once turn off browser, query "null" cursor.(works fine when chrome running in background) here code:(query bookmarks) resultcursor = context.getcontentresolver().query(browser.bookmarks_uri, new string[] {browser.bookmarkcolumns.title,browser.bookmarkcolumns.url}, null, null, sortorder); there no permission warning in log. i tried replace content provider uri "content://com.android.chrome.browser/bookmarks" , same problem. wonder if there wrong in query code, or bug @ chrome side. thanks. it should chrome issue. reference: code.google.com/p/chromium/issues/detail?id=497538

c# - Get the value from the CheckBox Control -

how can value checkbox control before selected?? doesn´t have .value method. else if (c.gettype() == typeof(checkbox)) // c control { string textvalue= ((checkbox)(c)).text; // here take text string value= ((checkbox)(c)).????; //how should take value? try : ((checkbox)(c)).checked.tostring()

objective c - UIRefreshControl offset changes after loading new items to UITableView -

i added uirefreshcontrol uitableview. the uitableview under top bar. everything works fine except when new items being loaded. example, if table had 1 row , now, after reloading data there 2 rows. after table being reloading, uirefreshcontrol offset isn't in 0 position of uitable adding bar height user needs pull not height of uirefreshcontrol height of top bar. after loading again same data, uirefreshcontrol ok. - (void)viewdidload { [super viewdidload]; [self setrefreshcontrol]; } -(void)setrefreshcontrol { refreshcontrol = [[uirefreshcontrol alloc]init]; refreshcontrol.tintcolor=[uicolor redcolor]; [self.campaignstableview addsubview:refreshcontrol]; [refreshcontrol addtarget:self action:@selector(refreshtable) forcontrolevents:uicontroleventvaluechanged]; }

javafx 8 - External font not applied by CSS -

i'm trying create icon buttons. i've downloaded them flaticon.com , had them exported icon font files, includes ttf file. in css file specify external font as: @font-face { font-family: flaticon; src: url('/flaticon/flaticon.ttf'); } i've defined button class should use font follows: .flaticon-button { -fx-font-size: 90px; -fx-font-family: flaticon; -fx-padding: 10px; } my code applies styleclass follows: button button = new button("\ue000"); button.getstyleclass().add("flaticon-button"); but unfortunately doesn't show expected icon. when load font in code , set explicitly correct icon shown: font font = font.loadfont(this.getclass().getresource("/flaticon/flaticon.ttf").toexternalform() , 90d); button button = new button("\ue000"); button.setfont(font); i'm overlooking small, despite how many examples browse on internet, or how long stare @ oracle's css documentation can't s

excel - Export hashtable to CSV with the key as the column heading -

i have script create hashtable usernames key , array of groups value. here looks like: name value ---- ----- user1 {domain users, group2, group3} user2 {domain users, group4} user3 {domain users, group2, group3, group4} how can export csv file using username heading? when import csv file excel want this: b c ------------------------------------------- 1 | user1 user2 user3 2 | domain users domain users domain users 3 | group2 group4 group2 4 | group3 group3 5 | group4 i have played around export-csv cannot work type of hashtable. to able arrays columns need "transpose" hashtable, meaning need build individual objects have usernames (the keys of hashtable) properties. number of objects need create defined maximum nu

What is the best way to copy but not clone a function in javascript? -

given have declared function in of foo = function f() {} how can copy but not clone function. example code below each time 1 calls function log() argument argument added array log.list list can shown calling function log.alert() . how can 1 declare new variable log2 copy functionality of log function remain independent of it? i.e independent list maintained log , log2 , calling log2.alert() log2.list shown , calling log.alert() log.list shown? var log = log || function f (x) { f.list = f.list || []; if (x != undefined) f.list.push(x); if (!f.fired) { f.alert = function () { alert (f.list.join("\n")); } f.reset = function () { f.list = []; } f.fired = true; } } // demonstrate function log("log #1"); log("log #2"); log("log #3"); log("log #4"); log.alert(); this ones bit tricky. you've half described factories , functions retur

tld - Loading a map only once in application life cycle by reading a file in c++ -

i want load map reading file in application startup, , want utilize map in other class particular string , execute logic. loading of map should done once in application life cycle. would know best approach declare map , access in other logic. best approach load once const std::map<key_type,value_type>& themap = loadmap(); and pass const reference other functions: std::map<key_type,value_type>::const_iterator find_key(key_type key, const std::map<key_type,value_type>& map) { return map.find(key); }

microchip - dsPIC33EV256GM002 PWM settings -

i developed simple program produce pwm waveform on dspic33ev256gm002 can't disable it. used pwm1 , pwm2 , generate pwm waveform on pwm1l1 pin (pin 26 on dip package) maintain pwm1h1 (pin 25 on dip package) digital i/o. teorically pwm register setting: iocon1bits.penl = 1; /* pwm1l controlled pwm module / iocon1bits.penh = 0; / pwm1h controlled gpio module */ should but, using , oscilloscope, noticed pwm waveform on pwm1h1 pin, opposite value (when pwm1l 1 pwm1h 0 , veceversa) if should digital i/o. did find similar problem ? thank , cooperation regards i used following code: trisbbits.trisb10 = 0; /* set digital output */ trisbbits.trisb11 = 0; /* set digital output */ trisbbits.trisb12 = 0; /* set digital output */ trisbbits.trisb13 = 0; /* set digital output */ trisbbits.trisb14 = 0; /* set digital output */ trisbbits.trisb15 = 0; /* set digi

Android - BroadcastReceiver EXTRA_SUPPLICANT_ERROR missing -

i have broadcastreceiver: private broadcastreceiver broadcastreceiverwifi = new broadcastreceiver() { @override public void onreceive(context context, intent intent) { if (intent.getaction() == wifimanager.supplicant_state_changed_action) { int error = intent.getintextra(wifimanager.extra_supplicant_error, -1); } in android 4.1.2, 4.4.2 works in android 4.0.3 return -1 (when passwork wrong)

java - What does a Swing Call mean? -

i have project takes time load create splash screen tells user through progressbar how time take load , show ui, i'm facing problem. when create splash, shows correctly create , initialize principal frame , freeze until has load. so, try load principal frame in thread using swingworker (and works) after unknown nullpointerexception s , reading lot found terrible idea because not creating ui in edt, here stuck. i know must swing calls in event dispatch thread (edt) , non-swing heavy work in swingworkers initialize swing components of principal frame heavy work so, should do? i have read question here, specially this , , think have doubts. taking example: swingutilities.invokeandwait(new runnable() { public void run() { new splashscreen(); } }); // code start system (nothing touches gui) swingutilities.invokeandwait(new runnable() { public void run() { new mainframe(); } }); //.. etc and reading this site says: the swing framewo

javascript - Delete object from ImmutableJS List based upon property value -

what simplest way delete object list based on value of property? i'm looking equivalent of $pull in mongodb. my list looks simple this: [{a: '1' , b: '1'},{a: '2' , b: '2'}] and i'd remove array object property a set '1'. in mongodb, i'd this: model.update({_id: getcorrectparentobj},{ $pull: {listideletefrom: { a: '1' } } },(err, result)=>{}); how can same result immutablejs? you filter immutable list: var test = immutable.list.of(immutable.map({a: '1'}), immutable.map({a: '2'})); test = test.filter(function(item) { return item.get('a') !== '1' }); however, filter on non-empty list result different immutable list, may want check occurrence of {a: 1} first: if (test.some(function(item) { return item.get('a') === '1'; })) { test = test.filter(function(item) { return item.get('a') !== '1' }); }

javascript - jQuery AJAX: Posting serialized form data with $.post() does not achieve the same result as $.ajax() -

Image
i trying post data source sending form's data using jquery's shorthand method jquery.post() not capable achieve same result using full blue-print posting jquery.ajax() . please find below scripts i've used findings: using $.post(): jquery.post( "/full-path-to-service", { cache: false, data: jquery(submittingform).serialize(), _: jquery.now() }, null, "json" ).done(function(data) { // response handling }); using $.ajax(): jquery.ajax({ type: "post", url: "/full-path-to-service", data: jquery(submittingform).serialize(), datatype: "json", _: jquery.now() }).done(function(data) { // response handling }); while able receive successful response server, service seemed not being fired not receiving information sent serialized in post request. sniffing information being sent service able confirm information parsed incorrectly while using jquery.post .

python 2.7 - django admin load error: ImportError at /admin/login/ No module named backends -

all of sudden, don't seem able access admin on django app. here's error message i'm getting, idea have happened? don't think changed admin or settings data since last opened it. importerror @ /admin/login/ no module named backends request method: post request url: http://localhost:8000/admin/login/?next=/admin/ django version: 1.9.dev20150119161257 exception type: importerror exception value: no module named backends exception location: /system/library/frameworks/python.framework/versions/2.7/lib/python2.7/importlib/ init .py in import_module, line 37 python executable: /usr/bin/python python version: 2.7.6 python path: ['/users/saraabi/sites/django_testapp', '/library/python/2.7/site-packages/pip-6.0.6-py2.7.egg', '/users/saraabi/django-trunk', '/system/library/frameworks/python.framework/versions/2.7/lib/python27.zip', '/system/library/frameworks/python.framework/versions/2.7/lib/p

Polymer 1.0 Custom Element Using paper-dialog- better way to do this? -

i have custom element video-player uses paper-dialog . they way now, seems kind of hacky. have external button(it has external button design) opens with: bob = polymer.dom(this.root).queryselector('video-player'); bob.queryselector('paper-dialog').open() <link rel="import" href="../bower_components/paper-dialog/paper-dialog.html"> <link rel="import" href="../bower_components/paper-icon-button/paper-icon-button.html"> <link rel="import" href="../bower_components/iron-icons/iron-icons.html"> <link rel="import" href="../bower_components/google-youtube/google-youtube.html"> <link rel="import" href="../bower_components/polymer/polymer.html"> <dom-module id="video-player"> <template> <paper-dialog> <div class="layout horizontal"> <paper-button dialog-dismiss>

java - Error occurred during initialization of VM Unable to load native library: Can't find dependent libraries [Compiling C file, JNI] -

i implementing "reverse" jni call java c following tutorial: how call java functions c using jni . whenever compile file, "ctest.cpp", , run "ctest.exe" in windows command prompt or visual studio, receive following error: error occurred during initialization of vm unable load native library: can't find dependent libraries i know there similar questions out there: i've seen them , applied recommendations (such linking jvm.dll , jvm.lib paths path environment variable). added jvm.dll location inside file properties via visual studio. need help- have been stuck on few days now. thank time! ctest.cpp below: #include "stdafx.h" #include <stdio.h> #include <jni.h> #include <string.h> #define path_separator ';' /* define ':' on solaris */ #define user_classpath "." /* prog.class */ struct controldetail { int id; char name[100]; char ip[100]; int port; }; struct workor

python - Sentry limit notifications to certain users -

can give user access sentry project not send him emails? sometimes want forward error message our mobile developers, can see parameters, don't need other reports. i found - found 2 different ways: i can make projects public (under project settings) (with sentry account) can access it. i can give users access project , user has opt-out of emails going account (top right) , notifications.

c# - Logic to ensure a method is only called once -

i'm writing idisposable class, intended used in multi-threaded environment. want make sure dispose() called once. far came with: int _isdisposingasint = 0; public void dispose() { if (interlocked.exchange(ref _isdisposingasint , 1) == 0) return; // dispose code .... } is there more elegant way of achieving this? edit important addition - not intend call dispose() multiple threads. intend use _isdisposingasint signal background thread, listens serial port, , may terminate ungracefully, should not re-throw exception. firstly, declare _isdisposingasint volatile because want updated in threads. secondly, need declare object , lock it/exchange it's value in order know have been @ dispose. did in 1 line, there no shorter that. can in efficient way: if(interlocked.compareexchange(ref _isdisposingasint , 1 , 0) == 0) this way check before exchange if value 0, , u save bus , blocking threads.

javascript - No output error when attempting to display json -

when following code executes it's showing no output. can tell me going wrong? html file: <head> <script type = "text/javascript">function ajax_get_json() { var hr = new xmlhttprequest(); hr.open("get","mylist.json",true); hr.setrequestheader("content-type :application/json",true); hr.onread ystatechange = function() { if(hr.readystate == 4 && hr.status == 200) { var data = json.parse(hr.responsetext); var results=document.getelementbyid("results"); results.innerhtml = data.user; } } hr.send(null); results.innerhtml = "requesting..."; } </script> </head> <body> <div id="results"></div> <script type = "text/javascript">ajax_get_json();</script> </body> json file: { "user":"john", "age":22, "country":

multithreading - Why does Scala use a ForkJoinPool to back its default ExecutionContext? -

in scala can use global executioncontext if don't need define own importing scala.concurrent.executioncontext.implicits.global . my question why forkjoinpool chosen executor instead of threadpoolexecutor . my understanding fork-join framework excellent @ recursively decomposing problems. you're supposed write code breaks task halves, half can executed in-thread , other half can executed thread. seems particular programming model , not 1 applicable handling execution of general asynchronous tasks across wide range of possible applications. so why forkjoinpool chosen default execution context people use? work-stealing design result in improved performance if don't use full fork-join paradigm? i can't speak scala designers, idiomatic use of scala future s involves creation of lot of small, short-lived tasks (e.g. every map call creates new task) , work-stealing design appropriate. if care these kind of precise details might prefer use scalaz-concur

Python NameError: Name 'get_tool_versions' not defined -

i trying run cmd script calls setenv.py file. file has function says, import build_cfg tool_versions = get_tool_versions() env_var_list = get_env_var() which believe importing build_cfg module. build_cfg in turn has get_tool_versions , get_env_vars functions defined. anyway, when run script error : file "setenv.py", line 172, in <module> tool_versions = get_tool_versions () nameerror: name 'get_tool_versions' not defined i relatively new python. please tell me doing wrong? the error message says all: function get_tool_versions not exist in global namespace . solve problem have find out get_tool_versions defined , import there. if defined in build_cfg can this: import build_cfg tool_versions = build_cfg.get_tool_versions() ... or from build_cfg import get_tool_versions tool_versions = get_tool_versions() ...

r - Using bash to transform a numeric sequence -

here vector of numbers have ascend (it called t8_ ) 2 7 8 9 11 15 34 91 91 92 94 the problem number happen 2 times - don't want remove them have become 2 numbers unique , not floating point. thought @ first iterating through vector the next vector be 2 7 8 9 11 15 34 91 92 92 94 then same process again when vector be 2 7 8 9 11 15 34 91 92 93 94 for example works #!/bin/bash while read -a vec; # int_min bash: 32-bit bash supports 64-bit integers. min=$((-1<<63)) ((i = 0; < ${#vec[@]}; i++)); (( min = vec[i] = vec[i] > min ? vec[i] : min + 1 )) done echo "${vec[@]}" done ### the problem not real vector looks https://www.dropbox.com/s/vp67eiw4ns9rr07/num?dl=0 . when un.sh < vec don't output in specific instance. tell me why? i can't why shell code isn't working you, can offer perl solution works fine data use strict; use warnings; use 5.010; use autodie

scala - Why is starting a Blaze server that supports websockets different than a server that does not support it in Http4s -

here sample code start blaze server supports websockets in http4s: https://github.com/http4s/http4s/blob/master/examples/blaze/src/main/scala/com/example/http4s/blaze/blazewebsocketexample.scala#l53 it quite different in case websocket support not required: https://github.com/http4s/http4s/blob/master/examples/blaze/src/main/scala/com/example/http4s/blaze/blazeexample.scala#l8 why case? possible add withwebsocketsupport on blazebuilder ? i mean, if api can improved, that's great, trying understand how websocket support fits picture because having issues getting web server (that supports websockets) function properly.

javascript - Understanding a basic modular patterns private and public functions -

i looking @ code of simple demonstration of modular pattern, have : // global module var mymodule = (function ( jq, _ ) { function privatemethod1(){ jq(".container").html("test"); } function privatemethod2(){ console.log( _.min([10, 5, 100, 2, 1000]) ); } return{ publicmethod: function(){ privatemethod1(); } }; // pull in jquery , underscore })( jquery, _ ); mymodule.publicmethod(); the code pretty straightforward, don't understand what's need publicmethod ? why privatemethod1 , privatemethod2 inaccessible? understand privatemethod1 , privatemethod2 classic js functions , publicmethod more of variable assigned hold function. privatemethod1() , privatemethod2() local functions declared inside module function wrapper. such, visible , callable within function wrapper. can't reached outside module wrapper. this same local variable inside function. functio

java - Custom checkbox class in android -

i needed correlate checkboxes position in list view in checkboxes' onclicklistener. first solution make short custom view extended checkbox had variable (position) set in getview(). public class listcheckbox extends checkbox { private int position = -1; public listcheckbox(context context) {super(context);} public listcheckbox(context context, attributeset attrs) {super(context,attrs);} public listcheckbox(context context, attributeset attrs, int defstyleattr) {super(context,attrs,defstyleattr);} @targetapi(21) public listcheckbox(context context, attributeset attrs, int defstyleattr, int defstyleres) {super(context,attrs,defstyleattr,defstyleres);} public int getposition() { return position; } public void setposition(int position) { this.position = position; } } it worked, except changed checkboxes' color black, , nothing did (including changing android:buttontint) change it. solution hashmap view

xcode6.3 - xcode 6.3 Undefined symbols for architecture arm64 -

xcode 6.3 undefined symbols architecture arm64 but libs support arm64 architectures in fat file: libavfilter.a are: armv7 i386 x86_64 arm64 and build setting architectures armv7 arm64, valid architectures armv7 armv7s arm64

c++ - How do I efficiently multiply a range of values of an array with a given number? -

the naive way linearly iterate range , multiply each number in range. example: array: {1,2,3,4,5,6,7,8,9,10}; multiply index 3 index 8 2. assuming 1 based index. result array should : {1,2,6,8,10,12,14,16,9,10}; i know binary indexed tree can used 'sum' part. how can efficiently multiply given range number? if want modify array, can't better naive linear algorithm: have iterate entire range , modify each index accordingly. if mean like, have update operations described , query operation find sum in range x y , segment tree can so. for each update operation left, right, value , each node associated range included in [left, right] , sum gets multiplied value , update accordingly , stop proceeding recursion. apply intervals not recurse on, instead of updating sum, store in each node how associated interval multiplied by. when returning recursion, can recompute actual sums according info. pseudocode : update(node, left, right, value): if [left, ri

ios - Apple iWatch: contexts not sending between view controllers -

Image
so i'm building calendar-type app on new apple iwatch. initial storyboard layout app: basically initial table view parse calendar , grab event name , date of it. want basically, through push segue, send data second view controller. i have tried using method -(nsarray *)contextsforseguewithidentifier:(nsstring *)segueidentifier , context in second view controller showing nil . this code: interfaceviewcontroller: #import "interfacecontroller.h" #import <eventkit/eventkit.h> #import "calendar.h" @interface interfacecontroller() { nsarray *events; nsarray *eventswithnotes; } @end @implementation interfacecontroller - (void)setuptable { ekeventstore *store = [[ekeventstore alloc] init]; // appropriate calendar nscalendar *calendar = [nscalendar currentcalendar]; if ([store respondstoselector:@selector(requestaccesstoentitytype:completion:)]) { [store requestaccesstoentitytype:ekentitytypeevent com