Posts

Showing posts from April, 2011

Parse XML file to fetch required data and store it in mongodb database in Python -

i have xml file looks this: xml file i want fetch following information file events: under category event: start_date end_date title under category venue: address address_2/ city latitude longitude name postal_code and store information in mongodb database. don't have experience in parsing. can please me this! ! from pymongo import mongoclient import xml.etree.elementtree et urllib2 import urlopen cl = mongoclient() coll = cl["dbname"]["collectionname"] tree = et.parse("https://www.eventbrite.com/xml/event_search?app_key=uso53e2zht6lm4d5ra&country=de&max=100&date=future&page=1") root = tree.getroot() event in root.findall("./event"): doc = {} c in event.getchildren(): if c.tag in ("start_date", "end_date", "title"): doc[c.tag] = c.text elif c.tag == "venue": doc[c.tag] = {} v in c.getchi

javascript - jQuery append element and replace selected row -

Image
how change elements of selected row? when combo box changed, want check value of combo. if value of " gender " chosen, replace element " input value ke-3 " textbox value : <select id="data3" name="data3[]"> <option value="man" selected >man</option> <option value="woman">woman</option> </select> whether can done using $.(selector).html() ? my code : $(document).ready(function() { mylogic(); }); function mylogic(){ $(".addcf").click(function(){ $("#customfields").append( '<tr>' + '<td>' + '<select class="tabelbaru" id="data1" name="data1[]">' + '<option value="email" selected >email</option>' + '<option value="gender">ge

bash - Generate multiline file with Make -

i want create multiline file make, having exact content: #!/bin/bash if [ "$java_home" = "" ]; echo "please set java_home"; exit 1; fi export config_vars=$( cat <<eof -dmapred.job.tracker=$jt eof ) ${hadoop_home}/bin/hadoop $1 $hadoop_config_vars ${*:2} 2>&1 | grep -v slf4j how can tell make output file exact content somewhere? i tried this: define script_content #!/bin/bash if [ "$java_home" = "" ]; echo "please set java_home"; exit 1; fi export config_vars=$( cat <<eof -dmapred.job.tracker=$jt eof ) ${hadoop_home}/bin/hadoop $1 $hadoop_config_vars ${*:2} 2>&1 | grep -v slf4j endef export script_content bin/script: @echo "$$script_content" > bin/script this paricular solution 1) wipes $ , first char after $-es , 2) ugly because definition should happen outside of particular target it's needed :( i tried this: bin/script: @echo ' #!/bin/bash

objective c - What is the correct way to setup a Model for IOS? -

i creating app , using parse.com data storage. i use model different aspects of parse use. example, if store game data model handle doing finds/updates/entries game model held on parse. so model handle these methods, instead of adding these view controllers. what best/correct way set these up? have heard of singletons not sure if correct here. at present, set these using subclass of nsobject. create methods class methods (no instance methods there no instance create). call class method usual. [gamemodel classmethodname]; would correct? there better approach or issues approach? at present, set these using subclass of nsobject. create methods class methods (no instance methods there no instance create). call class method usual. this doesn't sound plan. job of model manage data application operates on. means model should have data store, means should instantiating model. building support end infrastructure (parse, in case) idea. it's better put

How to control when image data is loaded into memory in Windows Store Apps? -

Image
when creating image in windows store app, how control when data read disk? in wpf, control when image read disk using bitmapcacheoptions . bitmapcacheoptions.ondemand postpone reading data disk until image data needed. there few downsides this: io costs appeared ui delays; if stream used image source, stream not closed; if file used image source, file locked. to address problem use bitmapcacheoptions.onload read image memory immediately. how control when image data loaded memory in windows store apps? wpf code this: var bitmapimage = new bitmapimage(); bitmapimage.begininit(); bitmapimage.cacheoption = bitmapcacheoption.onload; bitmapimage.urisource = path; bitmapimage.endinit(); bitmapimage.freeze(); edit - more info wpa shows getting 8.8mb image onto screen costs ~330ms. of that, 170ms spent on file io (including 37ms antivirus check file), , 160ms spent on wic decoding. any ideas how control when file io happens or how trigger wic decoding? (right click

java - jsp request.getParameter -

edited, still not working exactly, need set page_type on each page of website. page_type needs checked java , code based on page_type. problem is, if else statements not being done correctly. nothing happens because parameter doesn't seem placed. main page page_type being set: <div id="dyk_area"> <jsp:include page="/imgs/random_dyk.jsp" flush="true"> <jsp:param name="page_type" value="prenataloverviewarea"></jsp:param> </jsp:include> </div> where code being checked <% string pagetype = request.getparameter("page_type")==null?"": request.getparameter("page_type"); string image_name=""; if(pagetype.equals("prenataloverviewarea")){ int random = (int )(math.random() * 10 + 1); image_name= "/images/did_you_know/dyk_p_" + random + ".png"; } else if(pagetype.equals("prenatalnorm&qu

qt - C++ type's destructor not called in QML -

i create sailfish app (using latest sailfish sdk). have problem exposing c++ object qml. inherits qsettings, class settings : public qsettings { q_object /**/ public: explicit settings() : qsettings("marcin mielniczuk", "bigtext") {} ~settings() { qdebug() << "dying"; } /**/ }; i noticed destructor isn't called @ all. (there's not destructor output) i create object that: import qtquick 2.0 import sailfish.silica 1.0 import bigtext 1.0 import "pages" applicationwindow { initialpage: mainpage { } settings {id: settings} } my main.cpp is: q_decl_export int main(int argc, char *argv[]) { qscopedpointer<qguiapplication> app(sailfish::createapplication(argc, argv)); qmlregistertype<settings>("bigtext", 1, 0, "settings"); qscopedpointer<qquickview> view(sailfish::createview("main.qml")); sailfish::showview(view.data()); ret

ios - Presented UINavigationController tint color not changing -

myvc *vc = [[myvc alloc] init]; vc.delegate = self; uinavigationcontroller *nc = [[uinavigationcontroller alloc] initwithrootviewcontroller:vc]; [nc.navigationbar settintcolor:[uicolor redcolor]]; [self presentviewcontroller:nc animated:true completion:^{}]; the navigation bar black. present navigation controller inside tab bar controller created in app delegate. in applicationdidfinishlaunchingwithoptions, can control color of navigation controllers there. why navigation controller tint bar black? [[uinavigationbar appearance] settintcolor:[uicolor redcolor]]; i suggest use if of navigationbars same color. appearance property of object sets uniformity on function apply on it.

tail - go to line in logfile with multitail -

using mulitail , want find specific line in logs, press / key , type string want search for. multitail pops box lines found in logs, want 'go to' location in log file, can see happened before or after specific line. is possible? alternatively, possible specify number n return +/- n lines above , below found string rather 1 line string found?

eclipse - Tomcat Not Starting after adding postgresql jar -

i using apache tomcat server eclipse. when added postgresql jar tomcat, fails start , ends on timeout message: "server tomcat v7.0 server @ localhost unable start within 45 seconds. if server requires more time, try increasing timeout in server editor". console output shown below: sep 04, 2013 12:39:50 org.apache.catalina.core.aprlifecyclelistener init info: apr based apache tomcat native library allows optimal performance in production environments not found on java.library.path: c:\program files (x86)\java\jre7\bin;c:\windows\sun\java\bin;c:\windows\system32;c:\windows;c:/program files (x86)/java/jre7/bin/client;c:/program files (x86)/java/jre7/bin;c:/program files (x86)/java/jre7/lib/i386;c:\program files\miktex 2.9\miktex\bin;c:\program files (x86)\miktex 2.9\miktex\bin;c:\program files (x86)\pc connectivity solution\;c:\windows\system32;c:\windows;c:\windows\system32\wbem;c:\windows\system32\windowspowershell\v1.0\;c:\program files (x86)\quicktime\qtsystem\;c:\

delphi - break condition to OR and AND operators in an IF Statement -

the if statement , other boolean comparison smart enought stop @ first false value when evaluating a , b , c , d , @ first true value when evaluating a or b or c or d . what name of behavior? compiler optimization? if so, there way disable compiler directive? this called 'boolean short-circuit evaluation', form of 'lazy evaluation'. you can tell compiler either use or not use feature using compiler directives : complete evaluation lazy evaluation {$b+} {$b-} {$booleval on} {$booleval off} but notice isn't only optimisation, since feature allows write code like if (length(myarr) > 0) , (myarr[0] = my_val) which work if myarr[0] doesn't exist. rather common, actually.

c++ - Sending "string" and "int" var using send() method in socket -

in below code want send hit->first , *vit via socket: for (std::map < int, std::vector < std::string > >::iterator hit = three_highest.begin(); hit != three_highest.end(); ++hit) { //std::cout << hit->first << ":"; (std::vector < std::string >::iterator vit = (*hit).second.begin(); vit != (*hit).second.end(); vit++) { std::cout << hit->first << ":"; std::cout << *vit << "\n"; results: 2:one 3:ff 3:rr 6:fg i.e. occurrence:word i want send using send() method in socket. if both have been int or char can store 2 dimentional array , send array. here not case. can 1 figure out way sent using single send() in socket? you can pack message string via stringstream , , send message (prefixed string length). other end read string length, read many bytes string. string fed stringstream extract data. in pseudo-ish code, sending like: std::ostringst

javascript - How do I validate my Radio Buttons -

i've started programming , i'm @ basic level, i've created form student website , i'm trying validate radio buttons. know can select "checked" in html code tutor stipulates has within javascript code. have researched on here examples many of have shown haven't worked me (my fault!) , crashes previous validations. any guidance ninjas appreciated. here small sample of code work me have deleted radio button validation in frustration, want know how adapt code: <script> function validate(){ firstname = document.getelementbyid("txtfirst").value; errors = ""; if (firstname == ""){ errors += "please supply valid first name \n"; } else if (!firstname.match(/^[a-za-z-\s]*$/)){ errors += "please use letters in first name \n"; } } </script> <body> <form method="post" action="" class="booking"> <fieldset> &l

jQM - Javascript doesn't work in 'file.html' when use $.mobile.changePage -

i'm trying make transition between 2 .html files using jqm (just test): index.html: <script> function go(){ var url = "go.html?go='123'"; $.mobile.changepage(url, {transition: "slide"}); } </script> <body> <button onclick='go();'>go!</button> </body> go.html: <script> $( document ).on("#mainpage", "pageinit", function() { // code url vars function geturlvars() { var vars = {}; var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) { vars[key] = value; }); return vars; } var go = geturlvars()['go']; alert(go); }); </script> the transition works fine, , see (in url browser) variable ' go ' there (123). when translation finish, alert doesn't work , have refresh page (f5) see alert (' 123 '): javascript in go.html doesn

how to use json webservice in blackberry cascades -

1.how use json web service in blackberry cascades. 2.i need data url link qml page. give suggession sample if possible. 3.my web service link contains array type for eg: { "address":["area": "chn", "city": "ght"]} 4.description: json link --> 192.168.1.251:410/mobile/service1.svc/english/category?countryid=1 5.by using above link please tell how retrive data json webservice in cascades.. need answer in cascades method.. right. 2 part question. first how make request , receive reply, , second how parse json; luckily, cascades has covered both cases. to make request: qnetworkaccessmanager qnam; qnetworkrequest req("192.168.1.251:410/mobile/service1.svc/english/category?countryid=1"); qnetworkreply *reply = qnam.get(req); connect(reply, signal(finished()), this, slot(onfinished())); then define onfinished slot so: void classname::onfinished() { qnetworkreply *reply = dynamic_cast<qnetwor

jquery - How do I put the proper data from this array into the place I need it to go? -

here's idea, pull color hex codes supplied sql , injected span in these list items , use hex codes set background color of span it's in. able proper information array i'm not sure how should go setting backgroundcolor rule in correct order array. <ul id="color-hr"> <li id="hr-aqua"> <a href="javascript:"><span></span></a> <ul> <li><a href="javascript:"><span>70859a</span> jetstream</a></li> <li><a href="javascript:"><span>4d98b5</span> periwinkle</a></li> <li><a href="javascript:"><span>5ecfcc</span> deep caribean</a></li> <li><a href="javascript:"><span>b6d8d5</span> sky</a></li> </ul> </li>

rest - How to perform authorization in RESTful requests with angularjs? -

i using angularjs make rest requests api requires authorisation. authorisation requires request signed (similar amazon s3) , signature sent in headers. i unsure how securely angularjs. client side credentials need embedded in js code exposes massive security hole. i assume i'm missing obvious here? thoughts appreciated. no, aren't missing anything. think possible solution here write own authorization backend hold credentials , return token application.

sh - How can I split a shell command over multiple lines when using an IF statement? -

how can split command on multiple lines in shell, when command part of if statement? while works: if ! fab --fabfile=.deploy/fabfile.py --forward-agent --disable-known-hosts deploy:$target; rc=1 fi this not working: # not work: if ! fab --fabfile=.deploy/fabfile.py \ --forward-agent \ --disable-known-hosts deploy:$target; rc=1 fi instead of whole command executing, get: ./script.sh: line 73: --forward-agent: command not found more importantly, missing understanding of bash me understand , similar issues in future? the line-continuation fail if have whitespace (spaces or tab characters) after backslash , before newline. no such whitespace, example works fine me: $ cat test.sh if ! fab --fabfile=.deploy/fabfile.py \ --forward-agent \ --disable-known-hosts deploy:$target; echo failed else echo succeeded fi $ alias fab=true; . ./test.sh succeeded $ alias fab=false;

javascript - Parsing jQuery XML object into Highcharts -

i'm new here , javascript beginner please bear me. i'm trying plot highcharts chart based on data in jquery xml object. actual data coming soap request purposes of fiddle pasted text variable now. my jsfiddle example just click button "create html table , plot" , scroll down see chart. an example of xml data follows: <rowset> <row> <column0>0</column0> <column1>101</column1> <column2>us 1 le 1 bu 1</column2> <column3>110</column3> <column4>ceo</column4> <column5>ledger usa pl</column5> <column6>01-12</column6> <column7>2012</column7> <column8>20120101</column8> <column10>240481</column10> </row> <row> <column0>0</column0> <column1>101</column1> <column2>us 1 le 1 bu 1</column2> <column3>121</column3> <co

eclipse - The tag named passThroughAttribute from namespace http://xmlns.jcp.org/jsf/core has a null handler-class defined -

i trying use jsf 2.2.2 on jboss 7.1.1.final followed solution 1 in link: http://www.mastertheboss.com/jsf/installing-jsf-22-on-jboss-as-7 based on replacing current jboss jsf libraries , after changed faces config. when trying run application getting following exception: 22:28:56,076 severe [javax.enterprise.resource.webcontainer.jsf.config] (msc service thread 1-1) critical error during deployment: : com.sun.faces.config.configurationexception: tag named passthroughattribute namespace http://xmlns.jcp.org/jsf/core has null handler-class defined @ com.sun.faces.config.processor.facelettaglibconfigprocessor.processhandlerclass(facelettaglibconfigprocessor.java:422) [jsf-impl-2.2.2.jar:2.2.2] @ com.sun.faces.config.processor.facelettaglibconfigprocessor.processtags(facelettaglibconfigprocessor.java:378) [jsf-impl-2.2.2.jar:2.2.2] @ com.sun.faces.config.processor.facelettaglibconfigprocessor.processtaglibrary(facelettaglibconfigprocessor.java:321) [jsf-impl-2.2.2.jar:2.

javascript - Uncaught InvalidStateError in JSON.stringify -

i've read other thread , no good: put data json jquery whenever try json.stringify object array error saying: uncaught invalidstateerror: attempt made use object not, or no longer, usable. here js: var responseitems = []; var keynotecontainer = $('div.keynote-questions'); var eventquestioncontainer = $('div.event-questions'); var sessioncontainer = $('div.session-questions'); var eventid = $('#evaluation-event-id').val(); keynotecontainer.children().each(function (index, el) { var element = $(el); var id = "-1"; var parentid = element.find('input[type=hidden]').val(); var parenttype = "keynote"; var responsevalue = element.find('.response-item-slider').slider("option", "value"); var responsetext = "";

eclipse - Zend Studio 10: "Composer" contextual menu missing? -

i have installed zend studio 10, installed composer plug-in, created zf2 project , configured composer. however, when right click on project in php explorer, there no contextual menu item composer. of tutorials i've found on how use composer zend studio 10 imply there should be. have seen other questions regarding problem here , on zend forum , point missing in .project file. however, have checked , mine seems complete. suggestions? <nature>org.zend.php.framework.zendframeworknature</nature> <nature>org.eclipse.php.core.phpnature</nature> <nature>org.eclipse.wst.jsdt.core.jsnature</nature> <nature>org.eclipse.wst.common.project.facet.core.nature</natur$ <nature>org.zend.php.zendserver.deployment.core.deploymentnatur$ <nature>com.dubture.composer.core.composernature</nature> i have been playing time , believe zend documentation in need of updates. have managed find of composer functionality in main projec

javascript - Convert [object Object] into DOM element -

i trying implement slideshow in jquery have images , description in hidden element id contain here want of containing elements ( img span ) pairs can iterate them. issue is: var slides = $('#contain').children(); //[object object] console.log(slides); //console.log(slides.get(0)); //< not working this returning [object object] want element in dom elements can select details, iterate them etc. can please how can that? complete code: function startslideshow(interval) { var slides = $('#contain').children(); console.log("0: " + slides); (var = 0; < slides.length; i++) { settimeout( function () { var slide = $(slides[i]).children(); $('#currentimage').attr('src', slide[0].src).fadein(interval * 100); $('#slidedesc').html(slide[1].innerhtml).fadein(interval * 100); }, interval * 1000); } } in html: <article id="contain"> <div class=

java - Read clipboard data with GWT -

this question has answer here: how copy clipboard gwt? 6 answers i have code have made handle ctrl + v browser, works fine need clipboard data this: event.addnativepreviewhandler(new event.nativepreviewhandler() { @override public void onpreviewnativeevent(event.nativepreviewevent event) { nativeevent ne = event.getnativeevent(); // when ctrl + v pressed if (event.getnativeevent().getkeycode() == 86 && // 'v' event.getnativeevent().getctrlkey() == true) { // need clipboard data } } }); although i'm 1 marked question duplicate, think answers in question may bit out of date. when google, find this discussion . answers in there solve problem jsni remark doesn't work in ff because ff requires manually enabling r

c++ - Wrong return value when access member of class -

i have class character , 2 subclasses warrior , wizard. class character { protected: std::string m_name; weapon m_weapon; int m_life; public: virtual void hit(character& cible); }; class warrior : public character{ public: warrior(std::string name); }; class wizard : public character{ public: wizard(std::string name); }; i have class weapon. class weapon { protected: std::string m_name; int m_damage; public: weapon(); weapon(std::string name,int damage, int reloading_time); int get_damage() ; }; the hit function is: void character::hit(character &cible){ cible.dec_life(m_weapon.get_damage()); } and get_damage simply: int weapon::get_damage() { return m_damage; } the problem m_weapon.get_damage() returns value -2 in hit function every character (warrior or wizard) though weapon's damage 10 or 15. main: int main() { string character_name; cout << "warrior 1 : "; cin >> character_name; warrior character_1(character

ruby on rails - Donations over past 24 months with keys and sums -

having pulled donations past 2 years, i'm trying derive sum of donations per month, storing keys (each month) , values (the sum of donations each month) in array of hashes. keys numbers 1 24 (1 being 2 years ago , 24 being month) , if there no donations given month, value 0 month. how array of hashes in ruby/rails? this variable donations in it. donations = gift.where(:date => (date.today - 2.years)..date.today) the following gives hash, keys '2013/09" , etc... monthly_donations = {} date = time.now while date > 2.years.ago range = date.beginning_of_month..date.end_of_month monthly_donations[ "{#date.year}/#{date.month}" ] = giftl.sum(:column, :conditions => {created_at >= range}) date -= 30.days end to select records in time-span, should enough: donations = gift.where("date >= #{2.years.ago}") you can this: donations = gift.where("date >= :start_date , date <= :end_date",

.net - Removing color cast from image -

Image
i have digital camera takes photos 24x7 , depending on weather returns images nasty color cast. blue. i have been trying find source code or library can call c# reduce color cast of images. photoshop has feature works quite on images tested is: open image select image -> adjustments -> match color check neutralize check box this works well, not know doing. i not @ maths looking ideas on existing code or libraries use. i have been searching web not found useful - love help. this looks white balance set indoors (expecting reddish light) getting daylight (blue). gimp has color temperature slider change cast of pictures. talking preventing in future, or batch processing bunch of existing images. simple cameras (but maybe not mobile phones) have controls on white balance, future shots. this looks web cam plugged computer? moving target, meaning wb being re-evaluated each time takes pic, , may not able apply same correction each image. here imagema

c# - RichTextBox - Add text to top with multiple colors (only latest line is showing) -

i'm trying replicate log window, recent log should appear @ top - visible. thus, need add text top (no problem) multiple colors (problem). first store original text. (it's rtf or text - tried both) , add new text, username , message. username should 1 color , message another. it's single lined too. all method when appending old text or old rtf text, latest "log" shows. public void addlog(log log) { try { string oldtext = this.richtextbox1.rtf; this.richtextbox1.text = log.user + ": " + log.message + "\n"; this.richtextbox1.select(0, log.user.length); this.richtextbox1.selectioncolor = color.greenyellow; this.richtextbox1.select(log.user.length + 2, log.message.length); this.richtextbox1.selectioncolor = color.white; this.richtextbox1.deselectall(); this.richtextbox1.rtf += oldtext; } catch { } } is possib

jquery - tips on using checkbox inputs in editable javascript form -

situation: i'm using javascript put user profile form , in need of little regard checkbox inputs. goal have form returns input information mysql database (such name, job, etc etc), form updated user, once saved. i've been able database query work text inputs users can see data they've saved. have 1 spot need checkbox input each user simple binary answer. figured i'd store information such checked=1 unchecked=0. problem: while can checked info save fine value=1, i'm looking way make box check display check once person has saved answer , has come edit it. also, i'm looking way allow user uncheck box , overwrite value=1 value=0. i figure use sort of sloppy if-statement fiasco accomplish this, wondering best practices used in situation. (if can't tell i'm learning way through web development) my checkbox displayed so: <tr><td id='ownershipquestion' colspan='2'>does person have ownership stake?</td><

Does SQL Server Service Broker load balance when External Activator is used? -

say have queue has high load throughout day. each of messages in queue takes several seconds process. if have 4 machines setup external activator (all configured same queue/service), work? if work, load balance (spreading work out evenly across worker machines)? this boils down, ultimately, how multiple pending waitfor (receive) statements serviced. consider have 4 instances of app running, each 'listens' on same queue, issuing waitfor(receive) . message becomes available in queue, question is: which of pending waitfor(receive) message ? the answers surprises many, , design: the issued waitfor(receive) message . not oldest one, not random one, newest one. in other words, lifo order listeners. why? behavior intentional , intent have few listeners needed handle load. have 4 processes listening. 1 gets message, processes , issues again waitfor(receive) , starting listen again more messages. next message, when arrives, given, deterministically, same process,

regex - Python: function to identify all subfolders that match a pattern -

i have written following bit of code find subfolders matching pattern. not have way of checking function finding matches. i want retrieve folders have name of form "19xx@60xx_npo" xx characters, possibly uppercase. def findwrongencut(path): pathlist = glob.glob("./%s/19*@60*_npo" %path) print pathlist print len(pathlist) does function above guarantee folders match "19xx@60xx_npo" yes, match things not directories , names '19xxxxxx@60xxxxxxxx_npo'. if want match specific number of letters, use ? each character in glob. if want guarantee directories, throw trailing slash on glob expression: pathlist = glob.glob("./%s/19??@60??_npo/" % path)

ios - Toggle between UIviews in Xcode -

i newbie in xcode , still learning basics. if question feels basic, please bear me. i have view, main view. when user clicks on button (options button), want go second view. here user can select 1 option many available. once user selected option, want send value first view , resume processing (when user clicked options button). important - user moving view1 view2 in mid of processing. have join view2 view1 , resume left off... means, need variable values available. a push segue won't create new version of parent view controller. starting session processing in viewdidload or in viewdidappear / viewwillappear? stopping processing in viewwilldisappear? in viewwilldisappear, can check navigation controller's stack see if parent view has been covered or being popped stack using code snippet: - (void)viewwilldisappear:(bool)animated { if ([[[self navigationcontroller] viewcontrollers] indexofobject:self] == nsnotfound) { // disappearing. clean sess

wpf - TextBox doesnt allow user to type -

hello i'm trying in wpf make user cant type in textbox. know there way make isenabled = false if use textbox gets grey color , cant make without background! there anyway forbid user entering char in textbox or other way? please help use textbox.isreadonly property: http://msdn.microsoft.com/en-us/library/ms753374.aspx

mysql - How can i create buttons from database field in VB? -

i use mysql database. want create new buttons in vb.net every data. when add new member admin panel, must create new button in vb.net. any appreciated. you can add control, including buttons dynamically control's collection: at basic looks this: dim mybutton new button mybutton.id = "btnmybutton" mybutton.text = "new button" me.controls.add(mybutton) the values id , text can come db. want button - can add handler "onclick" event using "addhandler" statement. the approach described above universal, depending on whether use asp.net or winforms - additional details may need coded.

gruntjs - Yeoman & Grunt, how to only include on build -

i'm using yeoman build angular app. there section of javascript want included on page when built (into dist folder). is there way tell grunt tasks running 'grunt server' during development skip part of template , include in build? this sounds perfect use-case grunt-processhtml . it allows place directives in html. in case remove directive you're looking for: <!-- build:remove --> <p>this removed when process done</p> <!-- /build --> <!-- build:dist:remove --> <p>but 1 when doing processhtml:dist</p> <!-- /build --> you can of course turn around , have snippet removed in server mode. if configure task output html in .tmp/ , connect server automatically serve file there. you add processhtml task task list server, e.g.: grunt.task.run([ 'clean:server', 'concurrent:server', 'autoprefixer', 'processhtml:server', 'connect:livereload', 'open'

ruby on rails - `require': cannot load such file -- cancan (LoadError) -

i'm using cancan gem activeadmin. working expected in dev, when pushed staging server following error: `require': cannot load such file -- cancan (loaderror) in case, caused the 'require' line in activeadmin's cancan adapter. i've searched google potential explanations have come empty-handed. what might cause of such error, , how can go fixing it? update: here config/initializers/active_admin.rb : activeadmin.setup |config| config.authentication_method = :authenticate_user! config.authorization_adapter = activeadmin::cancanadapter config.cancan_ability_class = "ability" config.current_user_method = :current_user config.logout_link_path = :destroy_user_session_path config.allow_comments = false config.batch_actions = true end restarting entire machine fixed this. i had tried restarting both nginx , unicorn, had yet restart machine itself. whatever reason, did trick. thanks thoughts / suggestions.

python - Borderless matplotlib plots -

Image
is there way save matplotlib graphs without border around frame while keeping background not transparent? setting frame 'off' show in code below not work removes background making transparent whereas want retain white background, without borders. a = fig.gca() a.set_frame_on(false) here screenshot of i'm trying do. if border can removed can draw x-axis line separately. all suggestions appreciated. a similar question asked here: how can remove top , right axis in matplotlib? . google search "hide axes matplotlib" gives 5th link. remove spines: x = linspace(0, 2 * pi, 1000) y = sin(x) fig, ax = subplots() ax.plot(x, y) ax.spines['top'].set_visible(false) ax.spines['right'].set_visible(false) ax.spines['left'].set_visible(false) ax.grid(axis='y')

How to configure localhost on android mobile and access it in offline? -

hello guys want ask how can enable access localhost without internet connection(wifi). because installed android application servers ultimate , androphp. if internet enabled, can access localhost using 127.0.0.1:8080 if internet disabled can't access localhost. checked settings , there nothing can found. can access http://localhost firstly? secondly, can login phpmyadmin using androphp?

javascript - preventing keyboard drops while loading in iOS -

in ios app, need focus on text field, based on user's previous interactions. focusing using javascript well, follows (in viewdidfinshload method) if (![focuselement isequaltostring:@""]) { // make keyboard freely appear without user intervention [webview setkeyboarddisplayrequiresuseraction:no]; // first lose previous focus , focus on // clicked element nsstring *jstofocus = [nsstring stringwithformat: @"document.activeelement.blur();document.getelementbyid(\'%s\').focus();", [focuselement utf8string]]; // javascript focuses on input [webview stringbyevaluatingjavascriptfromstring:jstofocus]; this works well. problem when page loads further frames/javascripts, key board drops down , reappears couple of times every new load. guess happening due earlier [webview setkeyboarddisplayrequiresuseraction:no]; is there (better) way , more importantly, keep keyboard

html - Content div height exceeding page height -

i have issue height of "content body" div (below) exceeding bottom of page (and behind page footer). want div scroll when there long content, now, doesn't scroll bottom of div beyond page. i'm not sure causing issue? here example: http://jsfiddle.net/gg6qy/ css: html, body { height:100%; width: 100%; overflow: hidden; margin: 0; } header { position: fixed; width: 100%; background: #006f3b; color: #fff; top: 0; height: 60px; padding: 10px; } #content { position: relative; height: 100%; width: 100%; padding: 60px 0 20px 0; /* header height , footer height */ margin: 0 auto; /* center content */ } #sidebar { position: absolute; background: #191919; color: #fff; left: 0; top: 60px; bottom: 0; width: 220px; padding: 10px; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; -o-box-sizing: border-box; -ms-box-sizing: border-box; box-siz

How do I search and copy in emacs? -

this question has answer here: emacs copy matching lines 5 answers my text follows format: header hello ... ... header neighbour ... ... ... header test1 header test2 i want select instances of header*\n , copy them new document. so, result like: header hello header neighbour header test1 header test2 it doesn't matter if spaces preserved. possible standard emacs functionality? it might easier copy whole document new document, , use delete-non-matching-lines . m-x delete-non-matching-lines<ret> ^header<ret>

try catch - Python trying fails -

i trying in python. try: newbutton['roundcornerradius'] = buttondata['roundcornerradius'] buttons.append(newbutton) buttons list. roundcornerradius optional in buttondata. alas gives buttons.append(newbutton) ^ syntaxerror: invalid syntax i want ignore cases roundcornerradius not exist. don't need error reported. why arent using except keyword try: newbutton['roundcornerradius'] = buttondata['roundcornerradius'] buttons.append(newbutton) except: pass this try first part , if error thrown except part you can add disered error want except error this except attributeerror: you can excepted error doing this: except exception,e: print str(e)

php - Using PhantomJS on host without root access -

i have been struggling long time decided ask here. i want use phantomjs on host not have root access. right using 000webhost.com test things, apache ver. 2.2.19 (unix) , uploaded phantomjs-1.9.1-linux-i686.tar.bz2 pulic_html/phantomjs-1.9.1-linux-i686.tar/ file. should work or need root access use phantomjs. if should work because php executing wrong exec('http://example.com/phantomjs-1.9.1-linux-i686.tar/phantomjs-1.9.1-linux-i686.tar.bz2 http://example.com/countdown.js'); will vps hosting root access work. as can see confused , great. usually executing applications in shared hosting environment isn't best practice , hosting provider may not allow it. recommend getting vps if need run phantomjs since have full control on how run applications. running application root , calling php bad idea. if system compromised, attacker has root access. create account restricted privileges on vps running phantomjs. can proceed call phantomjs php using exec .

php - Looking for better ways to style JSON object data retrieved using AJAX -

i'm using ajax in website json string generated php script. json object looks like: { "people" : [ { "name" : "bob", "id" : "1", "sex" : "m" }, { "name" : "amy", "id" : "2", "sex" : "f" } ] } once retrieve using ajax, i'm styling manually using javascript for(i = 0; < obj.people.length; i++) { document.getelementbyid('people-container').innerhtml += '<span class=\'' + obj.people[i].sex + ' person\'>' + obj.people[i].name + '</span> } but can't have feeling of guilt having html , classes embedded in javascript, since i'm using smarty template engine other, non-ajax content. i figured can't use smarty ajax responses since template engine runs on page load, , ajax calls done after page loads... there better way doing this? it useful if put sample code.

Redirect the Email Address Link to their Specific Domain Names -

i have question, please out there me!! i have email address "user@example.com" when click email address, should go specific domain name i.e, www.example.com, same if there email id "user@gmail.com" , should automatically go www.gmail.com when clicking email address!! simply have redirect domain name after @ symbol? so, actual final url when clicking above email id links "www.mysite.com/user@example.com" please prefer url rewrite code added in .htaccess file!! thanks in advance

Parsing json using model - Sencha -

i trying parse json having problem create model how can create effiecient model json below can access def-id doing record.get('def_id'): i creating model as: ext.define('myapp.model.todaysword', { extend: 'ext.data.model', requires: ['myapp.model.todayswordmenu'], config: { fields: [ {name: 'status', mapping: 'status'}, {name: 'message', mapping: 'message'}, {name:'data', mapping: 'data'}, {name: 'definitions', mapping: 'definitions.defintion'}, {name: 'ratings', mapping: 'definitions.rating'}, ], } }); ext.define('myapp.model.todayswordmenu', { extend: 'ext.data.model', config: { fields: [ 'name', 'author', 'word_id', 'category', 'definitions', 'rating', 'def_id', 'example',

java - Get value from jsp drop down in servlet -

i have 2 drop down box , & second drop down depends on user has selected in first drop down(done using javascript). shown below: first drop down: <div class="element"> <label for="category">category </label> <select id='statecombo' onchange='statecombochange();'> <option value='-1' title='-select one-'>-select one-</option> <option value='0' title='mobile'>mobile</option> <option value='1' title='nsw'>routers</option> <option value='2' title='tas'>datacard</option> </select> </div> second drop down: <div class="element"> <label for="category">sub-category </label> <select id='citycombo' name="category" onchang

ruby on rails - running rake task from console produces 'ArgumentError: no method name given' error -

i have rake task meant call mailer , email users meet given condition. but, when call rake task console using rake nagging_email:send following 'argumenterror: no method name given' , task not run. full console error log can seen here: https://gist.github.com/srt32/6433024 i have mailer set follows: class workoutmailer < actionmailer::base def nagging_email(user) @user = user subject = "what have done today?" @url = 'http://frozen-taiga-7141.herokuapp.com/members/sign_in' mail to: @user.email, subject: subject.to_s end end and rake task follows gets users meet given condition (being lazy) , calls mailer given user param: namespace :nagging_email desc "send nagging email lazy users" task :send => :environment daily_nag end def daily_nag users = user.all users.each |user| unless last_workout(user) == date.today workoutmailer.nagging_email(user).deliver

What to return when range HTTP header requests last byte of file? -

i need handle range header programatically in java supporting media files on ios. if file 23843 bytes, example, i'm getting request range header: range: bytes 23842-23842 what meant return in case? last byte of file? you should send file offset 23842 offset 23842, yes, comes out 1 byte. the spec gives similar example: the first , last bytes (bytes 0 , 9999): bytes=0-0,-1 (the important bit here being 0-0 = first byte )

java - Why it is necessary to override hashcode and equals method of key for Hashmap? -

this question has answer here: what issues should considered when overriding equals , hashcode in java? 11 answers i created hashmap having student key , string value. now everywhere have read necessary override equals , hashcode method if using key hashmap. but did not override it. , insert multiple key value pairs in hashmap. able fetch back. so why necessary? they required when want use objects useful hashing keys collections use hashing. have tried add student objects meaningfully equal? first understand significance of equals method in java read significance of equals , hashcode