Posts

R - Plot: How to format in 10-base scientific notation and put it text, mtex, title etc functions? -

i have numeric variable, k=3.5e-5 (its values calculated throughout script). want write value somewhere (title, text in plot, etc) in plot as: k_{root} = 3.5 10^{-5} cm /d i have tried functions bquote , substitute , no 1 worked. let's put question in examples. have tried following: 1) png("exp_1.png") kroot = 3.5e-5 plot(1:10,1:10, text(4,9,bquote(italic(k[root])~"="~.(kroot)~"cm/d"))) dev.off() try favorite function, paste(). plot(1:10,1:10, text(4,9,gsub("e",paste("k[root]=",format(k,scientific=true),"cm/d",sep=" "),replacement=" 10^"))) you can replace "e" here using function gsub. i've edited answer include this. the output: > k=.0000035 > k [1] 3.5e-06 > gsub("e",paste("k[root]=",format(k,scientific=true),"} cm/d",sep=" "),replacement=" 10^{ ") [1] "k[root]= 3.5 10^{ -06 } cm/d"...

geolocation - Windows Phone 8 - Keeping background location tracking active beyond four hours -

i'm in process of developing wp8 app makes use of background location tracking abilities provided os. idea monitor users position , notify them when near types of places. so far seems work fine , when running location tracking works expect. the problem is, seems phone times out background apps after around 4 hours, stopping location tracking. i can understand why microsoft did it, preserve battery life etc. there's not point having background location tracking app has manually restarted every 4 hours! if user chooses run app , made aware of potential battery hit, surely should able run indefinitely - point of course, if system runs out of resources or similar that's fair enough. does have experience this? there must hundreds of others apps in store have run issue have thought? , presumably there must way of keeping location tracking running? i've tried periodically updating live tile (using dispatchertimer) while tracking running doesn't seem enough ke...

validation - How to pass paramaters like unix into windows batch file -

i need pass various parameters .cmd file unix format file.cmd -configuration=value -source=value -flag but, try this: startlocal @echo off cls setlocal set cmdline=%* set configuration= set source= set badargs= set validation= goto main :splitargs echo splitargs(%*) if "%*" neq "" ( /f "tokens=1,2,* delims== " %%i in ("%*") call :assignkeyvalue %%i %%j & call :splitargs %%k ) goto :eof :assignkeyvalue echo assignkeyvalue(%1, %2) if /i %1==-configuration ( set configuration=%2 ) else if /i %1==-source ( set source=%2 ) else ( rem append unrecognised [key,value] badargs echo unknown key %1 set badargs=%badargs%[%1, %2] ) goto :eof :validate echo validating set validation=fail if defined configuration ( echo -configuration ok if defined source ( echo -source ok if not defined badargs ( set validation=success ) ) ) goto :eof :main cl...

c# - How to make tooltips show up when mouse hovers over data point -

i've been searching sort of tutorial focusing on how tooltips work, have not had luck. i have test project render line chart 5 data points. when instantiate chart object set ismapenabled = true . when define series try set tool tip. private void defineseries() { var series = new series(); series.tooltip = "#valy"; series.postbackvalue = "#index"; var x = new[] {0, 1, 2, 3, 4, 5}; var y = new[] {0, 4, 5, 3, 7, 2}; ( int = 0; < x.length; i++ ) { series.points.add( new datapoint( x[ ], y[ ] ) ); } series.charttype = seriescharttype.line; defineseriesstyle( series ); chart_.series.add( series ); } the chart renders expected, tooltip not display when mouse hovers on data point. missing step somewhere, have no idea is. edit: code shows action method , constructor chart view model , subsequent function call. public actionresult causedoutpoint() { var causedout = new causedoutvi...

Line ending issue with Mercurial or Visual Studio -

i seem have strange issue caused either visual studio or mercurial. localised single project, i'm guessing in project configuration causing issue. at difficult specify point, when perform action in visual studio, update every line ending in given file, means when @ file in sourcetree, every line has changed. i can replicate using nuget add package dependency; packages.config entirely replaced. if commit changes, including line endings, later same issue occur. workaround have shelve changes , reapply them, whereupon lines written correctly. i'm not sure application blame here. did make mistake of allowing sourcetree change mercurial configuration, issue have fixed, i'm not sure if has persisted. i thought might issue mercurial.ini files or hgrcs don't seem contain untoward. here's mercurial.ini [ui] username = .... [auth] bb.prefix = https://bitbucket.org/ bb.username = .... bb.password = .... [extensions] mq = rebase = [web] allow_push = * push_s...

Uncaught TypeError: Cannot read property 'parentNode' of null javascript -

this code should make element disappear list when dropped on element (called cookiemonster) addevent(cookiemonster, 'drop', function (e) { if (e.stoppropagation) e.stoppropagation(); var el = document.getelementbyid(e.datatransfer.getdata('text')); el.parentnode.removechild(el); return false; }); create auxiliar variable this addevent(cookiemonster, 'drop', function (e) { if (e.stoppropagation) e.stoppropagation(); var el = document.getelementbyid(e.datatransfer.getdata('text')); var aux = el.parentnode; aux.removechild(el); return false; });

ruby on rails - Is it the correct way to implement belongs_to relation with factory girl? -

i have realy easy model. user have role_id depends of role table (id, name) role reference. i want create users of types on rspec test, factory girl. my first idea factory :role name "guest" factory :role_admin name "admin" end factory :role_supervisor name "supervisor" end etc... have lot different roles end factory :user email password '123456' password_confirmation '123456' association :role, factory: :role factory :admin association :role, factory: :role_admin end factory :supervisor association :role, factory: :role_supervisor end etc... have lot different roles end in model have simple method : def is(role_name) return self.role.name == role_name end it's correct way to? realy need create factory role? can make stub function in factory girl each role? i realy new test stuff, thanks. factories should reflect models. class user has_many :products en...

python - Django dynamic embedded/nested models -

i have application knows type of entity @ creation time. because of don't know how link associated models see like have type embedded json field attribute entity have relation between 'fixed' tables (see bellow) the e_type field simple charfield, based on value has, query type_a or type_b. this how looks django class entity(models.model): name = models.charfield(max_lenght=64) e_type = models.charfield(max_lenght=1) class type_a(models.model): entity = models.onetoonefield(entity) attribute = models.charfield(max_lenght=64) class type_b(models.model): entity = models.onetoonefield(entity) attribute = models.charfield(max_lenght=64) what suggest ? thanks edit: in response of why multiple tables - each e_type referees different table structure. example type_a has 4 fields, type_b has ten fields , on. having json field simple since can store data no need have multiple tables each it's own structure. different option can see use eav...

performance - Optimization of algebraic computation -

using mathematica, can compute mathematical representation of function want code in c++. say like: f=log[2*x+3*y]+sin[4*x+6*y] it makes sense in case computation: temp=2*x+3*y f=log[temp]+sin[2*temp] is there way expression reduce execution time / number of operations / size of expression or metric given more complex mathematical expression? although doesn't work simple example, can try following in mathematica experimental`optimizeexpression[{log[(2*x^3 + 3*y)^2] + sin[2 (2*x^3 + 6*y)^2]}] as result get experimental`optimizedexpression[ block[{compile`$3, compile`$4}, compile`$3 = x^3; compile`$4 = 2 compile`$3; {log[(compile`$4 + 3 y)^2] + sin[2 (compile`$4 + 6 y)^2]}]]

javascript - Class and Object confusion within Ember.js -

this basic question i'm little bit confounded. understanding convention dictates class definitions capitalised object instances not. when following: app = require("app"); module.exports = app.authmanager = ember.object.extend({ apikey: null, // load current user if cookies exist , valid init: function() { this._super(); var accesstoken = $.cookie('access_token'); var authuserid = $.cookie('auth_user'); if (!ember.isempty(accesstoken) && !ember.isempty(authuserid)) { this.authenticate(accesstoken, authuserid); } }, // ... } i assume defining authmanager's class definition. if this: module.exports = app.applicationroute = ember.route.extend({ init: function() { this._super(); app.authmanager = app.authmanager.create(); } }); my understanding app.authmanager = app.authmanager.create(); instantiates instance , applicationrouter pretty first thing executed in ember app....

linux - default: command not found -

im new linux when when im facing problem first choice search on google, in these couple days still got no results. when im run script on new instalation return "default: command not found". if im running script on machine run fine , playing videos scrolling text. here's code: #!/bin/bash source /etc/atv.conf export display=:0 sleep 5 default $default & while true; sleep 1 now=$(date +"%t") while read line set -- "$line" ifs="#"; declare -a array=($*) if [ ${array[0]} == $now ]; duration=${array[1]} filename=${array[2]} filetype=${array[3]} default $filetype $filename $duration & fi done < $playlist done this script run video file exist playlist using mplayer on ubuntu dekstop 12.04 lts what default @ "default $default &" line refer to? $default on file.conf $default=screen for atv.conf #atv configuration #host host=/home/atv #media me...

Using a variable name as the key name in a hash (Perl) -

this question has answer here: how can use variable variable name in perl? 2 answers i have block of perl code want simplify. it's part of subroutine, series of arguments added values hash of hashes. $user{$account_num}{'item0'} += $item0; $user{$account_num}{'item1'} += $item1; $user{$account_num}{'item2'} += $item2; $user{$account_num}{'item3'} += $item3; $user{$account_num}{'item4'} += $item4; $user{$account_num}{'item5'} += $item5; $user{$account_num}{'item6'} += $item6; you can see variable names same key names. seem remember watching friend kind of thing in 1 line once. like: [looping through input arguments]: $user{$account_num}{'variable_name'} += $variable_name; does know of way this? you're on thinking it. i can tell because of time: me : if make device can vi...

sql server - Converting a string to a date time in SQL -

i'm importing data different system , datetime stored string in format: 20061105084755es yyyymmddhhmmss(es/ed) es est , ed edt. i have query table last 30 days. i'm using conversion query: select convert( datetime, left(cdts, 4)+'-'+substring(cdts, 5,2)+'-'substring(cdts, 7,2)+' '+substring(cdts, 9,2) +':'+substring(cdts, 11,2)+':'+substring(cdts, 13,2) dt tb1 dt < getdate()-30 i'm looking more efficient query reduce time taken. table has around 90 million records , query runs forever. no calculation @ runtime going speed query if performing calculation , need filter against result of calculation - sql server forced perform table scan. main problem you've chosen store dates string. variety of reasons, terrible decision. string column indexed @ least? if so, may data last 30 days: declare @thirtydays char(8); set @thirtydays = convert(char(8),dateadd(day,datediff(day,0,getdate()),0)-30,112);...

objective c - Xcode build failure "Undefined symbols for architecture x86_64" -

Image
an xcode beginner's question: it first experience xcode 4.6.3. i trying write simple console program, searches paired bt devices , prints them nslog. it builds following error: undefined symbols architecture x86_64: "_objc_class_$_iobluetoothdevice", referenced from: objc-class-ref in main.o ld: symbol(s) not found architecture x86_64 clang: error: linker command failed exit code 1 (use -v see invocation) i searched crazy. common problem should reference file, of header files imported , no implementation (*.m-file) found linker. iobluetooth library however, standard framework foundation framework. what missing in above statement? i have tried building 32-bit machine (build fails again). linker error, have no idea, relates, except there issue finding implementation iobluetoothdevice, on both x86 , x64 architecture, while header files standard included framework, called iobluetooth? for information main code "main.m" being: #import ...

ASP.NET MVC Navigational Property -

i'm looking add navigational property 'registration' class, can access parent 'person'. ideally, able add public overrideable property parentperson person , can't seem work complains principle end of association. public class person <required()> public property id integer <required()> <stringlength(150)> public property firstname string <required()> <stringlength(150)> public property lastname string public overridable property registration registration end class public class registration <required()> public property id integer public property registrationdate date public overridable property sessions list(of registrationsession) end class

Excel VBA: Select Case if ActiveCell like "*string*" -

i'm working on macro takes current value of activecell , changes value based on select case. however, unable determine if activecell contains wild card string. not sure if syntax correct. how can select case compare? select case activecell.value case activecell.value "*string*" activecell.value = "contains string" end select it possible use wildcards. keep these 2 things in mind: first, string comparison expressions evaluate boolean data type (true/false); second, per developer reference select...case statement, case expression(s) must "implicitly convertible" same data type of select case test expression . demonstrate, let's use code original post above. select case activecell.value '-->activecell.value test expression case activecell.value "*string*" '-->(activecell.value "*string*") case expression. activecell.value = "contains string" ...

vba - Creating an array variable with a variable number of elements -

i want define array variable have variable number of elements depending on m number of results returned search. error "constant expression required" on: dim cmodels(0 m) string here complete code dim foundrange range dim rangetosearch range set rangetosearch = selection set foundrange = rangetosearch.find(what:="lights", after:=activecell, lookin:=xlvalues, lookat:= _ xlpart, searchorder:=xlbyrows, searchdirection:=xlnext, matchcase:=false _ , searchformat:=false) 'first occurrence m = worksheetfunction.countif(selection, "lights") dim secondaddress string if (not foundrange nothing) dim count integer: count = 0 dim targetoccurrence integer: targetoccurrence = 2 dim found boolean z = 1 dim cmodels(0 m) string until z = m z = z + 1 foundrange.activate set foundrange = rangetosearch.findnext(foundrange) if not foundrange.next nothing z(m)...

javascript - Is is safe to use function reference as an object property/key -

this question has answer here: are functions valid keys javascript object properties? 2 answers are there reasons why should not use function reference property/key of object ? code works in chrome, firefox, & ie8, "just because works..." var x = {} var = function() { return 'a' }; var b = function() { return 'b' }; x[a] = 1 x[b] = 2 x[a] === x[a] // returns true x[a] === x[b] // returns false x[b] === x[b] // returns true x[a] // returns 1 x[b] // returns 2 object keys string. used in x[a] in fact x[a.tostring()] . this means function key same key string : x[a] === x["function () { return 'a' }"] so yes, might consider both unsafe , unreasonable. it's hard imagine context in useful or efficient.

json - Unsupported url in JSONP request -

my web app loads localhost/alpha/ , following error message browser (chrome or safari) when performs jsonp request : get localhost:5000/iseeyou/webservice/login.php?email=b&pwd=b&callback=ext.data.jsonp.callback1&_dc=1377281924940 unsupported url i using sencha touch , code : ext.data.jsonp.request({ url: iseeyou.url+'/iseeyou/webservice/login.php', params:{ email: email, pwd: pwd }, success: function(response){} }); when copy/paste url displayed in error directly in browser works well. it needed "http://" @ beginning.

c++ - On platforms where pthread_t is numeric, is 0 guaranteed to be an invalid value? -

this question has answer here: is there invalid pthread_t id? 5 answers pthread_t (as returned pthread_self() ) opaque type, on platforms numeric, example typedef ed unsigned long . on these platforms, 0 invalid pthread_t value? -1 ? if wanted value either pthread_t or invalid, i'd use boost::optional<pthread_t> or std::optional<pthread_t> c++1y. this has little overhead (bytes), expresses want (this value may or may not pthread_t ), , doesn't rely on platform-specific behavior.