Posts

Showing posts from September, 2010

r - Plot polynomial curve in ggplot using equation, not data points -

Image
this question has answer here: equivalent of curve() ggplot 2 answers is there way plot polynomial function in ggplot without having plot datafame contains selected points along curve of interest? equation x^3 + x^2 + x + 5. thought done in same way geom_abline can used add straight line plot far having no luck finding way this. checked ggplot2 documentation didn't see there thought help. geom_abline doesn't seem extend past straight lines. my end goal plot data independent dataset , use polynomial curve "reference standard". code below plots curve of interest plotting values along curve, not using equation directly. x <- 1:100 y <- x^3+x^2+x+5 dat <- as.data.frame(x,y) ggplot(dat, aes(x,y)) + geom_point() you're looking stat_function() , think: x <- 1:100 dat <- data.frame(x,y=x^3+x^2+x+5) f <- function(x) x^3+...

mysql - Find strings within text in SQL -

i have table string column "word" , rather large text. want find words appear within text. imho need reverse operator. ist possible in plain sql (no stored procedures)? example: finding words in rhymes | id | word | | 1 | star | | 2 | moon | | 3 | sun | | 4 | sky | text: twinkle, twinkle, little star, how wonder are! above world high, diamond in sky. ==> should find id 1: start, 4: sky try this: select id tablename 'twinkle, twinkle, little star, how wonder are! above world high, diamond in sky.' concat('%', word, '%'); sql fiddle demo

angularjs - master Detail with ui-router of angular -

i new angular , looking example of master detail. found one: http://embed.plnkr.co/dbsbiv/app.js , using angular's ngroute. heard ui.route state of art kind of way handle routing due more flexible. i want have both master , detail on 1 template, tried solve multiple named views in https://github.com/angular-ui/ui-router/wiki/multiple-named-views . have problem, don't know how create link in master list detail view .. tried ... don't know put right here, because have 1 state multiple views. can tell me whether i'm on wrong way or put ref link detail? thanks in advance markus you don't need named views this. nested views. lets imagine have list of blog posts. have 1 state called blogs. , state called blogs.edit, takes parameter of postid. your blogs.html (the master list) this: <a ng-repeat="post in blog.posts" ui-sref="blogs.edit({postid: post.id})">{{post.title}}</a> <div ui-view></div> this r...

python - How can i get django to stop returning "Response code: 403" to iPhone App -

i have following swift code iphone app: var post:nsstring = "username=\(username)&password=\(password)" nslog("postdata: %@",post); var url:nsurl = nsurl(string: "http://localhost:8000/straightred/login/")! var postdata:nsdata = post.datausingencoding(nsasciistringencoding)! var postlength:nsstring = string( postdata.length ) var request:nsmutableurlrequest = nsmutableurlrequest(url: url) request.httpmethod = "post" request.httpbody = postdata request.setvalue(postlength, forhttpheaderfield: "content-length") request.setvalue("application/x-www-form-urlencoded", forhttpheaderfield: "content-type") request.setvalue("application/json", forhttpheaderfield: "accept") var reponseerror: nserror? var response: nsurlresponse? var urldata: nsdata? = nsurlconnection.sendsynchrono...

move - How do I copy a folder structure with only modified files on GIT? -

i have repository big folder structure , lot of files. need take modified files without commit , copy folder, same folder structure. have done that? i've solve simple php code, when run it, changed file copied on patch folder. $dir = dirname( file ) . "/"; $patch = dirname( file ) . "/patch/"; cp($dir, "", $patch); function cp($dir, $file, $patch) { if ($file == "patch" || $file == "index.php") return; if (is_dir($dir . $file)) { $patch = $patch . $file . "/"; $dir = $dir . $file . "/"; $files = scandir($dir); foreach ($files $file) { if ($file != "." && $file != "..") { cp($dir, $file, $patch); } } } else { $t = mktime(0, 0, 0, date("m"), date("d"), date("y")); if (filemtime($dir . $file) > $t) { if (!file_exists($patch)) mkdir($patch, 0777, tru...

sql - Update columns In a Teradata Table using data from another table -

i have seen many posts , followed syntax write below query. still given error " column/parameter wm_ad_hoc.temp.temp not exist " please assist in figuring out doing wrong here. update temp wm_ad_hoc.owned_item_store_dly temp, wm_ad_hoc.owned_item_store_dly_util util set temp.vendor_stock_id = util. vendor_stock_id, temp.on_hand_each_qty = util. on_hand_each_qty, temp.vendor_stock_id = util.vendor_stock_id temp. vendor_nbr = util. vendor_nbr , temp.wmi_item_nbr = util.wmi_item_nbr , temp. store_nbr = util. store_nbr , temp.business_date = util.business_date you need not qualify set columns. so: update temp wm_ad_hoc.owned_item_store_dly temp, wm_ad_hoc.owned_item_store_dly_util util set vendor_stock_id = util.vendor_stock_id, on_hand_each_qty = util.on_hand_each_qty, vendor_stock_id = util.vendor_stock_id ...

Travis CI support for XCode 6.3 -

when travis support xcode 6.3? announced on april 9 soon. http://blog.travis-ci.com/2015-04-09-this-week-in-travis-ci/ as of may 26th, there beta support xcode 6.3 in travis: http://blog.travis-ci.com/2015-05-26-xcode-63-beta-general-availability/ you have add osx_image: beta-xcode6.3 in .travis.yml file opt in.

do document IDs in Meteor need to be random or just unique? -

i'm migrating data rails system, , convenient assign migrated objects ids post0000000000001 , etc. i've read here creating meteor-friendly id's in mongo? that meteor creates random 17 character strings 23456789abcdefghjklmnpqrstwxyzabcdefghijkmnopqrstuvwxyz which looks chosen avoid possibly ambiguous characters (omits 1 , i , etc.) do ids need random reason? there security implications being able guess meteor document's id?! or easy way of generating unique ids? mongo seems fine sequential ids: http://docs.mongodb.org/manual/core/document/#the-id-field http://docs.mongodb.org/manual/tutorial/create-an-auto-incrementing-field/ so guess have meteor constraint if exists. the ids need unique. typically there element of order: such using integers, or timestamps, or sequentiality. this can't work in meteor since inserts can come client, may disconnected period, or clients clocks may off/have varying latency. not possible know previous ...

ios - cycle for insert array -

please need help, have following code: nsstring* string = [[nsstring alloc] initwithdata:responsedata encoding:nsutf8stringencoding]; nsarray* params= [string componentsseparatedbystring:@"\\"]; lugar = params[0]; texto1 = params[1]; texto2 = params[2]; texto3 = params[3]; nsstring *query; query =[nsstring stringwithformat:@"insert contenido values(null,'%@','%@','%@','%@')", lugar,texto1,texto2,texto3]; // execute query. [self.dbmanager executequery:query]; // if query executed pop view controller. if (self.dbmanager.affectedrows != 0) { nslog(@"query executed successfully. affected rows = %d", self.dbmanager.affectedrows); } and receive string text follows: 34 \ field1 \ dfr23 \ \ 35 \ field2 \ dfr24 \ \ 36 \ field3 \ dfr25 \ bad my code separates first 4 spaces separated \ need inserting cycle spaces in array, please me? you can use stringbyappendingstring method can connect 1 string another....

html - Does a float need a width? -

after lot of research floats confused why there information on web float should have width defined. said, float take whole space , therefore behave normal block element. regard information here http://www.w3.org/tr/css21/visudet.html#shrink-to-fit-float float shrink-to-fit. understand float never take whole space unless needs to. when thinking navigation items, there need specify width? don't think in case. maybe when content inside float large? it discussed here do need width on floated element? there no clear statement, not necessary. i don't think floated elements require fixed widths, perhaps positional css includes dividing page 3 columns, may want consider fixing widths on columns floated left/right. 1 reason because navigation bars or forum posts or sort of list of hyper links aligned on sides of pages, , if these 2 columns not fixed, character limit of anchor links limited screen size decreases. may not want inline anchor tags wrapping across multiple...

javascript - Arguments of function inside a function -

i want create objects don't know how write arguments of function inside function. here code comments explain better. function troop(rss, time, offense, defense){ this.rss= rss; this.time= time; this.offense= offense; this.defense= function types(a, b, c, d){ this.a= a; this.b= b; this.c= c; this.d= d; } } dwarf = new troop(1,2,3, new types(11,22,33,44)); // wrong alert(dwarf.defense.a) // how can access values after? thanks. you want types own function, can pass in object troop constructor. function types(a, b, c, d) { this.a= a; this.b= b; this.c= c; this.d= d; } function troop(rss, time, offense, defense){ this.rss= rss; this.time= time; this.offense= offense; this.defense= defense; } dwarf = new troop(1,2,3, new types(11,22,33,44)); // these lines right alert(dwarf.defense.a) // it's function definition wrong :) in general capitalize class names types , , keep variables dwarf lowe...

ruby on rails - How to Submit Polymorphic Comments on Feed? [Error] -

Image
if user clicks [+ comment] button he confronted evil beast: activerecord::recordnotfound in commentscontroller#create couldn't find comment 'id'= line: @commentable = resource.singularize.classify.constantize.find(id) activities/index <%= link_to activity.user.name, activity.user %> <%= render "activities/#{activity.trackable_type.underscore}/#{activity.action}", activity: activity %> <%= render "comments/comments", comments: activity.comments %> <%= render "comments/form", new_comment: comment.new(commentable_id: activity.id, commentable_type: activity.class.model_name) %> comments/_form <%= form_for new_comment |f| %> <%= f.text_area :content, rows: 4, class: 'form-control', placeholder: 'enter comment' %> <%= button_tag(type: 'submit', class: "btn") %> <span class="glyphicon glyphicon-plus"></span> comment <% end ...

math - Matlab Log-Likelihood Threshold -

Image
i try implement speech detection application on matlab. purpose; try examine likelihood between speech , wanted word in speech. use below code calculate likelihood : [p, log_like] =posterior(model,speech_frame'); model acoustic model of wanted word, speech_frame part of speech contains many wanted word in it. anyway, above code returns log_like 4.969621267039301e+03 or like. need build threshold value. example, if model , speech similar 90%, there wanted word in speech. how can ? data: frame : https://dl.dropboxusercontent.com/u/51048269/frame.txt model acquired : https://dl.dropboxusercontent.com/u/51048269/model_data.txt represented below

jsp - Servlets birthday calculator tomcat -

can see if there errors in code servlet should able send data next servlet cant compile myself cause tomcat keeps giving several ports in use error though restarted tomcat services , tomcat/bin it... tried restarting pc tried searching 8080 port , closed ans still same protected void doget(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { response.setcontenttype("text/html"); printwriter out = response.getwriter(); out.print("<html>"); out.print("<body>"); out.println("<form action='end' method='post'>"); out.println("month " + "<select>" + "<option mon=1>january</option>" + "<option mon=2>febuary</option>" + "<option mon=3>march</option>" + "<option mon=4>april</...

Windows 8.1; Python 2.7: `import gtk` produces ImportError:DLL load failed? -

more completely, traceback: a:\hamster-src\hamster\win>python hamster-win.py running source folder, modifying pythonpath traceback (most recent call last): file "hamster-win.py", line 35, in <module> import gtk file "a:\anaconda\lib\site-packages\gtk-2.0\gtk\__init__.py", line 30, in <mod ule> import gobject _gobject file "a:\anaconda\lib\site-packages\gtk-2.0\gobject\__init__.py", line 26, in <module> glib import spawn_async, idle_add, timeout_add, timeout_add_seconds, \ file "a:\anaconda\lib\site-packages\gtk-2.0\glib\__init__.py", line 22, in <mo dule> glib._glib import * importerror: dll load failed: %1 not valid win32 application. i have installed gtk+ windows runtime environment, available here: http://sourceforge.net/projects/gtk-win/ i installed pygtk using all-in-one installer. it still seems right dlls cannot found? how fix issue?

javascript - How to Show a Tooltip at the Bottom of a Page -

Image
in apps, when user focues on element, tooltip float at bottom of page displays information element. example: does know of way achieve effect (preferably using angular, although jquery fine)? note i'm not looking tooltip hovers nearby actual element itself, so: instead, i'm interested in tooltip floats @ bottom of page. the control not looking use called popover. popover , tooltip both tied element on dom has interacted shown. if want in between shows in fixed position on window , use angular port of toastr , configure show when , where want.

SQL Server Filter items for a user -

i have order table , orderitem table. orders user placed less or equal 2 mins between them , have same products(number of products must match well) associated them. based on question i'm able sucessfully filter out order placed <=2 mins apart user. i'm unable figure out how able orders user have same products associated them well. i expecting output like ordernumber orderdatetime userid 1111 april, 28 2012 09:00:00 1 3333 april, 28 2012 09:03:00 1 4444 april, 28 2012 09:40:00 2 5555 april, 28 2012 09:42:00 2 here have tried far: sql fiddle using sql fiddle, came this... with ordered ( select ordernumber, orderdatetime, userid, lag(orderdatetime,1) on ( partition userid order orderdatetime ) prev_time, lead(orderdatetime,1) on ( partition userid order orderdatetime ) next_time, lag(ordernumber,1) on ( partition userid orde...

python - C++ to numpy and back to C++, tuple PyObject -

i implementing visual c++ code (ms vstudio 2013) acquires image camera, processes image, sends pre-processed data (an array 2 or more doubles) python through pyobject, , gets numpy-processed results python (a tuple of 3 doubles in py, becomes array of 3 doubles in c++). tested py function standalone script. however, keep getting null return pyobject_callobject(). python , vc++ project reside in same directory. i have set log file record in py function document calls c, know in cases c++ calls not reach py function, , in other cases py function called, but, perhaps, returned values cannot processed. specifically, found can call py function (positive log record) when tuple contains 1 object, cannot call (no log file records) when tuple contains 2 or more objects. in addition, if py function needs no arguments, , not need return anything, calls successful. i have googled , read having using tuples communicate between c++ , py, still did not make work. have read documentation , exa...

php - Handle Raspberry Pi camera via Apache -

i'm trying image of raspi camera via php script. it's installed php5, apache2 , necessary stuff. snippet: /var/www/img.php if(isset($_get['pic'])) system("sudo raspistill -w 512 -h 320 -o /var/www/img/img.jpg"); when run command directly in terminal it's working, php script not. sudo php /var/www/img.php?pic i'll error: could not read input file: /var/www/img.php first thought it's problem permissions, isn't working root privileges. have idea? i'm depressed.. thanks lot! solution first it's necessary change owner of apache directory: sudo chown www-data:www-data -r /var/www after it's not necessary prepend sudo : exec('raspistill ...'); it's possible popen , system , ...

How to add or modify my jquery for multiple selection to this javascript? -

issue i want able touch screen , drag finger across surface , select multiple boxes. want same thing mouse, hold down mouse , drag across whatever want select. because of this, thinking implement in jquery/jquery mobile have behavior out of box? code here working sample of have working far. built table , able select specific elements color (and ignore another) able select row or colum. able unselect. able select entire table or unselect (by color). attempts i tried using jquery ui. specifically, jquery selectable api , breaks existing code , buggy. took @ found here, dependent on desktop approach using shift , control. tried add select attribute <td> elements , use multiple select. didn't think hack work, @ least wanted try it. finally, looked @ stackoverflow , seems wants checkboxes or keyboard. again, need way able select multiple boxes/grids aka elements in grid touching screen , dragging across whatever wish select or same mouse. edit questio...

wpf - Surface : Multi focus, multi touch, multi applications -

i'm developping application surface sdk running 2 windows (not hard reproduce @ all). problem : when 1st window clicked, has focus. when want click 2nd window while first still clicked, can't focus , interact 2nd window. i think problem windows gives focus 1 application @ time, can't interact second window until first click released. do know if there solution force windows interact 2 applications @ same time ? cheers, your diagnosis correct unfortunately there no solution. of windows based on assumption 1 window has focus. (source: lead team created surface sdk)

javascript - HTML5 video autoplay and autostop when specific class on it -

i have slider of videos, want autoplay when visible , autostop when not visible. visible video @ moment of stay visible has class (active) identifies it. <video class="item active" controls autoplay poster="" width="640" height="360"> <video class="item" controls autoplay poster="" width="640" height="360"> <video class="item" controls autoplay poster="" width="640" height="360"> how can that? you can manipulate states of video javascript. playing example can select video tag have class active , play it: document.queryselector('video.active').play(); for other video tags can pause them code: var videos = document.queryselectorall('video.item'); for(var = 0; < videos.length; i++) { videos[i].pause(); } you need make manipulation on click, or on slide change, , take note first need stop videos play video ...

java - Change at runtime to a marker interface -

today saw next code: public tab addtab(component c, string caption, resource icon, int position) { tab addedtab = super.addtab(c, i18ncaption, icon, position); // if not securized if (!(addedtab instanceof securizedcomponent)) { addedtab = securitywrapper.createsecuritywrapper((tabsheettabimpl)addedtab, caption); } return addedtab; } securizedcomponent marker interface /** * * marker interface. securized components changed @ runtime implement interface. * way, possible know if component has been securized asking component instanceof securizedcomponent * * allows framework not securize components more once * */ public interface securizedcomponent { } the method createsecuritywrapper like: enhancer enhancer = new enhancer(); enhancer.setsuperclass(wrapperclass); enhancer.setclassloader(source.getclass().getclassloader()); enhancer.setinterfaces(new class[]{securizedcomponent.class}); //more stuff... i know ...

c - Function to search for string in array of strings -

i trying write function searches unique part(maximum 2 characters) of string in array of strings. although strstr , strchr not working , crash program reason. have resorted trying create resembles function. my question this: why strstr not working (something strstr(lex[j],word) ) , doing wrong here? here code function searches 2 unique characters within array of strings : void convert(char word[]) { int i; (i = 0 ; <= strlen(word) ; i++) { if(word[i] >= 65 && word[i] <= 90) { word[i] = word[i]+32; } } } int twochar(char lex[50][50],char word[], int size,char temp[3]) { int i,j,k,count,totlen; convert(word); (i = 0 ; < strlen(word) - 1 ; i++) { count = 0; totlen = 0; for(j = 0; j<size; j++) { convert(lex[j]); totlen += strlen(lex[j]) - 1; for(k = 0 ; k < strlen(lex[j]) - 1 ; k++) { ...

python - Installing to virtual env doesn't work -

i install virtualenv, yet still runs versions c:\python27\site-packages or c:\python34\site-packages. when try install pip in venv installed , location global site-packages. any idea why be?? also virtualenv wrapper commands work when workon x doesn't activate venv. os win7. problem occurred on powershell , git bash. thanks seems realiasing pip , starting on , using --force-installed install on (including venv) worked.

javascript - Roll hover image -

Image
i searched on internet lot couldn't find useful link. trying develop custom menu. it needs area-based rollover menu changes depending on part of image being hovered on user. image , related link needs change depending on area of image user hovering over. check below image: after clicking next image below one, lastly when hover on specific slice of pizza, image should changed accordingly. example below image: is possible css3, javascript? there's 2 different ways think of. since tagged jquery i'm assuming that's acceptable. pagex , pagey track mouse movements on screen , can used determine area of screen being hovered over. here's fiddle made determine coordinates: http://jsfiddle.net/cpk3mqxw/ $("#image").mousemove(function (e) { mousex = e.pagex; mousey = e.pagey; $("#update").text("x: " + mousex + " y:" + mousey); }); edit: checking coordinates, need think of page grid system, per usual javascrip...

AutoHotKey scripting to set condition on variable? -

i new @ autohotkey scripting, need create conditions on variables before of hotstrings. for example if machine's a_username = variable1 =chris, if a_username=b variable1 =mike, on. i set before of hotstrings. here sample of code. if (a_username==a) { variable1=chris } else { variable1=mike } :#ct:: send, closing ticket, please review data , let know if have questions.thanks %variable1% return the key set conditions before of hotkeys or hotstrings dont have use if else statements on hotstrings/hotketys. any appreciated. if (a_username==a) suggests a variable name. in case, you'd want use if (a_username=="a") or if a_username = or a := "a" ; or: = if (a_username==a) ps. on use of == , note following part of documentation : the operators != , <> identical in function. == operator behaves identically = except when either of inputs not number, in case == case sensitive , = case insensitive (the meth...

java - Overriding Gradle Settings with Defaults -

i'm working on codebase many ant style projects root project , many sub projects. in root project build.gradle file declare following settings allow gradle use ant structure: subprojects { sourcesets { main { java.srcdirs = files('src') resources.srcdirs = files('config') } test { java.srcdirs = files('test/unit') resources.srcdirs = files('test/unit') } } } i want convert sub projects on maven structure 1 one, way can think stick following in each subprojects build.gradle: sourcesets { main { java.srcdirs = files('src/main/java') resources.srcdirs = files('src/main/resources') } test { java.srcdirs = files('src/test/java') resources.srcdirs = files('src/main/resources') } } which seems bit overkill. there easier way default sourcesets default maven style in individua...

java - Maven dependency management issue -

i have multi pom project, parent pom imports external module such. external module uses saxon classes, import such: <dependency> <groupid>org.test</groupid> <artifactid>test-framework</artifactid> <version>1.0-snapshot</version> </dependency> in child pom, import such: <dependency> <groupid>org.test</groupid> <artifactid>test-framework</artifactid> <scope>provided</scope> </dependency> i under impression if imported such in parent pom, transitive dependencies of external module imported. when i'm building project saxon classes missing , way can them appear explicitly pull them down in pom. doesn't defeat point of transitive dependency resolution. going have explicitly pull down transitive dependencies in project imports external module? have tried changing scope of dependency? ...

python - Plotting Parallel Coordinates in pandas with different colours -

i have data frame this: 0 1 2 3 4 5 6 7 8 9 cluster 0 0.018420 0.003357 0.002626 -0.015603 -0.009005 -0.023671 -0.016316 0.066504 -0.039526 0.037820 1 0.017684 0.003434 -0.003338 -0.003904 -0.021871 -0.009454 -0.013772 -0.004610 -0.006150 -0.005746 2 0.018857 0.003987 0.001749 -0.019840 0.011184 -0.020451 0.082434 -0.008789 0.000449 0.005445 against 3 0.020454 0.026437 0.036899 0.027168 -0.018483 -0.001076 0.005831 -0.002117 -0.011288 0.007491 4 0.018006 0.005365 0.001298 -0.006953 0.017034 0.006931 0.000268 0.001615 0.016707 -0.017798 against df.columns index([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, u'cluster'], dtype='object') the last column 'cluster' specifies whether observation belong "for" cluster or "against" cluster. i want plot such observations "for" same colour...

ruby - Instantiating a watir browser on test failure in Cucumber without using the singleton pattern -

i've been trying create "cucumber seed" project can use bootstrap browser-based acceptance test suite. alister scott has written common antipattern of closing , reopening browser windows (which adds unnecessary delay test suite), can avoided adding following env.rb file: browser = watir::browser.new before @browser = browser end at_exit browser.close end but i'm unsure of how incorporate behavior, while still restarting browser when test fails (this ensures failed test not leak browser state , cause cascade of failures unrelated scenarios). my current approach wrap watir::browser instantiation in browser singleton class, so: # support/browser.rb class browser class << self def instance @browser end def start(name: 'chrome') @name = name @browser = watir::browser.new(name.to_sym) end def stop @browser.close # if page hangs fail selenium unknown error rescue selenium::webdriver::err...

java - Setting MQ flags for reading segmented message with API exit -

i'm trying set flags seamlessly reading segmented message getbefore exit call, below: (*ppgetmsgopts)->options = mqgmo_wait | mqgmo_logical_order | mqgmo_all_segments_available | mqgmo_complete_msg | (*ppgetmsgopts)->options; it works if use rfhutil reading client, whole message read @ once, if stored segmented. when try read jms client, ends following error code: '2046' ('mqrc_options_error') mq log gives no clue, tells "internal error". could possible @ read such message jms client? if not, particular problem options? message segmentation messaging provider specific feature , not defined in jms specification. hence have use provider specific apis, mq base java classes example, segmented messages.

Working with unconstrained arrays in ada record -

i have assignment not know number of entries there prior getting them user. in assignment, use unbounded arrays. once user states maximum number, used upper bound of array, , there 3 of these declarations. then, need accept value fill each of tose arrays held in record, held in array. then, once populated, array needs passed procedure output screen. i have put demo of needs happen. not assignment, rough idea/pseudo of 1 small spart of larger assignment. right away running problem of using unconstrained array in record. with ada.text_io; use ada.text_io; ada.integer_text_io; use ada.integer_text_io; procedure vehicles type year_array array (positive range <>) of integer; type vehicle_record record name: string (1 .. 40); cars_array : year_array; trucks_array: year_array; bikes_array : year_array; end record; type o_array array (1 .. 4) of vehicle_record; procedure get_...

ruby on rails - Create Migration for Column with a Number in the Name -

i'm porting app rails , couple of columns named things like 2nd_phone 2nd_address when try doing migration using t.string :2nd_phone i syntax error, unexpected tinteger, expecting tstring_content or tstring_dbeg or tstring_dvar or tstring_end any ideas how in rals? in migration file have quotes support starting character numeric 1 , run rake db:migrate t.string :'2nd_phone' while doing way if want create new record need have this: model.create(:'2nd_phone'=> 'your value')

c++ - How to force reserve() to use a non-default constructor? -

suppose have following code snippet: mytype::mytype(); // size of mytype.amember default size mytype::mytype(int mysize); // size of mytype.amember depends on mysize ... ... std::vector<mytype> mytypevector; mytypevector.reserve(numberofobjects); // memory reserved numberofobjects * sizeof(mytype) ... how can 1 make reserve not use default constructor determine size of individual objects, use desired constructor instead? one can try following: mytype::mytype(); // size of mytype.amember default size mytype::mytype(int mysize); // size of mytype.amember depends on mysize ... ... std::vector<mytype> mytypevector(numberofobjects, mytype(desiredsize)); // memory allocated numberofobjects * sizeof(mytype(desiredsize)) ... but above calls copy constructor avoid efficiency reasons. hence question. a type can have 1 size. calling non-default constructor has no effect on size of object. such, there no need you're asking. reserve ...

javascript - Create login/signup page before routing to main page in Meteor? -

Image
i have global route uses layout.html specifies header.html. know how to: 1) have main landing page login/sign proper formatting, without header. (im using useraccounts atmosphere formatting different, not sure why). header in layout.js cannot removed. 2) upon login/sign in, should go main page. can advise how ? router.configure({ layouttemplate: 'layout', //this header specified globally waiton: function() { return [meteor.subscribe('notifications')] } }); router.route('/', { name: 'auth' }); //added new line router.route('/posts', { name: 'home', controller: newpostscontroller }); var requirelogin = function() { if (! meteor.user()) { if (meteor.loggingin()) { this.render(this.loadingtemplate); } else { this.render('accessdenied'); } } else { this.next(); } } router.onbeforeaction('datanotfound', {only: 'postpage'}); router.onb...

c# - Using gps location system services dependency injection -

i looking platform specific location details using xamarin's dependency injection running issues. more doing wrong. here current setup: numaps/interfaces/ilocationservice.cs using xamarin.forms.maps; namespace numaps { public interface ilocationservice { void initlocationservice(); position getcurrentposition(); } } numaps/numaps.droid/interfaces/locationservice.cs using system; using numaps; using numaps.droid; using xamarin.forms.maps; using android.app; using android.gms.common; using android.gms.common.apis; using android.gms.location; using android.locations; using android.widget; [assembly: xamarin.forms.dependency (typeof (locationservice))] namespace numaps.droid { public class locationservice : java.lang.object, ilocationservice, igoogleapiclientconnectioncallbacks, igoogleapiclientonconnectionfailedlistener, android.gms.location.ilocationlistener { readonly igoogleapiclient _googleapiclient; readonly loc...

javascript - Dynamically switch antialiasing on/off with three.js -

is possible dynamically switch antialiasing on/off three.js? tried following doesn't work @ all: ` var rendereraa = new three.webglrenderer({{ antialias: true }}); rendereraa.setsize( window.innerwidth, window.innerheight ); document.body.appendchild( rendereraa.domelement ); var rendererna = new three.webglrenderer({{ antialias: false }}); rendererna.setsize( window.innerwidth, window.innerheight ); rendererna.domelement = rendereraa.domelement; var renderer = rendereraa; function render() { if (somepredicate) { renderer = rendereraa; }else { renderer = rendererna; } requestanimationframe( render ); renderer.render( scene, camera ); }` if active renderer rendererna (somepredicate = false), scene freezes , no change in antialiasing. i tried set inactive renderers domelement null, didn't help. inspired question: dynamically turn on/off antialiasing , shadows in webglrenderer but there no definite answer. this not possible three.js. you need ...

django - Can I render model properties in a form which uses that model as a foreign key? -

given following models class camp(models.model): camp_id = models.autofield(primary_key=true) name = models.charfield(max_length=45) level_choices = ( ("junior", "junior"), ("adventure", "adventure"), ) level = models.charfield(choices=level_choices, max_length=9) capacity_choices = [(i, i) in range(1, 101, 1)] capacity = models.integerfield(choices=capacity_choices) start_date = models.datefield() end_date = models.datefield() open_date = models.datefield() closed_date = models.datefield() fee = models.floatfield() def size(self): """returns number of registrations camp""" size = camp.objects .filter(registration__camp_id=self.camp_id) .count() return size def is_full(self): """returns false if size of camp less capacity, otherwise returns true"...

linux - Crontab running a script in UNIX -

have simple script run top comman nand store result in txt file.it run loop 3 times day 1 hour gap.once done email sent using text file content body of email , delete text file next day new text file. problem to automate process have create cronjob start @ 8.30 pm,which start script , script keep runing 4 hours , result of command appeneded in text file , sent on mail.cron >> 0 10 * * * /tmp/ssh-abc/kkk/report.sh /tmp/ssh-abc/kkk/report.sh: line 34: reportprod.txt: permission denied code for generating txt file { //some logic } >> reportprod.txt //running script manually works great , generate txt!! delete file after mailing. find /tmp/ssh-abc/kkk/*.txt -type f -delete //this works fine manually,file getting generated , deleted also. /tmp/ssh-abc/kkk/report.sh: line 39: reportprod.txt: no such file or directory can me out problem here? have goggled few things not hitting right point. given permission folder 0755 in expectation cron...

Test rules on the Business Rules service on Bluemix -

Image
i deployed ruleapp business rules service. can log in rule execution server console , see correctly deployed. how test rules? in ruleset view of rule execution server console, clicked on "retrieve htds description file", chose options "rest", "latest ruleset version" , "decision trace information", , clicked on "test" button. opened new browser tab allowed me choose data format (xml or json) , generated sample payload (with tracing enabled since chose "decision trace information" option earlier). clicked on "execute request" , server response displayed. however, discovered new ui business rules service on bluemix console, meant did not need use rule execution server console anymore test ruleset. in "decision services" tab of business rules service, able see newly deployed ruleapp , ruleset (i had click "refresh"). clicked on arrow beside ruleset (the tooltip said "test servic...

javascript - Cannot create multiple ckeditor instances ("default" is already registered) -

i have page (using kendo-ui if makes difference) has 3 text areas need made editors. problem can create 1 ckeditor instance. no matter how try create new instances, error: uncaught exception: [ckeditor.resourcemanager.add] resource name "default" registered. google-ing specific error message lands me 1 result doesn't tell me it. this have tried far after searching various issues mine on stack overflow: --deleting instances of editor if not being used /are hidden var editor = ckeditor.instances['createtext']; if (editor) { editor.destroy(true); } $('#edittemplate').ckeditor(); --creating instances in document ready $('#createtext').ckeditor(); $('#edittext').ckeditor(); $('#edittemplate').ckeditor(); --using class names instead of jquery spawn instances <textarea id="edittext" class="ckeditor"></textarea> --not using jquery , creating instances with ckeditor.re...

xaml - ListView moving left and right while scrolling -

i have following listview: <listview itemssource="{binding artistlist}"> <listview.itemtemplate> <datatemplate> <border borderthickness="0,0,0,0.5" borderbrush="#22ffffff" tapped="artisttapped"> <grid> <grid.columndefinitions> <columndefinition width="auto"/> <columndefinition width="*"/> </grid.columndefinitions> <ellipse grid.column="0" canvas.zindex="0" fill="#22ffffff" width="50" height="50" margin="0,10"/> <ellipse grid.column="0" canvas.zindex="1" stretch="uniformtofill" width="50" height="50" margin="0,10"> <ellipse.fill> ...

How can I find classes that annotated with Scala annotations? -

for example : import scala.annotation.staticannotation class myannotation extends staticannotation @myannotation class a{ ............ } the question how can scan classpath find classes annotated myannotaion without using spring or org.reflections module?

angularjs e2e - How to test slide-box in protractor -

i have slide-box described in 1 of protractor tests; can find box , can properties (i.e. 'how many') how cycle through boxes can test verify display, e.g. profilepage.slides.next() expect(profilepage.slide.slidetitle = 'credentials' profilepage.slides.next() expect(profilepage.slide.slidetitle = "info" etc. controller: .controller('profilectrl', function ($scope, profileservice) { $scope.data = { numviewableslides: 0, slideindex: 0, initialinstruction: true, secondinstruction: false, slides: [ { 'template': 'templates/slidebox/credentials.html', 'viewable': true }, { 'template': 'templates/slidebox/contactinfo.html', 'viewable': true }, { 'template': 'templates/slidebox/employeeinfo.html', ...

android - Different adapter in items of recyclerview -

i creating list contains, different types of views. like facebook in showing feeds in mobile application. example times scrollview or times list inside list. to choice. if add fragment in each item of recyclerview. like <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <fragment android:layout_width="match_parent" android:name="com.profile.editprofilefragment" android:layout_height="wrap_content"/> and add item in reclycleview , keep different logic inside it. can 1 suggest me how go through this. i don't think it's going possible using fragment row. fragment has own lifecycle don't lies within recyclerview can control. can simple view. just override several methods in recyclerview.adapter private arraylist<data> it...

forms - yii2 validate empty dropdownlist, checkbox -

i have fields required in model , dropdownlist on form. if try submit form without selecting no validation error occurs on view way textinput would. model [['name', 'survey_type','country_id'], 'required', 'isempty' => function ($value) { return empty($value); } ], display empty red validation <?= $form->field($model, 'name')->textinput(['maxlength' => 255]) ?> does not display validation <?= $form->field($model, 'survey_type')->dropdownlist([$surveytypelist],['prompt'=>'select survey type','id'=>'survey_type_dropdown']) ?> this because overrided id drop-down list: 'id' => 'survey_type_dropdown' you shouldn't if want client validation working field. ids generated automatically , used in javascript related activeform . remove , should ...

java - How to prevent spring-boot autoconfiguration for spring-web? -

i'm using spring-boot , added spring-web dependency in maven pom, make use of resttemplate . now spring tries initialize embeddedservletcontext . how can prevent it? exception in thread "main" org.springframework.context.applicationcontextexception: unable start embedded container; nested exception org.springframework.context.applicationcontextexception: unable start embeddedwebapplicationcontext due missing embeddedservletcontainerfactory bean. @ org.springframework.boot.context.embedded.embeddedwebapplicationcontext.onrefresh(embeddedwebapplicationcontext.java:133) @ org.springframework.context.support.abstractapplicationcontext.refresh(abstractapplicationcontext.java:474) @ org.springframework.boot.context.embedded.embeddedwebapplicationcontext.refresh(embeddedwebapplicationcontext.java:118) @ org.springframework.boot.springapplication.refresh(springapplication.java:686) @ org.springframework.boot.springapplication.run(springapplication.ja...