Posts

Showing posts from April, 2014

smtp - How to use X-MC-MergeVars for handlebars -

i new mandrill , trying setup mail using handlebars , smtp. template looks - <span> {{username}}, </span> welcome ...... this mailer.js looks (running on node.js) var mailer = require("mailer") , username = "**@***.com" , password = "*********"; mailer.send( {host: "smtp.mandrillapp.com", port: 25, to: "**@gmail.com", from: "**@gmail.com", subject: "mail using mandrill!", authentication: "login", username: "**@**.com", password: "********", headers: { "x-mc-track": "clicks", "x-mc-autotext": true, "x-mc-template": "newsfeed", "x-mc-mergevars": {"username": "pranav"}, "x-mc-mergelanguage": "handlebars" } }, function(err, result){ if(err){

OOP concept by destructors? -

which object oriented programming concept displayed destructors? example, overloading shows polymorphism. please explain reason answer. not find anywhere on web.. most of key oop concepts shown destructors. if consider concepts including inheritance , object , class , encapsulation , method , message passing , polymorphism , abstraction , composition , delegation , open recursion . can show of them being @ play in destructors generally. now, "destructor" means method defined in class automatically invoked when object destroyed*. covers method , object , class . destructors encapsulate clean-up logic. consider structure can point structure: struct somestruct { somestruct* next; } if above written in language didn't support object-oriented design letting define method on somestruct itself, , deletes heap objects global delete() method, clean all memory used somestruct we'd need like: cleanupsomestruct(somestruct* todelete) { while(todele

java - Is it possible to implement cosmetic rules like indentation and spacing in PMD using XPath? -

i did detailed search on every link found through google or youtube every able examples implementing logical or programming rules instead of how implement our own indentation rules. please me out through this. pmd used find design flaws in code. not possible write cosmetic rules pmd check formatting of code. checkstyle looking for. built keep formatting of code consistent. there eclipse checkstyle plugin runs checkstyle in background , marks formatting issues directly in editor.

c# - Chrome instead of firefox, element not found -

i'm starting use selenium , have problems. here code (c#): namespace selenium1 { [testclass] public class unittest1 { firefoxdriver firefox; [testmethod] public void testmethod1() { firefox = new firefoxdriver(); firefox.navigate().gotourl("https://www.google.com"); firefox.findelement(by.id("gbqfq")).sendkeys("google"); firefox.findelement(by.id("gbqfq")).sendkeys(keys.enter); } [testcleanup] public void teardown() { firefox.quit(); } } } but instead of opening firefox opening chrome , invoking error: test method selenium1.unittest1.testmethod1 threw exception: openqa.selenium.nosuchelementexception: unable locate element: {"method":"id","selector":"gbqfq"} where mistake? thx. have here: how run selenium tests in multiple browsers cross-browser testing using java? and here http://www.widecodes.com

xmpp - Cannot connect to local openfire server from C# -

Image
i've setup openfire server in vm, , accessible internet(i've done port-forwarding point ip of vm). i can chat using spark openfire working perfectly. now trying connect c# app server , getting error. code : private void button1_click(object sender, system.eventargs e) { try { using (var client = new xmppclient("192.168.0.109", "pbc92", "12345")) { try { client.connect(); client.statuschanged += client_statuschanged; } catch (exception ex) { messagebox.show(ex.tostring()); } } } catch (exception ex) { messagebox.show(ex.tostring()); } } private void client_statuschanged(object sender, s22.xmpp.im.statuseventargs e) { messagebox.show(e.jid.tostring()); } the error :

c# - Translate DataGridComboBoxColumn on the fly -

i have got datagridcomboboxcolumn need translate wpflocalizationextension . i have got static method in view model, provides available values: public static list<profilesegmenttype> availablesegmenttypes { { var availablesegmenttypes = new list<profilesegmenttype> { new profilesegmenttype { value = profilesegmenttypeenum.arc }, new profilesegmenttype { value = profilesegmenttypeenum.line }, }; return availablesegmenttypes; } } the profilesegmenttype looks this: public class profilesegmenttype { public profilesegmenttypeenum value { get; set; } public string label { { return resources.localization.adummyvalue; } } } my data grid column definition looks this: <datagridcomboboxcolumn header="..." itemssource="{binding source={x:static viewmodels:profilegeometryviewmodel.availablesegmenttypes}}" selectedvaluebinding="{binding segmenttype, m

android - Keep listview item selected even if view changes -

i have listview in fragment. when select listview item, gets highlighted , open fragment. now, want is, when move previous fragment, list item should stay selected. how can that? i have implemented like add 2 methods in adapter private int selectedindex = listview.no_id; public int getselectedindex() { return selectedindex; } public void setselectedindex(int index) { this.selectedindex = index; // re-draw list informing view of changes notifydatasetchanged(); } and in adapter getview(...) // highlight selected item in list if (selectedindex != -1 && selectedindex == position) { yourview.setbackgroundresource(r.color.lightred); } and implement in fragment in setonitemclicklistener onitemclick(...) like adapter.setselectedindex(position); save selected value in preferences , when come again call in fragment on resume(...) adapter.setselectedindex(selectedindex);

Boolean column(Check box) cell in Infragistics UltraGrid should be disabled based on a condition in InitializeRow event -

in infragistics ultra grid have disable boolean (check box) cell based on condition in initialize row event ps: don't want entire column disabled. cell should disabled (cell contains check box should disabled). i kept code below e.row.activation = activation.noedit this code disabling cells in ultra grid row. boolean checkbox present in cell not getting disabled. try like: private void ultragrid1_initializerow(object sender, infragistics.win.ultrawingrid.initializeroweventargs e) { // deactivate boolean in cell 0 //ultragrid1.displaylayout.bands[0].columns[0].cellactivation = // infragistics.win.ultrawingrid.activation.disabled; e.row.cells[0].activation = infragistics.win.ultrawingrid.activation.disabled; } other choices available beside disabled are: activateonly , allowedit , , noedit you can come , activate it.

python - Inserting data in a Dictionary with raw_input dynamically? -

i writing code school project user enters data student along numbers 3 subject , if needed can update them later. have 2 questions. 1) how insert key value pair dictionary when inputs in 1 line of console? ex:- >>>enter data? >>>alex 45 26 35 here key 'alex' , values 45 26 35 expected output {'alex': '45 62 35'} 2) perform update single command line statement? with syntax >>>'action' 'data' ex:- >>>update alex 45 47 41 the main problem facing here how split statement in action , data program can identify them individually , further data key value pair? if want split string @ first space, can use string.split(s, maxsplit=n) s string split , maxsplit=n number of splits stop at. if not give value s call function string.split(maxsplit=n) split whitespaces. example - >>> s = "alex 45 26 35" >>> s.split(maxsplit=1) ['alex',

web - How to fetch multiple column from mysql using go lang -

i trying fetch multiple columns in mysql database using go language. modify script, , work fetching 1 column, , printing using http print function. however, when fetches 2 things script no longer works. don't have idea need fix it. know sql fine have tested out in mysql terminal, , has given me expected result wanted. conn, err := sql.open("mysql", "user:password@tcp(localhost:3306)/database") statement, err := conn.prepare("select first,second table") rows, err := statement.query() rows.next() { var first string rows.scan(&first) var second string rows.scan(&second) fmt.fprintf(w, "title of first :"+first+"the second is"+second) } conn.close() you using wrong variable names assume that's "typo" in sample code. then correct syntax is: var first, second string rows.scan(&first, &second) see this on scan(dest ...interface{}) mean

java - Split a string into two based on some special characters in android -

i have string this: [{\"id\":2,\"text\":\"capital good\"},{\"id\":3,\"text\":\"general office items\"},{\"id\":1,\"text\":\"raw material purchase\"}]&@[{\"id\":2,\"text\":\"capital good\"},{\"id\":3,\"text\":\"general office items\"},{\"id\":1,\"text\":\"raw material purchase\"},{\"id\":0,\"text\":\"approved\"},{\"id\":1,\"text\":\"freezed\"},{\"id\":2,\"text\":\"cancelled\"},{\"id\":3,\"text\":\"completed\"},{\"id\":4,\"text\":\"foreclosed\"},{\"id\":5,\"text\":\"unapproved\"}] i want split string 2 based on &@ character combination this: string [] separated=line.split("&@"); but when checked valu

jquery - How to make canvas cursor image dynamic using css or javascript -

i’m building canvas drawing app, can select different colors color tool, how can make canvas cursor image dynamic filled selected color? in advance, following code make cursor image, static cursor image, wanted make dynamic filled selected color color tool. .circle64 { cursor: url('http://www.iconsdownload.net/icons/64/16574-black-circle.png'), pointer; }

android - Trouble in adding a search widget in actionbar -

i add search function in action bar following this guide still got these errors. 07-02 13:36:05.175 21813-21813/com.example.fieldbookv2 e/androidruntime﹕ fatal exception: main process: com.example.fieldbookv2, pid: 21813 java.lang.nullpointerexception: attempt invoke virtual method 'void android.widget.searchview.setsearchableinfo(android.app.searchableinfo)' on null object reference @ com.example.fieldbookv2.loginactivity.oncreateoptionsmenu(loginactivity.java:1621) @ android.app.activity.oncreatepanelmenu(activity.java:2823) @ android.support.v4.app.fragmentactivity.oncreatepanelmenu(fragmentactivity.java:277) @ android.support.v7.internal.view.windowcallbackwrapper.oncreatepanelmenu(windowcallbackwrapper.java:84) @ android.support.v7.app.appcompatdelegateimplbase$appcompatwindowcallbackbase.oncreatepanelmenu(appcompatdelegateimplbase.java:273) @ android.support.v7.app.appcompatdelegat

html - How to check class name exist in child div; of parent div using jquery? -

how check whether div class within div class exist or not? in following example; want check whether "showonload" div class exist inside; parent div class "hideunhidepanel"? <div id="lodadiv" hidden="true" class="hideunhidepanel"> <div class="showonload"> </div> <div class="showonload"> </div> <div class="showonload"> </div> </div> <div id="load2div" hidden="true" class="hideunhidepanel"> //nothing exist </div> jquery code: $('.hideunhidepanel').each(function() { alert('yo'); if($(this).children('showonload')) alert('child exist'); }); fiddle: https://jsfiddle.net/5h49x7qe/ update : note -> in fiddle, displaying alert thrice; in actual should show 2 times only; third showhidepanel not have "showonload" class. .children() return jquery

spring mvc - How to pass multiple form parameter in "th:action" using themleaf -

i trying pass parameter in th:action <form class="form-inline" th:object="${search}" method="get" action="search.html" th:action="@{'/hotels/'+${search.location}+'/'+${search.adults}+'/'+${search.datecheckout}+'/'+${search.datecheckin}}" id="search-hotel-form"> <select class="selectpicker form-control input-lt" th:field="*{location}" id="city"> <option value="delhi">delhi</option> </select> <input type='text' th:field="*{datecheckin}" id="datetimepicker1" /> <input type='text' th:field="*{datecheckout}" id="datetimepicker2" /> </form> then spring mvc contoller part @requestmapping(value = "/hotelsparam/{datecheckin}/{datecheckout}/{location}", method = requestmethod.post) public modelandview searchhotel(@

java - Illegal access error when initializing SparkConf - MLLIB -

team, i'm playing around spark , mllib. installed scala , spark, versions mentioned below. scala - 2.11.7 spark - 1.4.0 (did mvn package -dscala-2.11) i'm trying run java classification, clustering examples came along documentation. however, i'm getting illegal access error when i'm trying initialize sparkconf object. i'm trying basic : > sparkconf conf = new sparkconf().setappname("svm classifier example"); > sparkcontext sc = new sparkcontext(conf); please find error trace below : exception in thread "main" java.lang.illegalaccesserror: tried access method scala.collection.mutable.hashset.()v class org.apache.spark.util.utils$ @ org.apache.spark.util.utils$.(utils.scala:195) @ org.apache.spark.util.utils$.(utils.scala) @ org.apache.spark.sparkconf.(sparkconf.scala:58) @ multinomiallogisticregressionexample.main(multinomiallogisticregressionexample.java:15) how go this? did googling , couldn'

Has Sitecore 8 built-in support for MVC areas? -

is sitecore 8 has built-in support mvc areas? or still need install sitecore plugins? thanks quoting kevin brechbühl (from the sitecore mvc puzzle ): sitecore has no support areas out of box, there multiple solutions available integrate them in solutions: resolve area in mvc.renderrendering-pipeline use custom controllerrunner , custom renderer resolve area configurations we saw sitecore working on solution integrate areas core. rumor has integrate similar pattern brainjocks mvc.renderrendering pipeline.

Deliberate timing delay in netlogo? -

dear netlogo community, i want put timer constraint in simulation agents make decision. know can implement using ticks in simulation agents should make decision in tick , avoid deadlock want introduce time constraint agent make decision. if agent not make decision in specified time control of resource should go other agent. appreciated. thanks if don't have constraint related tick limit make procedure counts number of ticks since main turtle procedure started, like... edited code: procedure turtle-decision-making set time_passed 0 while time_passed < time_limit decision-taking-part << if decision taken break while loop else set time_passed (ticks_passed + 1) ;; tick might procedure outermost loop, might not. end while end turtle-decision-making

javascript - How to break SweetJS hygiene for local variable? -

i attempting use sweetjs in project. in order better understand , learn sweetjs thought start simple "class" macro (i know few exist, playing around here...). can not seem sweetjs stop messing local variables "self" , "supercall" however. ideas doing wrong? var self=this remain var self=this instead of being mangled. macro class { case { _ $name extends $parent { constructor $cargs { $cbody ... } $($mname $margs { $mbody ... } ) ... } } => { return #{ function $name $cargs { var self=this,supercall=$parent.prototype; $cbody ... } $name.prototype = object.create($parent.prototype); ($name.prototype.$mname = function $margs {var self=this,supercall=$parent.prototype; $mbody ... } ) ...; } } case { _ $name { $body ...} } => { return #{ class $name extends test2 { $body ... } }; } } macro super { case { $macroname.$name( $($args (,) ...) ) } => { letstx $s = [makeident("s

emacs - org-bibtex-yank fails with Wrong type argument: stringp, nil -

org 8.2.10 emacs 24.4.1 i have bibtex entry in scratch buffer, m-w entry. it's in kill-ring i swap org-mode buffer , try m org-bibtex-yank i receive error: wrong type argument: stringp, nil i've toggled-debug-on-error , backtrace below. have checked entry on kill-ring - can yank scratch buffer. i've set debug-on-entry org-bibtex-yank, , went long way down rabbit hole! can see entry in steps of debugger, got lost! i'd grateful pointers on either problem, or getting more information might help. thanks debugger entered--lisp error: (wrong-type-argument stringp nil) looking-at(nil) bibtex-parse-entry() org-bibtex-read() org-bibtex-yank() call-interactively(org-bibtex-yank record nil) command-execute(org-bibtex-yank record) execute-extended-command(nil "org-bibtex-yank") smex-read-and-run(("toggle-debug-on-error" "org-bibtex-yank" "debug-on-entry" "describe-function" "apropos" "set-varia

Maximum pool size error in C# using MySQL -

do have suggestion on how manage application run properly? updates rows (203 rows can more) in table of database. , need run day. after hour of running, prompts error: mysqlexception: error connecting: time out expired. timeout period elapsed prior , max pool size reached obtaining connection pool. may have occurred because pooled connection in use. i close connection using conn.close() . i'm not sure if increasing pool size best solution since run day , possibly may reach pool size set. here's code: public static class globals { //global variable public static string update; public static string update2; public const string connectionstring = "server=localhost; uid=root; pwd=; database=it_map;"; public static int totalruntime = 0; } static void main(string[] args) { while (true) { stopwatch stopwatch = new stopwatch(); stopwatch.start(); thread t = new thread(new threadstart(pinglaptop)); t

html - First Bootstrap project, how do I make container widths equal? -

student here working on 1 of final projects. first time using bootstrap. having difficulty making content match same width navigation. can see project live here see talking about. i built grid first , attempted create own styles in file called style.css . what have tried create class so: .container .no-padding-lr { padding-left: 0px; padding-right: 0px; margin-left: 0px; margin-right: 0px; } and apply markup: <div class="col-sm-12 no-padding-lr"> <h1 class="intro">your online canadian-built pontiac, acadian, , beaumont resource.</h1> <img class="img-responsive img-rounded no-padding-lr" src="assets/images/dscn8314.jpg" alt="pontiac header" /> </div> as can see widening maybe 50% of required. how can adjust content in line 1 another? you need wrap col- - divs <div class="row"> . quoting relevant bootstrap docs : rows must placed wit

css - Wufoo form is not loading custom stylesheet -

i have wufoo form trying customize css. css form being uploaded far can tell, far haven't been able change anything. tips? the thing i've tried change header color so: .wufoo .info h2 { color:blue; } here necessary links: stylesheet - http://crimsonroot.com/files/php/custom.css form - https://thedrawshop.wufoo.com/forms/r60xxmf0kwbb7j/ the issue far can tell trying link stylesheet, not on secure connection. it's http form secured https . many browsers default prevent loading of "mixed content" need them both on same connection style before begin load. hope helps. also try this, tested , works. http://thedrawshop.wufoo.com/forms/r60xxmf0kwbb7j/

ios - How can I get the layout to stay the same, but increase/decrease size based on device? -

i have been making first ios app, calculator, , having hard time making fit devices. here looks on iphone 5s: http://imgur.com/mgavo2e when go iphone 6, ends looking this: http://imgur.com/guxm0xw is there way keep same layout iphone 5s , have increase in size? im using xcode 7 beta 2 you have few options: use auto layout. meant guide how elements react each other depending on screen size. recommended when using storyboards. it's not i'm great with, there resources help. check wwdc videos, or read docs here: https://developer.apple.com/library/ios/documentation/userexperience/conceptual/autolayoutpg/introduction/introduction.html the second manage layout of elements on own. have perform calculations placed, , how large are. example, black bar start @ top left corner, have width matches self.view's width, , height 20% height of device. might produce strange results there mistakes in calculations on each item placed, or run in screen size don't expe

Is there a standard Linux library for "lock files"? -

suppose have folder , want 1 instance of application working on @ time. can synchronize via filesystem itself. times accomplished .lock_file if that's present know instance using it. there standard libraries handle sort of thing? if using c/c++, see fclnt or flock : locking files in linux c/c++ if using java, see filechannel lock method , how can lock file using java (if possible) you can check existence of .lock_file opening open(pathname, o_creat | o_excl, 0644) , see open man page , creates , opens file , returns eexist if pathname exists. in java, calling file method createnewfile() can use create atomically .lock_file

html - Passing an instance attribute and association method as parameters in a ruby method -

i've written rails helper part of creating data-attributes options within select box. helper def list_attributed_options(instance_vars, attr, assoc_method) instance_vars.map { |instance_var| [instance_var.attr, instance_var.id, { :"data-#{assoc_method}" => instance_var.assoc_method.downcase.gsub(/\s+/, "-")}] } end view code <%= f.input :game_id, as: :select, collection: list_attributed_options(@games, "title", "console"), include_blank: "select game" %> instance_vars represents instance variables used collection ( @games ), attr represents 1 of instance variables' attributes , assoc_method model belongs to. instance_var.title = "halo" instance_var.id = 21 instance_var.console = "xbox one" so example in particular case want name options game's title, name data attribute after console belonging game: <select> <option data-console="xbox-one">halo<

busybox - vagrant ash: sudo: not found -

when starting vagrant box small 15mb busybox image, first time error during phase mounting shared folders... it seems vagrant trying sudo, isn't istalled. error: the following ssh command responded non-zero exit status. vagrant assumes means command failed! mkdir -p /vagrant stdout command: stderr command: ash: sudo: not found it works far, can login root password vagrant, guess not perfect? this setup: https://github.com/rubo77/ffnord-example/blob/pyddhcpd/vagrantfile config.ssh.username = 'root' config.ssh.password = 'vagrant' config.ssh.insert_key = 'true' config.ssh.shell = 'ash' (0..9).each |i| config.vm.define "gc-node0#{i}" |node| end end by default vagrant share/sync directory /vagrant (guest) current project directory, 1 containing vagrantfile (host), more directories can shared using config.vm.synced_folder , don't know if default /vagrant can disabled. if aren

javascript - How to optimize JS code? -

chrome profiling say: "not optimized: assignment parameter in arguments object". can optimize code? this.buffer.foreach(function(tilepos, ypos) { tilepos.foreach(function(tileinfo, xpos) { _self.tiles.puttile('ground', xpos, ypos, _self.ground); }); }); it not acting on tilepos within block. i recommend doing follows if wish eliminate error, bit of performance boost: for(var = 0; < this.buffer.length; i++) { for(var j = 0; j < this.buffer[i].length; j++) { _self.tiles.puttile('ground', i, j, _self.ground); } }

Format JSON string in R -

i have string below response api (i have omitted of it): "{\"results\":{\"output1\":{\"type\":\"table\",\"value\":{\"columnnames\":[\"x\",\"y\",\"month\",\"day\",\"ffmc\",\"dmc\",\"dc\",\"isi\",\"temp\",\"rh\",\"wind\",\"rain\",\"area\",\"classes\",\"probabilities\"],\"columntypes\":[\"int32\",\"int32\",\"string\",\"string\",\"double\",\"double\",\"double\",\"double\",\"double\",\"int32\",\"double\",\"double\",\"double\",\"string\",\"double\"],\"values\":[[\"7\",\"5\",\"mar\",\"fri\",\"86.2\",\"26.2\",\"94.3\",\"5.1\",\&quo

graphics - Scaling textures in libgdx on resizing -

Image
i set texture resize gdx.graphics.getwidth() , gdx.graphics.getheight() every time render function calls. in fact when launch app, texture sets full screen (as want). when change size of app, texture draws in dumb way, while want full screen time. here code: package com.leopikinc.bobdestroyer; import com.badlogic.gdx.applicationadapter; import com.badlogic.gdx.gdx; import com.badlogic.gdx.audio.music; import com.badlogic.gdx.graphics.gl20; import com.badlogic.gdx.graphics.texture; import com.badlogic.gdx.graphics.g2d.spritebatch; public class bobdestroyer extends applicationadapter { spritebatch batch; texture mainscreen; music intromusic; float volume; @override public void create () { volume = 1f; batch = new spritebatch(); mainscreen = new texture(gdx.files.internal("data/firstlevel.png")); intromusic = gdx.audio.newmusic(gdx.files.internal("data/intromusic.mp3")); intromusic.setloop

r - shiny radio buttons broken -

radio buttons broken me in shiny-0.12.1/mime-0.3. following code works older version shiny-0.11.1/mime-0.2 not newer version (input$dist , input$n return empty strings). example below based on http://shiny.rstudio.com/articles/html-ui.html select menu modified radio buttons. index.html <html> <head> <script src="shared/jquery.js" type="text/javascript"></script> <script src="shared/shiny.js" type="text/javascript"></script> <link rel="stylesheet" type="text/css" href="shared/shiny.css"/> </head> <body> <h1>html ui</h1> <p> <label>distribution type:</label><br /> <input type="radio" name="dist" value="norm" checked="checked" />normal<br> <input type="radio" name="dist" value="unif" />uniform<br> <input type

hive - Weird behaviour with spark-submit -

i running following code in pyspark : in [14]: conf = sparkconf() in [15]: conf.getall() [(u'spark.eventlog.enabled', u'true'), (u'spark.eventlog.dir', u'hdfs://ip-10-0-0-220.ec2.internal:8020/user/spark/applicationhistory'), (u'spark.master', u'local[*]'), (u'spark.yarn.historyserver.address', u'http://ip-10-0-0-220.ec2.internal:18088'), (u'spark.executor.extralibrarypath', u'/opt/cloudera/parcels/cdh-5.3.3-1.cdh5.3.3.p0.5/lib/hadoop/lib/native'), (u'spark.app.name', u'pyspark-shell'), (u'spark.driver.extralibrarypath', u'/opt/cloudera/parcels/cdh-5.3.3-1.cdh5.3.3.p0.5/lib/hadoop/lib/native')] in [16]: sc <pyspark.context.sparkcontext @ 0x7fab9dd8a750> in [17]: sc.version u'1.4.0' in [19]: sqlcontext <pyspark.sql.context.hivecontext @ 0x7fab9de785d0> in [20]: access = sqlcontext.read.json("hdfs://10.0.0.220/raw/logs/arqui