Posts

Showing posts from February, 2015

coded ui tests - When would you use the UITestControl.Find method? -

when checking whether page/screen has loaded, use uitestcontrol.waitforcontrolexist() method, finding example code follows ctl.waitforcontrolexist() otherctl.find() calls on parent controls. this: var tab = uimainmenuextwindow.uiitemwindow.uiribbonclient.uisolutionstabpage; tab.waitforcontrolexist(3000); uimainmenuextwindow.find(); uimainmenuextwindow.uiitemwindow.find(); uimainmenuextwindow.uiitemwindow.uiribbonclient.find(); uimainmenuextwindow.uiitemwindow.uiribbonclient.uisolutionstabpage.find(); tab.find(); mouse.click(tab); does code make sense? purpose of 'find()' calls? after setting searchproperties , filterproperties etc ui control, find method causes search performed. commonly find not called explicitly (or possibly equivalent internal method) called implicitly when ui control evaluated in expression parent of control. consider: this.uimap.uitoplevel.actionmethod(); in above statement value of uitoplevel must evaluated find object actionme...

Are global hotkeys in a C# Mono project possible on Linux? -

so i'm creating screenshotting app linux/windows using mono , c#, , while there's extensive documentation on how global key combinations windows - there's next none linux. is possible global key listening in c# - have write in c, , if so, can point me documented bit of code doing (i have no c experience @ all). an example of hitting 'ctrl + print screen' when application not in focus, prompt application method. is possible? thanks in advance. different desktop environment / window managers in linux handle keyboard shortcuts differently. different distros can have varying configuration file locations. you'll have choose targets you'll support, , work there.

html - How to keep navigation text inline with the end of an image -

i'm creating navigation bar , want text, going on right, inline end of image. want stay aligned , in position regardless of whether window resized or not. i've included image incase haven't explained well: http://i.stack.imgur.com/qwr6l.png hopefully guys can help! is looking achieve ?... http://jsfiddle.net/65fbd/ way achieved float image right , wrap image , links inside div , give min-width attribute. hits minimum width specified in viewport, division not shrink after maintaining inline look. here css #navcontainer { width:100%; min-width:400px; height:40px } #image { float: left; } #links { float:right; } and html... <div id="navcontainer"> <img src="http://dummyimage.com/230x40/123dfe/fff" id="image"/> <p id="links"> &nbsp;&nbsp;link&nbsp;&nbsp;|&nbsp;&nbsp;link&nbsp;&nbsp;|&nbsp;&nbsp;link&nbsp;&nbsp;</p> </div> but ...

javascript - Backbone call model function -

i have collection, collection i've selected model. in model i've defined function. how can call function of model selected collection? where call model function (but undefined): var singlehomepostview = backbone.view.extend({ tagname: "li", template: handlebars.compile(template), events: { "click #retweet": "retweet", }, initialize: function () { // console.log(this.model); this.model.bind("change", this.render, this); this.model.bind("destroy", this.close, this); }, render: function (eventname) { var ad = this.model.tojson(); ad.cid = this.model.cid; $(this.el).html(this.template(ad)); return this; }, retweet: function () {//here---------- console.log(this.model);// defined console.log("retweet"); console.log(this.model.retweet()); //here try call model function }, }); ...

Ajax doesnt work on ruby on rails -

this clear method of catalog_controller def clear @page_title = 'vaciar carro' if request.xhr? @cart.cart_items.destroy_all flash[:cart_notice] = "carro vaciado." render :controller => 'cart', :action => 'clear_with_ajax' elsif request.post? @cart.cart_items.destroy_all flash[:cart_notice] = "carro vaciado." redirect_to :controller => 'catalog' else render :controller => 'cart', :action => 'clear', :template => 'cart/clear' end end this clar_with_ajax.js.erb code jquery.noconflict(); jquery('#shopping_cart').html("<%= j render :partial =>'cart/cart' %>"); and that's part of view calls clear method <p id='cart_total'><strong>total: <%= sprintf "%0.2f €", @cart.total %></strong></p> <% unless @cart.cart_items.empty? %> <p id='clear_cart_link'> <b...

php - Zend view url function issues -

first i'd admit didn't enough searching because didn't know how put in words fit search. 'getting clean urls in zend' or 'ignore comes after action in zend' can't name well, sorry this. guide me duplicates, i'll delete @ once :> now, story goes this: let's in page project/public/home i've got link <a href="<?php echo $this->url(array( 'controller' => 'test', 'action' => 'index' )); ?> "> <?php echo $this->translate('go_to_test_index'); ?> </a> that me project/public/home/test/index (index omitted default) let's link parameter <a href="<?php echo $this->url(array( 'controller' => 'message', 'action' => 'add', 'id' => 1//some value or parameter )); ...

JavaScript: Finding a difference between two dates in years -

i've got 2 timestamps e1 , e2 (both expressed in milliseconds since jan 1st 1970). want know difference between them in years (including parts of years - e.g. 2.74 acceptable result). dividing (e2 - e1) 31536000000 not right idea because of leap years. there elegant solution ? the ideas in comment nice. however, need determine if 1 of timestamps leap year. simple find difference between first date , second date, comparing timestamps without years. example: http://jsfiddle.net/en8qg/ function compareyears(t1, t2) { var day = 24 * 3600 * 1000, year = 365 * day, d1 = new date(t1), d2 = new date(t2), y1 = d1.getfullyear(), y2 = d2.getfullyear(), isleap1 = new date(y1, 1, 29).getmonth() == 1, isleap2 = new date(y2, 1, 29).getmonth() == 1, ms1 = t1 - date.utc(y1, 0, 0), ms2 = t2 - date.utc(y2, 0, 0), diff = ms2 - ms1, rest; if (isleap1 && isleap2) { //two leap years ...

android - how can i set selected value from alert dialog (single selection) on my list view item? -

how can set selected value alert dialog (single selection) on list view item?... scenario is: - have listview item button , textview - clicking on button in listview item , opens dialog box - selecting value single selection list in dialog box - want show selected value dialog in textview inside listview item here code: problem is: value changed inside listitem view setting in dialog box, doesnt persist on scroll , down. public view getview(int position, view convertview, viewgroup parent) { final viewholder holder; db = new databasehandler(getcontext()); if (convertview == null) { layoutinflater inflater = (layoutinflater) context.getsystemservice(context.layout_inflater_service); convertview = inflater.inflate(r.layout.activity_event_item, parent, false); holder = new viewholder(); holder.x = (textview) convertview.findviewbyid(r.id.x); holder.y = (textview) convertview.findviewbyid(r.id.y); ...

stack - Data structure that deletes all elements of a set less than or equal to x in O(1) time -

Image
i self studying algorithms course, , trying solve following problem: describe data structure store set of real numbers, can perform each of following operations in o(1) amortized time: insert(x) : deletes elements not greater x, , adds x set. findmin() : find minimum value of set. i realize findmin kind of becomes trivial once have insert, , see how linked list implementation, delete multiple elements simultaneously (ie o(1)), finding out link delete (aka x goes) seems o(n) or o(log n) operation, not o(1). problem gave hint: consider using stack, don't see how helpful. any appreciated. the original question below: note goal o(1) amortized time, not o(1) time. means can work you'd per operation long n operations don't take more o(n) time. here's simple solution. store elements in stack in ascending order. insert element, keep popping stack until it's empty or until top element greater x, push x onto stack. find-min, read top of stack. ...

sql server - Make ADO generate parameters for a temporary stored procedure? -

i'm trying ado recognize parameters stored procedure on sql sever. if normal stored procedure, works fine: conn.execute "create proc normalsp (@i int output) set @i = 3" cmd.commandtype = adcmdstoredproc cmd.activeconnection = conn cmd.commandtext = "normalsp" cmd.parameters.refresh 'parameters list has @return_value , @i cmd.execute debug.print cmd("@i") but if try same thing temporary stored procedure, can't parameters: conn.execute "create proc #tempsp (@i int output) set @i = 3" cmd.commandtype = adcmdstoredproc cmd.activeconnection = conn cmd.commandtext = "#tempsp" cmd.parameters.refresh 'parameters list remains empty cmd.execute 'error: command expects parameter '@i', not supplied debug.print cmd("@i") 'error: item cannot found in collection what more need parameters.refresh work temp sp normal sp? asking 2 black boxes (legacy ado, oledb/odbc provider) why don't ...

Disable bluetooth Low Energy bonding 30 second timeout in Android -

i have ble peripheral in "just works" encryption mode. after bonding using bluetoothgatt.getdevice().createbond() , there seems 30 second interval after bonding complete (measured message reception in action_bond_state_changed receiver) during bluetoothgatt.disconnect() not disconnect. i'd disable or decrease 30 second interval. i'm guessing interval related period pin entry, using works encryption no pin necessary (or requested android). to summarize in pseudo-code: bluetoothgatt.getdevice().createbond(); .... //bonding successful reported action_bond_state_changed broadcast receiver bluetoothgatt.disconnect(); ... //30 seconds after disconnect call peripheral disconnects //note if wait 10 seconds before calling disconnect, peripheral disconnects 20 s later, if wait 15 s, disconnect occurs 15s later, etc...

angularjs - JayData and Angular - Save Form Data -

i new angular , jaydata. need grab data drop down , save jay data. not sure @ missing. have. in index.html page have drop down , button save data when clicked. can please me understand need here? thanks <select id="year" name="year" class="input-large" ng-model="year" > <option value="0" selected=""disabled="">&lt;year&gt;</option> <select id="year" name="year" class="input-large" ng-model="year" > <option value="0" selected="" disabled="">&lt;year&gt;</option> <option value="2001">2001</option> <option value="2002">2002</option> <option value="2003">2003</option> <option value="2004">2004</option> <option value="2005">2005</o...

sql - TSQL XML Parsing / Insert -

i passing xml stored procedure , inserting table. if passing multiple nodes, of happening before gets something else comment? for example, if xml contained 6 vehicle nodes, insert statement run 6 times. of run before reaching something else line? the reason ask because want insert data xml separate table using lastinsertedid code below. can done? insert licenseplates (carcolor, carmodel, licenseplate, empid, dateadded) select paramvalues.x2.value('color[1]', 'varchar(100)'), paramvalues.x2.value('model[1]', 'varchar(100)'), paramvalues.x2.value('licenseplate[1]', 'varchar(100)'), @empid, getdate() @xmldata.nodes('/vehicles/vehicle') paramvalues(x2) --something else yes. 6 rows inserted before code hits -- else line. so if want capture 6 ids , insert audit tab...

usage of the append function of list in python -

class solution: # @param num, list of integer # @return list of lists of integers def permute(self, num): self.res = []; self.dfs(num, 0) return self.res def dfs(self, num, level): if level == len(num): self.res.append(num) print(num) return in range(level, len(num)): num[i], num[level] = num[level], num[i] self.dfs(num, level+1) num[i], num[level] = num[level], num[i] the above code used generate permutations given collection of numbers. example, num = [1, 3] result be: [1 3], [3, 1] but there bug above code don't understand, self.res.append(num) . if change self.res.append(num[:]) , code correct. can explain why? using self.res.append(num) , result is: [1, 3], [1, 3] using self.res.append(num[:]) , result is: [1, 3], [3, 1] the elements of python list references other obje...

Matlab error: input argument not defined -

i wrote function as: function f = factorial(x) f = prod(1:x); f =factorial(5); end but when tried running it, says input argument not defined. what's wrong this? you have defined function recurses endlessly. f = factorial(5); in third line call function again, again call function once reaches third line, again call function... never done. when implementing recursive solution need provide base case. here's example calculating factorials. function f = factorial(x) if x == 0 % base case f = 1; else f = x*factorial(x-1); % recursive case end end example: >> factorial(5) ans = 120 as your input argument not defined problem, need tell used input argument. above example, any* integer x>=0 should work. *as long f has enough bytes hold result.

r - How to make sublist/extract expression data of candidate genes from normalized microarray list -

i have several processed microarray data (normalized, .txt files) want extract list of 300 candidate genes (ilmn_ids). need in output not gene names, expression values , statistics info (already present in original file). have 2 dataframes: normalizeddata identifiers (gene names) in first column, named "name". candidategenes single column named "name", containing identifiers. i've tried 1). all=normalizeddata subset=candidategenes x=all%in%subset 2). all[which(all$gene_id %in% subset)] #(as suggested in other bioinf. forum)#, but returns dataframe 0 columns , >4000 rows. not correct, since normalizeddata has 24 columns , compare them, error. the key able compare first column of ("name") subset. here info: > class(all) > [1] "data.frame" > dim(all) > [1] 4312 24 > str(all) > 'data.frame':4312 obs. of 24 variables: $ name: factor w/ 4312 levels "ilmn_1651...

ruby on rails - Sqlite3 getting ActiveRecord::ConnectionTimeoutError Heroku -

i using rails 4.0.4. error happening more upgraded 4.0.1. we using sqlite3 in production (something didn't realize). have created postgres db before, suppose can switch on postgres, if seems problem. be? [if bc sqlite, there easy way convert past data sqlite data?] 2014-05-29t17:46:29.300034+00:00 app[web.2]: activerecord::connectiontimeouterror (could not obtain database connection within 5.000 seconds (waited 5.003 seconds)): http://pastebin.com/8pzkvpuk production: adapter: sqlite3 database: db/production.sqlite3 pool: 5 timeout: 5000 i noticed in gemfile gem 'sqlite3', :group => [:development, :test] gem 'pg', :group => [:production] does mean using pg production though yml saved .sqlite3? heroku doesn't allow use of sqlite3 in production. https://devcenter.heroku.com/articles/sqlite3 you have switch pg. check database connection with: activerecord::base.connection.current_database and adapter used: active...

Better way to rethrow errors for debugging javascript in Chrome -

the chrome debugging tools great of time, lately i've been annoyed errors rethrown. there doesn't seem way see call stack unless have set pause on caught exceptions, run gobs of errors other libraries. makes pausing on exceptions pretty useless if want display errors nicely. consider example ( http://jsfiddle.net/redbmk/83y8l/1/ ): html: <button id="push-me"></button> javascript: function bedangerous() { var 1 = 1, rand = parseint(math.random() * 2); if (rand === one) console.log("you win"); else if (rand === zero) console.log("you lose"); } function warnuser(error) { alert("hey, went wrong! refresh page"); throw error; } function runcode() { try { bedangerous(); } catch (e) { warnuser(e); } } document.getelementbyid("push-me").addeventlistener("click", runcode); when run error, call stack shows warnuser threw error , called runcode . the...

sorting - Change the way sorted works in Python (different than alphanumeric) -

i'm representing cards in poker letters (lower , uppercase) in order store them efficiently. need custom sorting function allow calculations them. what fastest way sort letters in python using ['a', 'n', 'a', 'n', 'b', 'o', ....., 'z'] as ranks rather than ['a', 'b', 'c', 'd', 'e', 'f', ....., 'z'] which default? note, sorting derived from: import string c = string.letters[:13] d = string.letters[13:26] h = string.letters[26:39] s = string.letters[39:] 'a' = 2 of clubs 'n' = 2 of diamonds 'a' = 2 of hearts 'n' = 2 of spades etc you can provide key function sorted , function called each element in iterable , return value used sorting instead of elements value. in case might following: order = ['a', 'n', 'a', 'n', 'b', 'o...

java - Why is this program running so slowly? -

this project euler problem 14. when number even, you're supposed divide number two, when odd multiply 3 , add one. should reach one. my task find number takes largest amount of steps 1. here's code: int currentnum = 0; int iterator = 0; int[] largestchain = new int[]{0,0}; for(int = 10;i<=1000000;i++) { currentnum = i; iterator = 0; while(currentnum!=1) { iterator++; if(currentnum%2==0) { currentnum/=2; } else { currentnum = (currentnum*3)+1; } } if(iterator>largestchain[1]) { largestchain[0] = i; largestchain[1] = iterator; } } system.out.println("largest iterator:"+largestchain[1]+"for num:"+largestchain[0]); can please me out telling me what's slowing down? (it's taking >30 minutes right , still ...

Run a Perl script in PHP - Plesk 11 -

how can run a perl script in every page of server? i put code @ /var/www/cgi-bin , need correct code run it. should place it. i have added code httpd.conf: action add-footer /cgi-bin/script.cgi addhandler add-footer .htm .htm and on site have added code script. if page .html code runs page php code not run. i have tried not work, in works on html files not in php <directory / > options +execcgi addhandler cgi-script .cgi .pl addhandler application/x-httpd-php5 .php addhandler application/x-httpd-php .html .htm addhandler php-cgi .php addhandler cgi-script cgi pl addhandler cgi-script .html addhandler cgi-script .php action add-footer /cgi-bin/script.cgi addhandler add-footer .html .htm .php php </directory> the way trying not work dynamic content work static content.

node.js seems not work in Ruby 1.8.7 and Rails 3.1.0 -

i have installed ruby 1.8.7 , rails 3.1.0 . when rails s error triggered. alberto@alberto:~/screencast/tasks$ rails s /home/alberto/.rvm/gems/ree-1.8.7-2012.02@screencast/gems/execjs-2.1.0/lib/execjs.rb:2:in `require': /home/alberto/.rvm/gems/ree-1.8.7- 2012.02@screencast/gems/execjs-2.1.0/lib/execjs/runtimes.rb:22: syntax error, unexpected ':', expecting ')' (syntaxerror) name: "node.js (v8)", ^ /home/alberto/.rvm/gems/ree-1.8.7-2012.02@screencast/gems/execjs-2.1.0/lib/execjs/runtimes.rb:22: syntax error, unexpected ',', expecting kend /home/alberto/.rvm/gems/ree-1.8.7-2012.02@screencast/gems/execjs- 2.1.0/lib/execjs/runtimes.rb:23: syntax error, unexpected ',', expecting kend /home/alberto/.rvm/gems/ree-1.8.7-2012.02@screencast/gems/execjs- 2.1.0/lib/execjs/runtimes.rb:24: syntax error, unexpected ',', expecting kend /home/alberto/.rvm/gems/ree-1.8.7-2012.02@screencast...

HTML5 IOS/Cordova Hybrid App Input Fields Issue -

Image
i have html5 app , on ios device when input fields have focus virtual keyboard comes , pushes app view when virtual keyboard goes away leaves app in same state , can't figure out why. please see below screen shots , let me know thoughts on issues has have researched issue , can't seem find solution.

tsql - Where do I put the CONVERT statement to change DATETIME to just DATE in UPDATE Satement -

i have query produces date in datetime format... see below. update wcv_3 set visit_1= #temp2.[first service date] wcv_3 join #temp2 on #temp2.universalmemberid= wcv_3.universalmemberid #temp2.visit_cnt= 1 returns this: 2013-01-03 00:00:00.000 what correct convert statement use , place in query return date , not time part? i want 2013/01/03 update wcv_3 set visit_1= cast(#temp2.[first service date] date) wcv_3 join #temp2 on #temp2.universalmemberid= wcv_3.universalmemberid #temp2.visit_cnt= 1

JSF: Caused by: java.lang.IllegalStateException: Could not find backup for factory javax.faces.application.ApplicationFactory. -

i using jsf 2.2.4( javax.faces-2.2.4.jar), tomcat 7.0.52 server , jdk 1.7. addding jar lib of application. when deploying application server showing above said exception. have looked other related question in so others communities none of them solved problem. mistake doing ? thanks.

java - Android BluetoothDevice Reflection -

i have found several examples of using reflection call methods on instances of android's bluetoothdevice objects.( http://developer.android.com/reference/android/bluetooth/bluetoothdevice.html ) example: how unpair or delete paired bluetooth device programmatically on android? can methods invoked directly on object instances? found in documentation bluetoothdevice: "this class thin wrapper bluetooth hardware address. objects of class immutable. operations on class performed on remote bluetooth hardware address, using bluetoothadapter used create bluetoothdevice." does imply reflection necessary invoke methods? why code uses consistently use reflection these objects?

asp.net mvc - JQuery-validate submitHandler not working on MVC 4 -

i'm working on mvc4 view model , trying implement unobtrusive validation jquery. testing purposes, have implemented couple of custom validation rules , work when copy generated mvc code (see below) jsfiddle, not work @ within mvc project. i know javascript working in mvc view model because alert('lol') indeed pop everytime page loads. submit handler , validation rules have no effect. as note, following set true on web.config: <add key="clientvalidationenabled" value="true" /> <add key="unobtrusivejavascriptenabled" value="true" /> also, these included scripts: <script src="/scripts/jquery-1.7.1.js"></script> <script src="/scripts/jquery.unobtrusive-ajax.js"></script> <script src="/scripts/jquery.validate.js"></script> <script src="/scripts/jquery.validate.unobtrusive.js"></script> <script src="/scripts/jquery-u...

.net - Reduce Task Parallel Library "Boilerplate" -

my team using task parallel library first time, , colleague has come code listed below. running few things, using data make further server requests (the methods async in name), , using data comes server call more data. after of these loaded, items on ui (usually combo boxes) updated (in methods returned in name), user use filters. basically, figure out companies user has access to, based on information, load more "filters" data (loading defaults), , load data default view. while code works, seems there's lot of duplicate code, , wondering if extension method or other code change used reduce amount of code needed this. private sub getandloadviewdata() dim nocanceltoken = cancellationtoken.none const attachtoparent taskcontinuationoptions = taskcontinuationoptions.attachedtoparent task.factory.startnew( sub() 'fire off child tasks task.factory.startnew(function() getcompaniesasync()).continuewith( ...

for loop - Python - Syntax error with nested iterations? -

so have code: chars = maketrans(" abcdefghijklmnopqrstuvwxyz-.,"," abcdefghijklmnopqrstuvwxyz-.,"); input = input.split(" "); length = len(input); charlength = len(chars); x in range(1,length): y in range(1,charlength): z in range(minint,maxint): if transform(z + x.translate(chars) + key)[:5] == input[x] print x.translate(chars) the function receives blocks of 5 characters separated spaces. when attempting run it, following error: file "sh25.py", line 21 if transform(z + x.translate(chars) + key) == input[x] ^ syntaxerror: invalid syntax i'm admittedly newbie @ python, help? thanks. the error message pretty precise: need : after if if transform(z + x.translate(chars) + key)[:5] == input[x]:

spring data - Create index in correct collection -

i annotate document @index(unique = true) so: public class adocumentwithuniqueindex { private static final long serialversionuid = 1l; @indexed(unique = true) private string iamunique; public string getiamunique() { return iamunique; } public void setiamunique(string iamunique) { this.iamunique = iamunique; } } when saving object, specify custom collection: mongooperations mongodb = ... mongodb.save(document, "mycollection"); as result get: a new document in "mycollection" an index in collection "adocumentwithuniqueindex" how can create index in "mycollection" instead without having explicitly specify in annotation? background: the default collection name ambiguous in our use case. cannot guarantee, there wouldn't 2 documents same name in different packages. added package name collection. mapping document collection dealt in infrastructure component. the implementation ...

http - Router servlet for webservice project -

in recent project started using maven , instead of depending on rad deploy , build ear, have been coming across little things why use , 1 best.. my question here , below code copied form web.xml , com.ibm.ws.websvcs.transport.http.wasaxis2servlet servlet ibm route http request web services, there servlet present java can replace above 1 , dont want our ear generation should dependent on specific application server <servlet> <servlet-name>com.test.helloworld</servlet-name> <servlet-class>com.ibm.ws.websvcs.transport.http.wasaxis2servlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>com.test.helloworld</servlet-name> <url-pattern>/helloworldservice</url-pattern> </servlet-mapping> no. the servlet you're seeing in web.xml ibm-proprietary servlet routes http requests web services and, far can tell, if you're running 7.0 onwards don't need it. can use jax-ws ...

sql - Query returns a different result every time it is run -

this query returns same amount of rows but, in different order, every time. why happen? i have more filters add can't past step. begin declare @laststatus varchar(10) select [job].[job], [job].[part_number], [job].[rev], [job_operation].[description], [job].[customer_po], [job].[customer_po_ln], [delivery].[promised_date], [job_operation].[operation_service], [job].[note_text], [job_operation].[status], [job_operation].[sequence] [#tmptbl] [production].[dbo].[job_operation] inner join [job] on [job_operation].[job]=[job].[job] inner join [delivery] on [job_operation].[job]=[delivery].[job] [job].[status]='complete' order [job_operation].[job],[job_operation].[sequence] select * [#tmptbl] drop table [#tmptbl] end put order by on select * #tmptbl , not on insert .

javascript - Find object by properties from array -

with array, value, , and object nested objects: object mesh array ['options', 'range', 'x'] value 12.5 is possible translate update property, e.g. mesh.options.range.x = 12.5 attempted: index = (obj, i) -> obj[i] arr.reduce(index, obj) = 12.5 update thank elegant solutions. using .reduce() pretty nice this: // current object----| |----current key // v v arr.reduce(function(obj, key) { return obj == null ? obj : obj[key]; }, window.mesh); // ^ // |-- initial object your attempt use .reduce() needed pass function manages "accumulation". here, long previous obj wasn't null or undefined , it'll return key of current obj , becomes next obj . then since need assign value, you'd want value of second last key. var o = arr.slice(0,-1).reduce(function(obj, key) { return obj == null ? obj : obj[key]; }, window.mesh); and check existence , us...

timezone - Look up time zone from latitude and longitude using Perl -

i'm looking way use perl time zone corresponding given latitude , longitude. program runs on linux okay too. i have pictures time in utc , gps coordinates , want use them on website local time , date. i found geo::location::timezone module on cpan looks job, doesn't work , i'm still trying figure out why. depending on amount of lookups need , terms of use, google time zone service looks trivial use. use strict; use warnings; use lwp::simple; use json::any; ($lat, $long) = (39.6034810,-119.6822510); $apikey = 'whatever'; $time = time(); $location = json::any->jsontoobj(get("https://maps.googleapis.com/maps/api/timezone/json?location=$lat,$long&timestamp=$time&sensor=false&key=$apikey")); $location->{timezoneid}; # america/los_angeles $location->{timezonename}; # pacific standard time

scala - Compile errors when defining a macro to convert a case class instance into a map and back -

i'm trying understand following blog post, discusses how use macros create generic macro-based approach convert case class objects , map: http://blog.echo.sh/post/65955606729/exploring-scala-macros-map-to-case-class-conversion even though read entire post , article on scala macros, still not understand how work. unfortunately, i'm receiving couple of compile errors example code given in blog post , not sure why errors occurring nor how resolve them. i'm reproducing code below, preceded compile errors, completeness (i annotated code snippet comments regarding compile errors). know why these compiler issues occurring , how resolve them? -type mismatch; found : field.nametype required: c.universe.termname -can't unquote list[nothing] .., bottom type values indicate programmer mistake here's code: import scala.reflect.macros.context import scala.language.experimental.macros trait mappable[t] { def tomap(t: t): map[string, any] def frommap(map: map...

javascript - Showing Credit Card Brand Within TextField with JQuery -

i have input text field credit card number. i'd change image background whenever credit card number inserted. goal show credit card brand within it. the code i've been working on is: function get_brand_image(){ $.ajax({ url: '/cards', type: "post", datatype: "json", data: {code: $("#card_brand").val()}, error: function(response){ }, success: function(response){ $('#card_brand').css({background: "'url("+response['path']+") 0 no-repeat'", 'background-position': 'right'}) } }); } the above code doesn't add background image text although second hash parameter ('background-position': 'right') is. what's strange if put raw comand: $('#card_brand').css({background: 'url(/assets/cards/visa.png) 0 no-repeat', 'background-position': 'right'}) everything done it's supposed...

themes - how can I add a css for my plugin in wordpress? -

this question may seem dummy, found info on codex (its first project on wordpress) , want style admin , frontend... wrote can use this wp_register_style( 'uni-bootstrap', ds.'plugins'.ds.'uni-info'.ds.'css'.ds.'bootstrap.min.css' ); wp_enqueue_style('uni-bootstrap'); i named ds variable, in case linux or windows (directory slash) , still, on loaded page, , route correct, no slashes. try write them own "/" , still, no success.. i absolute path, when see loads says undefined so, changed , try other way(for admin only) add_action( 'admin_head', 'admin_css' ); function admin_css(){ echo '<link rel="stylesheet" type="text/css" href="mypath">'; } still, same undefined result, dont know how load it, , how use paths, due dont know how wordpress manage folders , on, idea? add_action( 'wp_enqueue_scripts', 'register_plugin_styles' ...

sql server - Change tracking - sys_change_operation are all "I"? -

i created test table. create table test (id int not null, ......) on [primary] (data_compression = page) go alter table test add primary key clustered (id) (data_compression = page) on [primary] go create nonclustered index [ix_timestamp] on test ([timestamp]) (data_compression = page) on [primary] go alter table test enable change_tracking (track_columns_updated = on) update: table has trigger writing pks of changes in table and inserted values in table. updated 1 row using update test set ... id = 1 . however following query returns "i" sys_change_operation? can cause problem? (btw, tried enable cdc, doesn't capture anything.) select distinct commit_time,sys_change_operation, count(*) -- select * changetable(changes dbo.test, 0) c join sys.dm_tran_commit_table tc on c.sys_change_version = tc.commit_ts group commit_time, sys_change_operation results: commit_time sys_change_operation count ----------------------- -----------...

excel - If "x" is in column A and "y" is in column B, I want column C to be 5. I have a list of about 190 values. What is the most efficient way to do this? -

i have list of 190 column c values correspond specific column , column b values. created huge if statement, excel says it's large , keep messing parentheses. more efficient way solve problem? example, if column "united" , column b "brain", want column c 150. first value. thank you. if data in column , b. use concatenate in column c: concatenate(a1, b1) then in sheet values, insert column between values column , 2 criteria columns. use concatenate in column (sane formula above). then on first sheet in column d use formula: vlookup(c1, sheet2!c1:d190, 2, false) this assuming second sheet sheet 2 yadda yadda. let me know if run issue!

python - How can I simulate mouse movement in OSX, not just change the cursor location -

this question has answer here: how control mouse in mac using python? 10 answers i'm playing leap motion controller , trying use controller game surgeon simulator. if search "leap motion oculus rift surgeon simulator", you'll understand end goal. however, i'm having issues simulating right kind of mouse movements on mac. problem: the movement in game seems work based off of mouse movement, not cursor location. example, can move mouse infinitely left , still see interaction in game - never hits edge. libraries i've tried, don't seem mimic right behavior. i've tried autopy's smooth_move, pyuserinput's mouse library, , methods found on various blogs including http://www.geekorgy.com/index.php/2010/06/python-mouse-click-and-move-mouse-in-apple-mac-osx-snow-leopard-10-6-x/ , http://metapep.wordpress.com/2009/07/10/contr...

vsts - Java heap space error when migrating to Visual Studio Online using OpsHub Migration Tool -

i'm trying use opshub migration tool our source code onto visual studio online. partway through migration, progress page indicates error occurred , migration has halted, , yet process still continues run (ie - migration status still says it's running, , process manager indicates work still being done opshubtfsservice.exe process). if click on hyper link in error message, opens popup dialog indicating there's been java heap space error of kind. looking closer @ running processes, can see java.exe process using on 2gb of ram. i'm running migration tool on windows 7 x64 machine 16gb of ram , loads of disc space free. source server running tfs 2013. i've run tool few times now, , run same issue right @ same point during migration (xxxx/yyyy chageset(s)/label(s) passed). doesn't seem xxxx+1/yyyy, perhaps need let run longer it's chewing on large changeset of somekind. any suggestions on how, or if it's possible passed error? should concerned it, or ...

javascript - Rails Show value from a select box on change method -

i'm trying show value model, when select box value changes. code it's this. <%= f.label :nit , "client nit:" %> <%= f.collection_select(:nit, client.all, :nit, :nit, :prompt => "select nit")%> my client model has name , nit, need display value according nit selection example: i have in table: nit=>name 12345678=>john doe 987654321=>bruce wayne 327654=>clark kent if choose first 1 in select box, need display "john doe". i'm trying nothing works me. try this <%= f.collection_select(:nit, client.all,:nit,:name,:prompt => "select nit")%>

python - Calling function from another staticmethod function within a class -

i have following code, cool_function() i'd call somefunc() class myklass: # function internally called def somefunc(self,text): return (text + "_new") @staticmethod def cool_function(ixdirname, ixname): tmp = self.somefunc(ixname) print ixdirname, ixname, tmp return tmp = myklass.cool_function("foodir","foo") the result want print out is: foodir, foo, foo_new what's way it? prints this: tmp = self.somefunc(ixname) nameerror: global name 'self' not defined you may want this: class myclass: @staticmethod def somefunc(text): return text + '_new' @staticmethod def cool_function(ixdirname, ixname): tmp = myclass.somefunc(ixname) print((ixdirname, ixname, tmp)) return myclass.cool_function('foodir', 'foo')

php - WP Subtitle - Formatting -

Image
not sure if right place ask, i’ve had no luck elsewhere , have managed find answers stuff before, looking @ other people’s questions , answers on site. i’ve installed wordpress plug-in (wp subtitle) allows me assign subtitle posts , pages. got couple of problems though: the following line displays title of blog posts links in sidebar: <a href="<?php the_permalink(); ?>"><?php get_the_title() ? the_title() : the_id(); ?> </a> i’ve amended subtitle displayed well: <a href="<?php the_permalink(); ?>"><?php get_the_title() ? the_title()+the_subtitle('<span class="subtitle">', '</span class="subtitle">') : the_id(); ?></a> the links themselves, work fine – if mouse hovers on title, title highlighted, whereas if mouse hovers on subtitle, both title , subtitle highlighted (which want). know how can achieve please? title , subtitle highlighted regardless o...

javascript - How to chain playing of several HTML5 audio files like a smooth playlist? -

given access valid audio files : <audio src="https://upload.wikimedia.org/wikipedia/commons/9/9b/zh-tianjin.ogg"></audio> <audio src="https://upload.wikimedia.org/wikipedia/commons/8/8a/zh-beijing.ogg"></audio> <audio src="https://upload.wikimedia.org/wikipedia/commons/7/73/zh-shanghai.ogg"></audio> <audio src="https://upload.wikimedia.org/wikipedia/commons/e/e2/zh-chengdu.ogg"></audio> given button : <button id="play">play me!</button> given play 1 audio $('#play').on('click', function () { $("audio")[0].play(); }); how chain playing of these several audio, 1 after other ? -- pure js , jquery, other js libs acceptable. my starting point this fiddle basic tools edit: tried big hand of ways without success, using .duration , window.settimeout(function(){do_that}, time_ms) , .delay() in few combinations without success. see: ...

javascript - add cursor: pointer to audio element -

got quick one: how add cursor style <audio> controls? when add them via css cursor displays around controls , not on controls themselves. here's code: <audio class="_audio" src="http://www.somewebsite.co/assets/audiosample-jobs.mp3" controls="controls" autoplay="autoplay" preload="auto"></audio> of note: element created onclick via javascript, shouldn't come play... i'm sorry say, can't style html media controls. can make own controls. if you're interested here's link: http://www.adobe.com/devnet/html5/articles/html5-multimedia-pt3.html

update database android: Error parsing data org.json.JSONException: End of input at character 0 of -

im trying make user can change password after login. got error here. database dont want change after input new password. here code details. change password class: public class password extends activity { progressdialog pdialog; jsonarray jsona = new jsonarray(); jsonparser jsonparser = new jsonparser(); edittext password,enpassword,cpassword; button simpan; string spassword,success,id; static string email,npassword; textview tnama; sessionmanager session; private static string url = "http://10.0.2.2/login/editpass.php"; private static string url1 = "http://10.0.2.2/login/detail.php"; private static final string tag_id = "id"; //private static string url1 ="http://10.0.2.2/login/login.php"; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_edit_pass); session = new sessionmanager(getapplicationcontext()); toast.maketext(getapplicationcontex...

How to get values of multiple select in contact form magento? -

i have code on form.phtml, custom multiple select. <select name="projecttype[]" multiple="multiple"> <option value="" selected>select...</option> <option value="kitchen remodeling">kitchen</option> <option value="refacing">reface</option> <option value="counter tops">counters</option> <option value="bathroom remodeling">bathrooms</option> <option value="flooring">floors</option> <option value="lighting">lights</option> <option value="other">others</option> </select> now problem is, how values if lets select "floors , lights" in contact form. because in normal select option, have project type: {{var data.projecttype}} in custom form email template. 1 multiple select. first time encounter problem can't find sou...