Posts

Showing posts from May, 2011

android - Code optimisation. (Architecture) -

i'm making quiz app. user has finish phrase shown on display , write name of car in edittext, after pushing on button, if answer right, edittext become green, if doesn't, become red. if answers right (green), intent move on next activity. the question is: how optimize code, don't how it's like? if decide add more options wouldn't readable. public class mainactivity extends appcompatactivity { edittext et_one_one, et_one_two, et_one_three; button buttoncheck; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); et_one_one = (edittext) findviewbyid(r.id.et_one_one); et_one_two = (edittext) findviewbyid(r.id.et_one_two); et_one_three = (edittext) findviewbyid(r.id.et_one_three); buttoncheck = (button) findviewbyid(r.id.buttoncheck); buttoncheck.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v

javascript - Show/hide navigation on scroll position -

this jquery show navigation menu when scroll page 0px (in right-way). trying show after 200px (on page scroll-up), means not showing right way, want show , hide after 200px when scroll page. jquery: fiddle // script lastscroll = 0; $(window).on('scroll',function() { var scroll = $(window).scrolltop(); if(scroll === 0){ $(".nav").removeclass("darkheader"); } else if(lastscroll - scroll > 0) { $(".nav").addclass("darkheader"); } else { $(".nav").removeclass("darkheader"); } lastscroll = scroll; }); html: <div class="nav"> sticky top navigation bar </div> <div class="wrap"> <h3>some filler text</h3> bacon ipsum dolor sit amet mollit ball tip occaecat brisket cupidatat meatball capicola. capicola rump turducken, elit shankle cupidatat pastrami duis fatback. sint occaecat kielbasa labore pastrami corned beef

ios - Heimdall Swift authenticate each request failure -

i using heimdall https://github.com/rheinfabrik/heimdall.swift oauth2 access , authenticate own api seems can't authenticate second request. see thing doing wrong. sure first request access token right. because end in success case. my code: @ibaction func logintapped(sender : anyobject) { let username = inputusername.text let password = inputpassword.text let tokenurl = nsurl(string: "https://[my-domain]/oauth/v2/token")! var identifier = "my-id" var secret = "my-secret" let credentials = oauthclientcredentials(id: identifier, secret: secret) let heimdall = heimdall(tokenurl: tokenurl, credentials: credentials) heimdall.requestaccesstoken(username: username, password: password) { result in switch result { case .success: self.calluserinfo(heimdall) case .failure(let error): println("failure: \(error.description)") } } } func calluserinfo

asp.net mvc 5 - Should I be able to test AuthorizeAttribute and RequireHttpsAttribute with localhost? -

i have been building mvc 5 month now. before deep in project want make sure security done , build secure web site. have created 5 pages should available , implement aspnet.idenity. first wanted test following works expected. expecting pages fail security reasons except home page. based on research if add: public static void registerglobalfilters(globalfiltercollection filters) { filters.add(new handleerrorattribute()); filters.add(new system.web.mvc.authorizeattribute()); filters.add(new requirehttpsattribute()); } every page should require https , logged in user. decorated home, index controller [allowanonymous] can land on 1 page when start project. expecting every other page fail, or error or redirect login (not sure how since not https yet). but every page works no problems. should able test using localhost, or need server environment iis? understand that possibility http, think authorizeatribute should tested , fail. not doing right? yes. but auth

android - apache cordova set/get audio name/path from storage -

i want able save name , path of recorded audio file, these values next time start app. believe can save them this, local storage: // after recording done function capturesuccess(mediafile) { addfilepath(mediafile); } function addfilepath(mediafile) { localstorage.setitem(mediafile.name, mediafile.fullpath); } how can these values next time start app? there better way store these values? in way, when try path of audio file next time can not know key 'mediafile.name'. in application, created object contains file's informations, stored in localstorage using constant key 'audio'. following example illustrates how that: var filename = "audiofilename"; var filepath = "audiofilepath"; localstorage.myaudio = { name: filename, path: filepath }; // file's informations in next time var audio = localstorage.myaudio; var filename = audio.name; var filepath = audio.path; if want store more 1 file : // stored array in loc

javascript - sails.js relifting with mocha -

i have mocha tests need re-lift sails different configuration mocks policies using moduleloaderoverride. in general, working, seems sails not lowering , re-lifting properly. the utility file management of sails instance tests: // util var sails = require('sails/lib/app'), sails; module.exports = { sailsinstance: undefined, testconfigs: {}, start: function(callback) { this.sailsinstance = new sails(); /* config not enforced remaining tests, quick lift our code can use sails config parser , extract other configs easily. */ this.sailsinstance.lift({}, function(err, server) { sails = server; // populate this.testconfigs object here this.configuresails('defaultconfig', callback); }.bind(this)); }, end: function(callback) { this.sailsinstance.lower(callback); }, configuresails: function(configname, callback) { console.log('lifting with:', configname); var launchconf

c++ - How many object instances are being created here? -

there c++ code looked in tutorial video (line numbers added clarity): 1. config defaultconfig("/etc/foobar/config"); 2. config userconfig("~/.config/foobar/config"); 3. config conf; 4. /* else not involving `conf` */ 5. conf = defaultconfig.join(userconfig); my question is, how many instances of config class being created? in case, join function returns new config instance, rather modifying existing one, @ least 3 objects being created. my question third line ( config conf; ). c++ automatically create config instance on line (even though in other language, such java, have manually tell assign new config() )? or c++ compiler smart enough realize conf object never accessed, instead gets replaced on line #5? how memory allocated? enough 3 references , 4 config instances, or there more going on behind scenes? c++ isn't java, there no references here, class objects. say, there 3+1 objects created code. you can delay creation of t

jquery - Live event video youtube not work on jwplayer -

i have live event on youtube , tried embedding on website using jwplayer. not working, when click play message "please stand by". tried resolve problem , detect message when use inspect element -> console failed load resource: server responded status of 400 (ok) live_state:1 post https://content.googleapis.com/youtubei/v1/player/live_state?key=aizasycqwzgg81j3lv5dotxaxoxf87gmdy9pstc 400 (ok) <!doctype html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>jwplayer-6.12</title> <script src="jwplayer.js"></script> <script type="text/javascript">jwplayer.key = "8cyv4dplmn3p81lxaar31qpi90ggw4u8tiok/w==";</script> </head> <body> <div id="myelement">loading player...</div> <script type='text/javascript'> jwplayer('myelement').setup({ flashplayer: 

access combobox values not showing -

Image
i trying create form 3 combo boxes on run report existing data. combo boxes filter down based on data chosen in next level combo box. however i'm having issues batch number combobox not populating it's list now vba script: private sub form_load() me.cbodate.rowsource = "" me.cbobatchno.rowsource = "" end sub private sub cbobottleno_afterupdate() dim sdatesource string sdatesource = "select [tblnewcc].[date] [tblnewcc]" & _ " [tblnewcc].[bottleno] = " & me.cbobottleno.value me.cbodate.rowsource = sdatesource me.cbodate.requery end sub private sub cbodate_afterupdate() dim sbatchsource string sbatchsource = "select [tblbatchtotals].[batchno] [tblbatchtotals] inner join [tblnewcc] on [tblbatchtotals].[runno]=[tblnewcc].[runno]" & _ " [tblnewcc].[bottleno] = " & me.cbobottleno.value & _ " , [tblnewcc].[date] = &q

nlp - Morphology software for English -

in application need use piece of software able to: a) convert words basic forms , b) find if 'nouns', 'verbs' etc. i found list of software able job. http://aclweb.org/aclwiki/index.php?title=morphology_software_for_english does have experience of these? 1 recommend? you can use nltk (python) perform these tasks. find if 'nouns', 'verbs'... this task called part-of-speech tagging . can use nltk.pos_tag function. (see peen treebank tagset ) convert words basic forms this task called lemmatization . can use nltk.stem.wordnet.wordnetlemmatizer.lemmatize function. example import nltk nltk.stem.wordnet import wordnetlemmatizer nltk.corpus import wordnet wn penn_to_wn = lambda penn_tag: {'nn':wn.noun,'jj':wn.adj,'vb':wn.verb,'rb':wn.adv}.get(penn_tag[:2], wn.noun) sentence = "the rabbits eating in garden." tokens = nltk.word_tokenize(sentence) pos_tags = nltk.pos_tag(tokens)

windows - using the clipboard in native c++ metro app -

i'm looking interfaces allow me access clipboard in native c++ metro app - similar datatransfer::clipboard::setcontent in c#. can please refer me interfaces , how can done using wrl library? in wrl, need iclipboardstatics interface contains setcontent method. #include <windows.foundation.h> #include <windows.applicationmodel.datatransfer.h> #include <wrl\wrappers\corewrappers.h> #include <wrl\client.h> using namespace abi::windows::foundation; using namespace microsoft::wrl; using namespace microsoft::wrl::wrappers; using namespace abi::windows::applicationmodel::datatransfer; // initialize windows runtime. roinitializewrapper initialize(ro_init_multithreaded); if (failed(initialize)) { cout << "failed initialize"; } comptr<iclipboardstatics> clipboard; hresult hr = getactivationfactory(hstringreference(runtimeclass_windows_applicationmodel_datatransfer_clipboard).get(), &cli

javascript - What's the best practice building unique component IDs using Catberry Framework? -

catberry has requirement components – ids must unique. what's best practice building unique ids when have complicated hierarchy of nested components? the recommended way building unique identifiers nested components is: <parent-component­-id>:<child-component­-name>:<entity-­id>. entity-id optional , used in case have list of items or that. it’s easy have id of component in render method using this.$context.attributes.id . for example, have component renders list of items. name cat-list id some-list . nested components name cat-list-item have ids: some-list:list-item:1 some-list:list-item:2 some-list:list-item:3 ... some-list:list-item:n if have more nested components cat-author each item have ids: some-list:list-item:1:author some-list:list-item:2:author ... some-list:list-item:n:author so, if use rule have unique identifiers components on page.

java - Wrong Manifest.mf in IntelliJ IDEA created .jar -

i'm trying package project using optaplanner 6.0.1 libraries .jar through intellij idea's jar artifact instead of manifest.mf containing standard manifest-version: 1.0 main-class: a.b.c.app the jar uses 1 supplied in ecj-3.7.2.jar, 1 of optaplanner's supporting libraries: manifest-version: 1.0 build-jdk: 1.6.0_26 built-by: ibrandt created-by: apache maven archiver-version: plexus archiver because of this, "no main manifest attribute, in appname.jar" error happens when trying run app. if manually replace manifest in .jar file mine works correctly. there can fix this? i keep libraries in separate /lib directory , added root of jar artifact extracted directory, intellij idea v13.0.1. i had same problem. make sure manifest.mf in: src/main/resources/meta_inf/ not src/main/java/meta_inf/

java - AndroidPdfViewer - Can not open PDF document from Assets folder -

Image
i've been working this pdf library , trying path pdf file resides, keep getting error. missing here? checking android device monitor, can see db in database folder reside in assets folder can't find pdf files? please they? check image below thanks friends, mistake, discovered need read file assets file directory before opening it. working right using code below ` private void copyreadassets(string filename) { assetmanager assetmanager = this.getassets(); inputstream in = null; outputstream out = null; file file = new file(this.getfilesdir(), filename); try { in = assetmanager.open(filename); out = this.openfileoutput(file.getname(), context.mode_world_readable); utility.copyfile(in, out); in.close(); in = null; out.flush(); out.close(); out = null; } catch (exception e) { log.e("tag", e.getmessage()); } intent intent = new int

php - Best way to get specific value in two table -

this question has answer here: mysql join clause 2 answers i'm stuck on problem, let me explain. have 2 table 1 called league have structure: id|leaguecode|country|league 0 | b1 |germany|bundesliga 1 | i1 | italy |serie another table called soccerseason have structure: id|caption |league |years 0|bundesliga|b1 |2014 1| serie | i1 |2014 now, want eet league values league table. in particular bundesliga , serie a. how can see in soccerseason table each value have years, want select bundesliga year 2014 , nation germany . because app, have selection structure: select year: 2014 select nation: germany i'm aspect result this: bundesliga how can achieve this? you need join tables using column exists in both tables. example, guessing soccerseason.league same league.leaguecode , in case can join tables using colum

java - Multithreading: Issue in allocating and blocking resources -

i have multiple resources - sake of understanding 3 resources namely xresource, yresource , zresource (java classes - runnables) able task. there list of tasks needs done in parallel among 3 resources. need resources locked , if 1 of resource locked task should go other resource , if none of resources available should wait till 1 of resource available. trying lock resource using semaphore thread gets assigned 1 runnable , other runnables idle. new multithreading might overlooking obvious. using java se 1.6 below code - public class test { private final static semaphore xresourcesphore = new semaphore(1, true); private final static semaphore yresourcesphore = new semaphore(1, true); private final static semaphore zresourcesphore = new semaphore(1, true); public static void main(string[] args) { arraylist<task> listoftasks = new arraylist<task>(); task task1 = new task(); task task2 = new task(); task task3 = new task(); task task4 = new task();

angularjs - How to independence inject Browserify Crypto in Angular Ionic -

i new bee of ionic , angular. used browserify require crypto module of nodejs ionic project. following steps: i added new line app.js file angular.module(.....).constant('crypto',require('crypto')) i run command line, create new file code of crypto module , app.js file browserify app.js > bundle.js i replace app.js bundle.js in index.html file i try test in service.js angular.module('mapp.services').factory('abc',['$http','crypto',function($http,crypto){ return { getallproduct:function(){ console.log(crypto.sha256("message")); }); } }]); it return message "crypto.sha256 not function". think "constant" means value, not static object, cannot pass crypto "constant". so, how can require needed modules @ app.js file browserify , pass use @ other js file, $http? thanks! sorry because of

How do mobile apps typically manage user sessions? -

i web developer making mobile app. have ruby on rails backend mobile client. when user signs up, needs create new user or sign in; needs fetch data user. i don't want require them enter username , password. should seamlessly associated device/phone number/fb account/whatever. if got right, can either use facebook api or normal logging form. make sure enable automatic logging in , user won't have enter data.

Getting error when importing json jar in my java file in linux -

this java code import org.json.jsonarray; import org.json.jsonexception; import org.json.jsonobject; public class plutomake { public static void main(string[] args) throws jsonexception { } } and compile , compiles without error javac plutomake.java -cp java-json.jar now copied project eclipse windows, , using jar worked fine. access json functions. here on linux, when run it, get exception in thread "main" java.lang.noclassdeffounderror: org/json/jsonexception caused by: java.lang.classnotfoundexception: org.json.jsonexception @ java.net.urlclassloader$1.run(urlclassloader.java:217) @ java.security.accesscontroller.doprivileged(native method) @ java.net.urlclassloader.findclass(urlclassloader.java:205) @ java.lang.classloader.loadclass(classloader.java:323) @ sun.misc.launcher$appclassloader.loadclass(launcher.java:294) @ java.lang.classloader.loadclass(classloader.java:268) if remove throws jsonexcep

listview - Android List.add function overwriting previous entries -

im trying populate list results database query following code. public list<entry> getallentries() { list<entry> entries = new arraylist<>(); cursor cursor = database.query(sqlitehelper.table_clients, allcolumns, null, null, null, null, null); cursor.movetofirst(); while (!cursor.isafterlast()) { entry entry = cursortoentry(cursor); entries.add(entry); log.v("andy", "entry::: " + entry.tostring()); log.v("andy","entries::: " + entries.tostring()); cursor.movetonext(); } cursor.close(); return entries; } and here outputs when run following list<entry> e = getallentries(); 08-16 19:53:28.274 13698-13698/uk.co.ab.ci v/andy﹕ entry::: id: 1 / name: andy / address 1: null / address 2: null / address 3: null / postcode: null / tel: null / mob: null / email: null / website: null / deleted: 0 08-16 19:53:28.274 13698-13698/uk.co.ab.ci v/andy﹕ entries:

angularjs - How to correctly implement multiple views with UI Router in Angular? -

i'm trying implement site 2 main content 'panes' (imagine 2 columns each half width of page). panes should able change independent of each other , have own controllers , able pass data between each other (so user can navigate through bunch of pages on left pane while right pane stays same without reloading , vice versa, , change in left pane can update data showing in right pane). i've looked through bunch of examples/tutorials on ui router can't seem find example of how implement i'm trying do. of them seem show either examples single nested views (so single view within larger view) or show multiple views not how change views independent of each other. i'd single <div ui-view></div> in index.html file (as opposed multiple ui-views) can have happening within single parent ui-view , not in index.html file. right have following js file: config(['$stateprovider', '$urlrouterprovider', function($stateprovider, $urlrouterp

ssl - Dailymotion "broke" HTTPS with video thumbnail (Chrome warning) -

i have embed dailymotion video inside web page. use code below display it. code call preview picture of video through http instead of https whereas web page domain on https. api call sent https protocol : document.location.protocol due this, ressources web page not sent through https , chrome display warning on ssl certificate. <script> // dailymotion sdk (function() { var e = document.createelement('script'); e.async = true; e.src = document.location.protocol + '//api.dmcdn.net/all.js'; var s = document.getelementsbytagname('script')[0]; s.parentnode.insertbefore(e, s); }()); window.dmasyncinit = function() { var player = dm.player("player", {video: "x254e00", width: "480", height: "270"}); player.addeventlistener("play", function(e) { $('.video_layer').hide(); }); }; do have idea, how force https call picture preview ? there bug when re

xcode - Cast JSON AnyObject to Double (Swift) -

i want cast anyobject json double in swift. let value = double(jsonresult["counter"]) not work let value = jsonresult["counter"] as? double not work let value = jsonresult["counter"] as! double not work numbers in dictionaries(/from json) nsnumber . can use (jsonresult["counter"] as? nsnumber).doublevalue . (the double type not class, can't anyobject.) edit: sounds server returning data as string , {"counter": "1234"} . in case, can take advantage of nsstring method called doublevalue parses string (or can use integervalue ): if let counter = (parsejson["counter"] as? nsstring)?.doublevalue { // }

php - Trying to validate if Facebook user exist or not from a .txt file -

i have .txt files contains few facebook usernames , want check if usernames exists, i.e if facebook returns real profile or if returns 404 page. want save usernames exists in .txt file. function get_data($url) { $ch = curl_init(); $timeout = 100; curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt($ch, curlopt_connecttimeout, $timeout); curl_setopt($ch,curlopt_useragent,'mozilla/5.0 (windows; u; windows nt 5.1; en-us; rv:1.8.1.13) gecko/20080311 firefox/2.0.0.13'); curl_setopt($ch, curlopt_followlocation, true); curl_setopt($ch, curlopt_ssl_verifypeer, false); $data = curl_exec($ch); if (curl_errno($ch)) { echo 'curl error: ' . curl_error($ch); } curl_close($ch); return $data; } $handle = fopen("usernames.txt", "r"); if ($handle) { while ($username = fgets($h

python - How to put a django form on a bootstrap modal with another form on the same page (outside the modal)? -

i've tried build website using django & bootstrap, , in 1 of pages have 2 forms, 1 add comment post, , other make contact me, contact form on bootstrap modal. how can put contact form in modal, function-based view? views.py def gameview(request, slug): game = gameupload.objects.get(slug=slug) comment_form = commentform() contact_form = contactform() if request.method == "post": if request.post['form-type'] == u'comment-form': comment_form = commentform(request.post) if comment_form.is_valid(): instance = form.save(commit=false) instance.upload = game instance.save() else: contact_form = contactform(request.post) #send mail me context = {"game": game, "comment_form": comment_form, "contact_form": contact_form, "comments": game.comme

sql - Create bins with unique values in each bin -

i bin numeric column ( var ) in such way there approximately same number of rows in in each bin. additional requirement 1 (unique) value in column cannot assigned more 1 bin. example if value 1 in column var assigned bin 1 not allowed assign value 1 bin 2. i aware of functions ntile() or percent_rank() , not see how these used task @ hand. drop table if exists binme; create table binme (var numeric); insert binme values (0), (0), (0), (1), (1), (1.5), (1.5), (2), (2), (2), (2.5), (3), (3), (3.5), (4.5), (5), (6), (7), (10), (11); select (var * 100)::int, ntile(5) over(order var), percent_rank() over(order var) binme; for example , 5 bins required result be: var ntile required_bin 0 1 1 0 1 1 0 1 1 1 1 1 1 2 1 has in bin 1 1.5 2 2 1.5 2 2 2 2 2 2 3 2 2 3 2 has in bin 2 2.5 3 3 3 3 3 3 4 3 3.5 4 3 4.5 4 4 5 4 4 6 5 4 7 5 4 10 5 5 11

c# - sequence with min & max numbers -

i'm trying program let me enter desired number(entries), enter desired value entries. should write out biggest value(green), smallest(red) rest of sequence. , in next row, biggest , smallest should change places(didn't type code this). doing wrong(especially in last 'for loop' ) int max = int.minvalue; int min = int.maxvalue; console.writeline("how many numbers want enter ? "); int kolicinabrojeva = int.parse(console.readline()); int[] niz = new int[kolicinabrojeva]; (int = 0; < kolicinabrojeva; i++) { console.writeline("enter {0}. number:", + 1); niz[i] = int.parse(console.readline()); if (niz[i] > max) { max = niz[i]; } if (niz[i] < min) { min = niz[i]; } } console.foregroundcolor = consolecolor.green; console.writeline(ma

java - Using a Scanner with a String Splitter -

i trying use string splitter display user input e.g. 1,2 coordinates display on console. don't errors when run code. however, attempt use splitter not seem work. scanner scanner = new scanner(system.in); system.out.println("enter row , column number @ shoot (e.g., 2,3): "); string[] coordinates = scanner.nextline().split(","); if (coordinates.length != 2) { system.out.println("please enter coordinates in correct format."); system.out.println("\nplayer 1 please take turn:"); continue; } system.out.println("\nenter mine location:"); system.out.println("\nplease enter x position mine:"); system.in.read(byt); str = new string(byt); row = integer.parseint(str.trim()); system.out.println("\nplease enter y position mine:"); system.in.read(byt); str = new string(byt); col = integer.parseint(str.trim()); your use of system.in.read(...) dangerous code , not doing think it's doing: syst

swift - Why can not set name of SKSprite in its init function? -

i have extended skspritenode , want set name attribute in init function: class ship: skspritenode { var id: int /** * image name of sprite image bubble. **/ var image: string //some other vars not name, because super class sknode has name init(ship: (name: string, <other vars>), position: cgpoint) { let texture = sktexture(imagenamed: self.image) super.init(texture: texture, color: uicolor.clearcolor(), size: texture.size()) self.name = name //here set name!!! self.position = position self.physicsbody = skphysicsbody(circleofradius: self.size.width / 2) self.physicsbody!.dynamic = true } required init(coder adecoder: nscoder) { fatalerror("init(coder:) has not been implemented") } } but later, when create 'ship' (ship[1] values including name): var titanic = ship(ship: ship[1], position: shipposition!) println(titanic.name) //nil self.addchild(tit

java - Continue to next tests IF assertEquals fails -

i new in java / selenium , trying automate tests. trying move next lines of code if test fails , print message if test pass. now, forcing test fail in order move next operations. here piece of code: public class selfreportingtest { private webdriver driver; @before public void setup() { driver = new firefoxdriver(); } @test public void testloginfunctionality() string validusername = "testusername"; string validpassword = "testpassword"; string validurl = "https://testsite.com/users/profile/show" // url when user logged driver.get("http://testsite.com"); webelement loginlink =driver.findelement(by.id("loginlink")); loginlink.click(); webelement usernamefield = driver.findelement(by.id("loginusername")); webelement passwordfield = driver.findelement(by.id("loginpassword")); usernamefield.sendkeys(validusername); passwordfield.sendkeys(validpassword); webelement loginbutton =driver.findele

spatial - Implementing a software gimbal -

i have game controller (e.g. wii) gives me in software position , orientation. the given spatial data has lot of noise, both because of hardware, , because user human, , human hands aren't stable. i want implement similar gimbal, stabilize input , remove noise. ideally, if hand held in place, spatial data should stay same, if in reality hand moves little bit. , when hand moving, data should stable , smooth, , not jiggly , noisy. i tried simple things moving average, it's not effective actual gimbal. searching related "gimbal" either results in game rotation math (gimbal lock), or electronics projects use physical gimbal. are there resources related stabilizing spatial data?

Warning with missing data when making a plot (R) - but am using na.rm=TRUE -

i trying change whiskers (upper &lower limits) of boxplots , directed boxplotperc() in statda package. data i'm using has missing values , works fine when using regular boxplot() however when used function (i.e. boxplotperc(x) ) warning: error in quantile.default(x, quant) : missing values , nan's not allowed if 'na.rm' false` i tried adding na.rm = true function, same error returned. new user of r, understanding of above error "missing values" should allowed, not correct. is there advice on how make boxplotperc() work missing data? great. thank you.

Save outputs of nested for loops in MATLAB -

i have following codes wish have output matrix rpp of (10201,3). run code (which takes bit long) check matrix size of rpp , see (1,3), tried many things couldn't find proper way. logic of codes take 6 values (contain 4 constant values , 2 variable values (chosen 101 values)) , make calculation 3 different i1 , store every output vector of 3 in matrix (101*101 (pairs of 2 variable values)) rows , 3 (for each i1) columns. i appreciate help vp1=linspace(3000,3500,101); vp2=3850; rho1=2390; rho2=2510; vs1=linspace(1250,1750,101); vs2=2000; i1=[10 25 40]; rpp = zeros(length(vp1)*length(vs1),length (i1)); n=1:length(vp1)*length(vs1) m=1:length (i1) l=1:length(vp1) k=1:length(vs1) p=sin(i1)/vp1(l); i2=asin(p*vp2); j1=asin(p*vs1(k)); j2=asin(p*vs2); a=rho2*(1-2*vs2^2*p.^2)-rho1*(1-2*vs1(k).^2*p.^2); b=rho2*(1-2*vs2^2*p.^2)+2*rho1*vs1(k)^2*p.^2; c=rho

Nest simulator: python says “no module named nest” -

after installing nest neural simulator, keep getting following error when trying run of example python files came in installation. i've tried re-installing nest, python, , using anaconda, no go. python error: importerror: no module named nest suggestions? turns out needed move directory installed nest (users/name/opt/nest) nest folder in following directory in anaconda. specifically, moved contents of folder (from nest installation): /users/name/opt/nest/lib/python2.7/site-packages/nest into one: /anaconda/lib/python2.7/site-packages/nest disclaimer: run problems not having copied contents of nest installation, little hack helping me run example files now.

design - State machine and params in a rails app -

i in process of implementing state machine model having subscription behaviour usin aasm. want state machine able trigger actions when changing states. currently use update action fail if date not correct callbacks. class contrat validate :active_start_is_valid end i want use state machine implementations imagine seems messy me : -i create class method or service object kind of method : def start_subscription(date) date = validate_input_date(date) @contrat.start_date=date @contrat.activate! end i in before_save method triggered update. 1 more complicated need check if start_date has changed, , if yes check date , update it, before changing state. -the controller action activation limited update action (filtered custom params require) : if @contrat.update_attributes @contrat.activate! end i not comfortable of theses. state machine articles, rails or not, never mention params event, there other pattern should aware of? am missing obvious?

ios - Do I need to check for nil on my strongSelf = weakSelf assignment inside a block? -

for example, i'm using svinfinitescrolling ( https://github.com/alexanderedge/svinfinitescrolling ). i have code looks this... - (void)initializeinfinitescrollingfortableview { __weak myviewcontroller *weakself = self; [self.tableview addinfinitescrollingwithactionhandler:^{ myviewcontroller *strongself = weakself; if (!strongself.endreached) { [strongself fetchdata]; } else { [strongself.tableview.infinitescrollingview stopanimating]; } }]; } what i'm wondering is... need check strongself nil before using this... ... [self.tableview addinfinitescrollingwithactionhandler:^{ myviewcontroller *strongself = weakself; if (strongself) { // <== ** needed? ** if (!strongself.endreached) { here why ask. point #3 on link ( http://www.apeth.com/iosbook/ch12.html#exstrongweakdance ) says "the nil test because, in multithreaded situation, our weak reference self may have vanis

php - Codeigniter cannot find controller -

i using codeigniter 3. when running on local wamp server, good. but, when running on vps (linux debian apache 2.2.22) 'url not found' message. here controller: <?php defined('basepath') or exit('no direct script access allowed'); class contact extends ci_controller { public function __construct() { parent::__construct(); $this->load->helper('url'); $this->load->library('session'); $this->load->helper('form'); } public function index() { $this->load->view('contact_view'); } } my url controller www.example.com/contact error message is: the requested url /index.php/contact not found on server. i have removed index.php $config['index_page'] = '' in .htaccess file, using rewrite eleminite need index.php in urls, using this: rewriteengine on rewritecond $1 !^(index\.php|resources|robots\.txt) re

Is there a way to make an IPhone wallpaper react to touch event?(programmatically) -

like nexus revamped does. kind of tech involved in this? can via javascript&css? if it's not possible, please explain why? edit(1): want make animated wallpaper( a kaleidoscope ) spinning while user swiping on screen.

bash - Linux: How to kill Sleep -

more of conceptual question. if write bash script like control_c() { echo goodbye exit #$ } trap control_c sigint while true sleep 10 #user wants kill process here. done control+c won't exit when sleep 10 running. because linux sleep ignores sigint? there way circumvent , have user able cntrl+c out of sleep? what describing consistent interrupt signal going bash script, not process group. script gets signal, sleep not, trap cannot execute until after sleep completes. standard trick run sleep in background , wait on it, wait receives interrupt signal. should explicitly send sigint child processes still running, ensure exit. control_c() { echo goodbye kill -sigint $(jobs -p) exit #$ } trap control_c sigint while true sleep 10 & wait done

Problems Starting C Programs -

i'm trying execute code below. however, in eclispe, program doesn't start until enter character , press enter. instance, if hit run, have enter number represent age before asks me enter age. wondering how fix this. int main() { int age; /* need variable... */ printf( "please enter age" ); /* asks age */ scanf( "%d", &age ); /* input put in age */ if ( age < 100 ) { /* if age less 100 */ printf ("you pretty young!\n" ); /* show works... */ } else if ( age == 100 ) { /* use else show example */ printf( "you old\n" ); } else { printf( "you old\n" ); /* executed if no other statement */ } return 0; } this pretty classic problem. output stream has not been flushed. happens after writing newline (which not doing

mysql - SQL Multi Order by Count with Criteria -

i want query standings motogp race result my sql select `rider`, `team`, `bike`,sum(`points`) `table_name` `year` = 2015 , `classes` = "motogp" group `year`,`rider` having sum(`points`) order sum(`points`) desc if 2 or more riders have same sum('points'), next order number of 1st race position. put race position on 'pos' field. pos value: 1,2,3,4,5 ... please 2nd order. thank you you need change having clause: order sum(`points`) desc, sum(raceposition = 1) desc for multiple positions, think need add condition each one: order sum(`points`) desc, sum(raceposition = 1) desc, sum(raceposition = 2) desc, sum(raceposition = 3) desc at point, perhaps sum(raceposition) want.

ruby on rails - Creating DBs on the fly for all my users -

i'm building rails app in i'd provide every user each own database work with. @ moment i'm thinking simpledb due compatibility json, low maintenance, , compatibility aws. however, did notice aws caps users @ 250 simpledb domains may problematic. anyway, i've never created application required dynamic databases scoped users , wondering if aware of design patterns/gems/databases meant address common pitfalls regarding application design.

Convert interactive flash animation to javascript to use in html5 -

hi, i have banner on site made in flash. animation ends sequence showing buttons user can click navigate inner pages. since flash seems dead replace html5 friendly code. possible have program such adobe flash cs5 convert full movie me javascript code? or have write javascript myself scratch? thank you. you can use flash cc publish flash file html canvas base structure. steps - open file in flash cc select commands->convert other documents. folder select html 5 canvas dropdown , press ok. open newly created flash file , publish. give canvas base html file. the html , javascript in organized format , can edit code well. hope solve problem.

java - How can I set this thread instead of starting it from 0? -

i have class works clock, follows: public class playtime extends thread { public int playtimei = 0; @override public void run() { while(true) { playtimei++; try { thread.sleep(1000); } catch (interruptedexception e) { e.printstacktrace(); } } } } which, in new game program started this: data.playtime = new playtime(); data.playtime.start(); which causes start zero; however, game needs able read int save file , start number instead. how start specific int? i think simple read config time , in class add constructor playtime. public class playtime extends thread { int playtimei = 0; public playtime(int playtimei) { this.playtimei = playtimei; } @override public void run() { while(true) { playtimei++; try { thread.sleep(1000); } catch (interruptedexception e) { e.printstacktrace();

parse.com - iOS + Parse Cloud Code - updating a specific user (not logged in user) -

i trying update user (which not current user). figured have use cloud code make update. i have created cloud function below update selected user. trying add meetingid's array property belongs user class. cloud code: parse.cloud.define('updateuser', function(request, response) { var userid = request.params.userid, meetingid = request.params.meetingid; var user = parse.object.extend('_user'), user = new user({ objectid: userid }); user.addunique("meetingsarray", meetingid) user.save(null, {usermasterkey:true}).then(function(user) { response.success(user); }, function(error) { response.error(error) }); }); objective-c //meetingid - obtained meeting object. [pfcloud callfunctioninbackground:@"updateuser&

javascript - paginating through a CRUD API -

i writing client query crud web api. be using socket.io.get('/api') . problem is: want paginate results, can start displaying stuff while client still receiving data. the results api come json, like [ { "id": "216754", "date": "2015-07-30t02:00:00.000z" }, { "id": "216755", "date": "2015-08-30t02:00:00.000z" } ] the api lets me construct url query can limit size of each result array. can make query /api&skip=10&limit=10 , , me results item 10 item 19. want able keep looping , receiving results until results array less length = 10 (that mean reached end of dataset). , need asynchronous, can start work on data right start , update whatever work have done each time new page received. is infinite scroll trying do? or want call pages asynchronously , able receive page 3 before page 2? reading question, understand second. you can't rely on "u