Posts

Showing posts from February, 2015

google maps - Android OnItemCLickListener not working in listview -

i new android programming.i developing app in when user clicks on listview item should go google maps app , display pin address on map. when click on item nothing happens. following display activity. public class displayactivity extends activity implements onitemclicklistener{ listview listview; private string tag_name; public list<nameaddress> nameaddresslist; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_display); listview = (listview) findviewbyid(r.id.list); intent intent = getintent(); if(intent!= null) { tag_name = intent.getstringextra("dashitemname"); settitle("list of " +tag_name+ " addresses"); } nameaddresslist = null; try { xmldomparserhandler parser = new xmldomparserhandler(tag_name); nameaddresslist = parser.parsexml(getassets().open("data.xml")); arr...

install sonata userbundle in symfony2.4.1 -

i want install sonata userbundle , use symfony2.4.1, composer.json: "require": { "php": ">=5.3.3", "symfony/symfony": "~2.4", "doctrine/orm": "~2.2,>=2.2.3", "doctrine/doctrine-bundle": "~1.2", "twig/extensions": "~1.0", "symfony/assetic-bundle": "~2.3", "symfony/swiftmailer-bundle": "~2.3", "symfony/monolog-bundle": "~2.4", "sensio/distribution-bundle": "~2.3", "sensio/framework-extra-bundle": "~3.0", "sensio/generator-bundle": "~2.3", "incenteev/composer-parameter-handler": "~2.0", "sonata-project/admin-bundle": "dev-master", "sonata-project/doctrine-orm-admin-bundle": "dev-master", "sonata-project/intl-bundle": "...

python - gevent and thread performance compare? -

i write test case compare thread , gevent's performance, using multithread task like: import time import threading def sync_task(): #do time.sleep(1) def multi_thread_run(): start = time.time() in range(10): t = threading.thread(target=sync_task) t.start() end = time.time() print("multi thread task executed in %f second"%(end-start)) print: multi thread task executed in 0.002425 second however, using gevent replace thread same task: import gevent def async_task(): #do gevent.sleep(1) def async_run(): start = time.time() coroutins = [] in range(10): coroutins.append(gevent.spawn(async_task)) gevent.joinall(coroutins) end = time.time() print("async task executed in %f second"%(end-start)) print: async task executed in 1.002012 second in many blog post see coroutine more effective mutilthread, in case, how explain it? that's because didn't j...

C http server get data array -

i trying set simple webserver in c. server reads request char , example request: get /?var1=val1&var2=val2 http/1.1 how can format char can retreive values array? something in format: const char *requestdata[2][80]; // code filling requestdata[][] url parameter values // requestdata[0][0] -> val1 requestdata[1][0] -> val2 i have tried things while loops combined strcmp() , these attempts seem inefficient, proper way of doing this?

MySQL 5.1.* Strange trigger replication behavior -

i have mysql master-slave configuration. on both servers have 2 tables: table1 , table2 i have following trigger on both servers: trigger: test_trigger event: update table: table1 statement: insert table2 values(null) timing: after the structure of table2 following: +-------+---------+------+-----+---------+----------------+ | field | type | null | key | default | | +-------+---------+------+-----+---------+----------------+ | id | int(11) | no | pri | null | auto_increment | +-------+---------+------+-----+---------+----------------+ the problem that, on mysql 5.1.* , when slave calls trigger adds id inserted on master , not id should insert according own auto_increment value. let's have following data: on master: select * table2; empty set (0.08 sec) on slave: select * table2; +----+ | id | +----+ | 1 | +----+ 1 row in set (0.00 sec) (just ignore fact slave not complete mirror of master) given above scenario, when...

Get SQL data via listbox -

ok, trying click 1 item in listbox have, listbox gets data sql database depending on user types textbox. now when click item in first listbox, need more info related item show in 2nd list box. when user enters name in textbox, first 10 in sql show up, have that, need click on 1 of items , 'task' of client in next listbox. task matters in database. i pretty sure code correct, no errors nothing shows in list box. here code: private void listbox1_selectedvaluechanged(object sender, eventargs e) { string item = listbox1.selecteditem.tostring(); if (listbox1.containsfocus) { if (item == "") { } else { var con2 = conn.connstring(); using (sqlconnection myconnection2 = new sqlconnection(con2)) { string ostring2 = "select clientmatters.matter, clientmatters.description clientmatters join clientcodes on clientmatters.client = clientcodes.client clientcodes.descripti...

c++ - unpack variadic template with scoped_ptr -

i'm using variadic templates, , find way unpack parameters template <typename kernel_type, typename ...kernel_types> class metakernel : public mykernel<kernel_type, kernel_types...> { public: metakernel ( unsigned int m, unsigned int n, const kernel_type& kernel_, const kernel_types&... kernels_ ) : mykernel<kernel_type, kernel_types...>(m, n) { ks.set_max_size(sizeof...(kernel_types)); ks.set_size(sizeof...(kernel_types)); // each kernels_, add myobskernel ks // ks[sizeof...(kernel_types)].reset((new myobskernel<kernel_type, kernel_types...>(kernels_, prototypes_, m, n))...); } private: array < scoped_ptr < myobskernel<kernel_type, kernel_types...> > > ks; } from documentation ( http://en.cppreference.com/w/cpp/language/parameter_pack ), saw how unpack this: int dummy[sizeof...(ts)] = { (std::cout << args, 0)... }; but i...

javascript - Check if all dropdowns in page has a selected option -

need enable button on page if questions have been answered, have 5 dropdowns , need make sure user answer of them before letting him go next step. tried iterate through each select on each change, can't make work, bad js knowledge. arr = $('.select1, .select2, .select3, .select4, .select5') $('.select1, .select2, .select3, .select4, .select5').on('change', function(event) { $.each(arr, function(index, val) { /* tried here */ }); }); i wondering may there better way this, in 1 line: select.selected.size = 5 . thank kind of - ideas, solutions, links, etc.. i had few moments, thought i'd offer potential solution; given html following: <select name="test1"> <option value="-1">please select</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> </select...

c++ - some_struct* args1 = (some_struct*)args2 -

in c++ code, explain following line doing, have not seen notation before. some_struct* args1 = (some_struct*)args2 a simplified example is: struct some_struct { myclass1* thisclass1; }; void function1(void *args2) { some_struct* args1 = (some_struct*)args2; //do more stuff } int main(int argc, char* argv) { mainclass1=myclass1::new() some_struct args2; args2.thisclass1=mainclass1; function1((void *)&args2); return 0; } forgive grammar, program in python. in function variable args2 generic pointer, meaning can point can't use directly there no type information associated void . expression (some_struct*)args2 tells compiler pretend args2 pointer some_struct . this type of expression called cast expression , "casts" 1 type type. syntax c-style cast, inherited in c++ roots in c language. the c++-specific equivalent of c-style cast reinterpret_cast , like some_struct* args1 = reinterpret_cast<some_struct*>(args2);

go - Is it possible to import only a function from a package? -

sometimes need function package importing whole package doesn't seem performance wise. question: possible import function ? no, not possible. no, has no impact on performance. unused stuff package should dropped linker won't clutter binary.

java - HSDC database connection -

i have inject data in database via java program. use hibernate , thread (pool of thread via executor) because customer want quick software. use pool of thread . program works during 45 seconds - 1 minute , after have error, repeated , repeated : exception in thread "pool-1-thread-593" org.hibernate.exception.jdbcconnectionexception: cannot open connection @ org.hibernate.exception.sqlstateconverter.convert(sqlstateconverter.java:99) @ org.hibernate.exception.jdbcexceptionhelper.convert(jdbcexceptionhelper.java:66) @ org.hibernate.exception.jdbcexceptionhelper.convert(jdbcexceptionhelper.java:52) @ org.hibernate.jdbc.connectionmanager.openconnection(connectionmanager.java:449) @ org.hibernate.jdbc.connectionmanager.getconnection(connectionmanager.java:167) @ org.hibernate.jdbc.jdbccontext.connection(jdbccontext.java:142) @ org.hibernate.transaction.jdbctransaction.begin(jdbctransaction.java:85) @ org.hibernate.impl.sessionimpl.begintransac...

android - Why we need to place Semicolon manually after this.. View -

why need place semicolon manually? after this anyview.setonclicklistener(new view.onclicklistener(){ @override public void onclick(){ //do here } }) /// here error if not place semicolon ... why eclips not placing ; here? } i want make concept clear.... you need semicolon complete anyview.setonclicklistener() statement. of time, eclipse not automatically complete code statements - cannot read mind code intended write. what can confusing argument setonclicklistner() anonymous inner class instance created inline , syntax mixture of class definition , method calling.

javascript - How to insert the dynamic added row values into the database using JDBC Servlets -

here jsp code, adding , deleting rows dynamically using javascript,but while inserting details database mysql,it insert 1 row..how add dynamically added row values database using servlets.. here code <html> <head> <title> timeline sheet</title> <script language="javascript"> $('form').change(function(){ $('form').submit(); }); function validlogin(){ if (document.form.eid.value == ""){ alert ( "please enter employee id." ); document.form.eid.focus(); return false; } if (document.form.ename.value == ""){ alert ( "please enter employee name." ); document.form.ename.focus(); return false; } alert ( "inserted successfully" ); return true; } function addrow(tableid) { var table = document.getelementbyid(tableid); // rowcount = table.rows.l...

html5 - Chrome Developer Tools Settings -

i have been using chrome dev tools aligning various <img>'s . doing inspecting element , adding css auto generated selector clicking plus button in style pane. somehow auto generated css not working same before i.e not generating css particular element e.g previously #framebox_3920691 > div > table > tbody > tr:nth-child(2) > td:nth-child(1) > > img { } now img{ } any ideas? using such [extremely verbose] selectors not recommended , hardly maintainable. it's better assign specific classes/ids images , use in selectors. that said, if need full css path element, right-click element in elements panel , choose copy css path in context menu full css path system clipboard.

Why my model function doesn't work in ZEND? -

i'm wondering wrong code : function controller : public function testareaction(){ // $this->getresponse()->setheader('content-type', 'application/json'); $this->_helper->layout->disablelayout(); $this->_helper->viewrenderer->setnorender(true); //$myarray = $_post['data_post']; //$product_ids = $_post['product_ids']; //$type = 1; $model = new application_model_order(); echo $model -> saveordernames(); } and function model : public function saveordernames(){ return 1; } why im not getting result "1" in browser? im newbie please give me speficitions. thx :d index controller : public function indexaction() { if (!($locationurl = $this->_getparam('locationurl'))) { throw new \zend_controller_action_exception('location url not provided.', 404); } $this->maidivclass = "block clear step1...

how to generate integer random number in fortran 90 in the range [0,5]? -

i kind of new in fortran proramming. can please me out solution. having problem of generating integer random number in range [0,5] in fortran random number using random_seed , rand what about: program rand_test use,intrinsic :: iso_fortran_env real(real32) :: r(5) integer :: i(5) ! call init_random_seed() go here call random_number(r) ! uniform distribution requires floor: @francescalus = floor( r*6._real32 ) print *, end program

ios - How to create a custom base class which has a TableView, a Search & some edit functions, so as other class can inherit from it -

i have many uitableviewcontroller classes in project. have, mostly similar functions including search, edit, pull refresh. a tableview a uisearchbar a uisearchdisplaycontroller. as don't want re-write these functions each class, how create custom base class has these function. i don't know how this? any tutorial link or guidance of help. you need follow simple inheritance concept of oops. so here simple idea proceed. create new file, name mycustomtablebase & type uitableviewcontroller in subclass of section in dialog. now provide table related stuff & public method & objects in base class. now create new file again step1 & name mynewhomecontroller & type mycustomtablebase in subclass of section in dialog. once done file, can check mynewhomecontroller.h file inheritance path this: #import "mycustomtablebase.h" @interface mynewhomecontroller : mycustomtablebase @end now how design base & subsequentl...

how to make Generic method for rest call in angularjs -

how make generic method rest call in angularjs ? i have tried single request, it's working fine uiapproute.controller('test', ['$scope', 'checkstatus', function($scope, checkstatus) { $scope.data = {}; checkstatus.query(function(response) { $scope.data.resp = response; }); }]) uiappresource.factory('checkstatus', function($resource){ return $resource(baseurl + 'status', {}, {'query': {method: 'get', isarray: false}}) }) i want make generic request please share sample,.. in advance i'm using : .factory('factoryresource', ['$resource', 'conf', function($resource, conf) { return { get: function(endpoint, method) { var resource = $resource(conf.baseurl + endpoint, {}, { get: { method: method || 'get' } }); return ...

asp.net - 'Owin.IAppBuilder' does not contain a definition for 'MapSignalR' -

error 'owin.iappbuilder' not contain definition 'mapsignalr' , no extension method 'mapsignalr' accepting first argument of type 'owin.iappbuilder' found (are missing using directive or assembly reference?) code using microsoft.owin; using owin; [assembly: owinstartup(typeof(signalrchat.startup))] namespace signalrchat { public class startup { public void configuration(iappbuilder app) { // connection or hub wire , configuration should go here app.mapsignalr(); } } } any appreciated... update signalr version 2.0.3 microsoft owin version 2.0.2 owin version 1.0.0 visual studio 2012 only install nuget: install-package microsoft.aspnet.webapi.owinselfhost

java - JAXB unmarshalling with @XmlMixed Annotation -

i have problem while unmarshalling xml document. found hints here (" jaxb- @xmlmixed usage reading @xmlvalue , @xmlelement ") wasn't able adopt on code. first.. here example of xml: <test> <content type="text">this content text</content> <content type="attributes"> <attributegroup name="group1"> <attribute name="attr1">value1</attribute> </attributegroup> <attributegroup name="group2"> <attribute name="attr2">value2</attribute> <attribute name="attr3">value3</attribute> </attributegroup> </content> </test> within content block there either text or several attribute groups attributes (never both!). sadly given xml structure , can't change it. i tried following class structures there must error within xmlmixe...

How to transform MongoDB document to array -

my returned document looks this: { "_id": "57terjrtgutgsjj", "eventlist": [ { "eventid": "5346a816e4b0efc8bd9759b5", "riskscore": 0, "entity": { "entityid": "5346a816e4b0efc8bd9759b6", "name": "src ip", "value": "209.178.49.9", "type": "ip", "direction": "s", "iskey": "true" } } ] } i want result in format: { "_id": "57terjrtgutgsjj", "eventlist": [ { "eventid": "5346a816e4b0efc8bd9759b5", "riskscore": 0, "entity": [ { "entityid": "5346a816e4b0efc8bd9...

c# - How can I setup Javascript dynamically to expand divs when clicking another div? -

i creating main menu in asp.net using dynamically created divs. the divs associated 3 different levels. i have done need struggling expanding , collapsing menus. i need show level 1 items when page loaded (probably easier using css?) then need able expand level2 items particular level1 item when item clicked. i need collapse them after time period. the code below shows how divs created , statements specific levels: private void creatediv(string divid, string url, int level) { //attributes items htmlgenericcontrol div = new htmlgenericcontrol("div"); div.attributes.add("id", divid); div.controls.add( new label() { id = "lbl" + divid, text = divid }); if (level == 1) { div.attributes.add("class", "level1"); //code expand level 2 items } if (level == 2) ...

r - POSIXct back to character, specific format -

lets have character vector of like: vec <- "1/1/2000" at pont turn date via newvec <- as.posixct("1/1/2000", format = "%d/%m/%y") now let want make character again can do: as.character(newvec) [1] "2000-01-01" the new format y-m-d . how can turn newvec "1/1/2000" ? like this: as.character(newvec,'%d/%m/%y') # [1] "01/01/2000"

How does Node.js execute two different scripts? -

i can't imagine how can node.js in 1 single thread execute 2 scripts different code simultaneously. example have 2 different scripts , b. happen if simultaneously several clients request , b. php understandable, example, created 5 threads handle , 5 threads handle b, , each request script executes again. happens in node.js? thank you! it uses called event loop , implemented libuv a simple explanation be: when new event occurs, put queue. every , then, node process interupt execution process these events. the main difference between php , node node.js process stand-alone web server (single threaded), while php interpreter runs within web server (i.e. apache), responsible creating new threads each request.

inplace editing - How to use Ruby's command line in-place-edit mode to remove lines from a text file -

i've been long time perl user, , in perl can remove lines text files this: perl -pi -e 'undef $_ if m/some-condition/' file.txt i'm trying move scripting ruby, in-place-edit, wrote this: ruby -pi -e '$_ = nil if $_ =~ /some-condition/' file.text but instead nullified entire file. tried ruby -pi -e 'nil if $_ =~ /some-condition/' file.text but didn't anything. any ideas? ruby -pi -e '$_ = nil if $_ =~ /some-condition/' file.text should correct. if doesn't work, problem in some-condition . demonstrate, echo -e "a\nb\nc" > x ; ruby -pi -e '$_ = nil if $_ =~ /b/' x ; cat x prints a c

JOIN query not working in iphone device but working in iOS Simulator -

i have 2 tables resources , resourceviewhistory resources has these fields: resourceid , typeid , name , url , isfavorite , languagecode , categoryid . resourceviewhistory has these fields: viewid , resourceid , dateviewed , longitude , latitude i want result set resourceid in resources table: name,url,isfavorite,resourceid , dateviewed,longitude,latitude same resourceid in resourceviewhistory table , categoryid=1,typeid=1 my query is: select r.resourceid,url,name,isfavorite,max(v.dateviewed) lastvisited,longitude,latitude resources r left join resourceviewhistory v on (r.resourceid=v.resourceid) categoryid=1 , typeid=1 group r.resourceid the above query working in simulator not working in iphone device.my objectivec code below.the arrurldetails array showing 0 objects +(nsmutablearray*)geturldetails{ nsstring *strhome = nshomedirectory(); nsstring *strdestpath = [nsstring stringwithformat:@"%@/documents/test.sqlite",strhome]; nsmutablearray *arrurldetail...

matlab - Cumulative Normal Distribution Function in C/C++ with parameters -

i want implement equivalent of matlab normcdf function in c++, have found useful post: cumulative normal distribution function in c/c++ pointing implementation http://www.johndcook.com/cpp_phi.html . want optional mu , sigma parameters in matlab. is ok, when change this: x = fabs(x)/sqrt(2.0); to: x = fabs(x - mu)/sqrt(2.0 * sigma * sigma); or supposed else? watch out - want save sign of x-mu , not of x : int sign = 1; if (x < mu) sign = -1; x = fabs(x-mu)/sqrt(2.0*sigma*sigma); otherwise scaling correct.

prestashop mail customisation, and module translation -

i have 2 question 1 - installed referral program module , , customise referralprogram-invitation.html mail template putted new template under : prestashop_root/themes/my_theme/modules/referralprogram/mails/referralprogram-invitation.html doesn't work ! 2 - add text program page of referral program module copied file included module under prestashop_root/themes/my_theme/modules/referralprogram/translations/fr.php , added new text translation in form $_module['<{referralprogram}prestashop>program_md5'] = 'new text'; and not work?!! you forgot language folder. mail templates must not in : prestashop_root/themes/my_theme/modules/referralprogram/mails/referralprogram-invitation.html in prestashop_root/themes/my_theme/modules/referralprogram/mails/fr/referralprogram-invitation.html if want add text program page, must: first, make copy of file : prestashop_root/modules/referralprogram/views/templates/front/program.tpl ...

Can I use function macros inside gcc inline assembly block? -

#define mov_macro(r0,r1)\ {\ "mov r0, r1 \n\t"\ } __asm__ volatile(\ mov_macro(r4,r5) :"r4","r5"\ );\ is possible use function in asm block ? if not, please suggest ways use it. yes, it's possible, if need such functionality shouldn't using inline asm separate asm module. #define mov_macro(r0,r1) "mov " #r0 ", " #r1 "\n\t" void foo() { __asm__ volatile( mov_macro(r4,r5) :: :"r4","r5" ); }

java - Just need some enlightenment about .equals -

this question has answer here: the equals() method in java works unexpectedly on long data type 10 answers integer = new integer(1); integer b = new integer(1); long c = new long(1); system.out.println(a.equals(b)); system.out.println(a.equals(c)); question why a.equals(c) gives false? from integer.equals() : the result true if , if argument not null , integer object contains same int value object. c not integer , a.equals(c) returns false .

c++ - Building gcc 2.95.3 on Ubuntu 12.04 -

i want compile gcc-2.95.3 on ubuntu 12.04 machine, won't work. i found this , , this , nothing helped. i first tried build 4.6.3 version of gcc, got error message. tried build gcc-3.4.6 because in first link, version had been used build 2.95.3, not successful either. trevorpounds best page solving issue can find, wont work. tried other things too, nothing works. as far know, newer toolchain may problem, there way fix without reinstalling whole os? actually, dont care whether build myself or not, if there place can download binaries , work, i'm happy. okay, detailed information did , error messages got: the whole procedure here 1) have fresh installation of ubuntu 12.04 2) detect glibc have installed ldd --version , got answer ldd (ubuntu eglibc 2.15-0ubuntu10.5) 2.15 ... 2.15 3) download glibc-2.15.tar.gz http://ftp.gnu.org/gnu/libc/ , save downloads folder. 4) unpack glibc tar xzf glibc-2.15.tar.gz 5) mkdir -p gcc-2.95.3/glibc-workaround/include/bits...

javascript - ng-show disturbing div layout - angularJS -

i using ng-show="!notesopened" hide div if notesopened variable true. when hidden messes layout. there way make ng-show act in same way css property visibility:hidden ? div elements around div being hidden stay in same place ng-hide uses same property you're referring to, i.e. display: none . if need achieve this, need use visibility: hidden; for can use ng-class attribute. eg: ng-class="{'vis-hidden': notesopened==true}" .vis-hidden{ visibility: hidden; }

Reading configuration in Biztalk maps AND orchestrations -

i've got 2 situations in need read in configuration data biztalk: within expression shape of orchestration. compare part of message response predefined string different between environments connection string of database lookup in map i don't want have recompile in order move between test , live environment , have multiple applications potentially needing own version of same configuration element. i've seen this question server level , seems risky. my other idea use custom table sp read values back. means every time want read setting have construct, send , receive message in orchestration. doesn't me in map. are there other options less intrusive process flow or involve less work/maintenance? the chosen method store config data biztalk sso though there other options. you can use sso config data storage tool, http://seroter.wordpress.com/2007/09/21/biztalk-sso-configuration-data-storage-tool/ , maintain information. microsoft has published s...

php - How can I update and new table based on 3 columns from an old table? -

i have 2 tables: new_product columns: id_product, id_category, id_combination, id_feature, whole_sale_price, retail_price, old_product columns: id_product, id_category, id_combination, id_feature, whole_sale_price, retail_price, how can update data columns whole_sale_price , retail_price on new_product using value columns whole_sale_price , retail_price old_product using key id_category , id_combination , id_feature ? in general way write follows: update table1 target, (select column1, column2 table2) source set target.column3 = source.column1 target.column4 = source.column2

c# 4.0 - windows setup file are not getting proper location -

Image
i creating setup file not going on proper location. when run setup follow these steps 1 right click on setup file - go on application folder --> right click go on properties > , set location but go in program files\ . want programs file\ata\schedulling\folder can please me doing mistake . thanks

osx - Which one of two versions of Xcode installed will be updated on updating? -

hey guys have installed 2 versions of xcode (xcode-5.0 , xcode-4.6) on mac. app store showing updates xcode. if updating xcode version updated (overridden). the 1 has name xcode in applications folder. in case, had xcode_4.6 , xcode (5.0) in applications folder, , 5.0 got updated.

java - How do I use ArrayList<Integer>#contains when I only have a BigInteger? -

i pulling data values database returns list of <integer> . however, see if list contains biginteger. there simple way this? i have following code in java: arraylist<integer> arr = new arraylist<integer>() {{add(new integer(29415));}}; boolean contains = arr.contains(29415); // true boolean contains2 = arr.contains(new biginteger("29415")); // false i'm not sure on efficient way this? the correct answer returned evaluation of following: val != null && biginteger.valueof(integer.min_value).compareto(val) < 0 && biginteger.valueof(integer.max_value).compareto(val) > 0 && list.contains(val.intvalue()) this correctly solve question of whether biginteger have "contained" within list<integer> . note here downcast necessary. if val outside range of integer values there no need downcast know value cannot within list. a more relevant question whether should using list<big...

python - How to automate interaction for a website with POST method -

i need input text text box on website: http://www.link.cs.cmu.edu/link/submit-sentence-4.html i need return page's html returned. have looked @ other solutions. aware there no solution all. have seen selenium, im not understand documentation , how can apply it. please me out thanks. btw have experience beautifulsoup, if helps.i had asked before requests solution.i don't know how use though pulled straight docs , changed example. from selenium import webdriver # create new instance of firefox driver driver = webdriver.firefox() # go page driver.get("http://www.link.cs.cmu.edu/link/submit-sentence-4.html") # page ajaxy title this: print driver.title # find element that's name attribute sentence inputelement = driver.find_element_by_name("sentence") # type in search inputelement.send_keys("you're welcome, accept answer!") # submit form inputelement.submit() this @ least input text. then, take @ this example retr...

xml - How to change Rails 3 to_xml encoding -

im using rails 3 to_xml on model few options include, except , methods. not first time using to_xml . i'm doing this: to_xml(include: { order: { methods: [:my_avg], except: [:this_attr, :and_this_attr ] }, customer: {} }) the xml result: <?xml version="1.0" encoding="utf-8"?> <my-model> <attr1 type="integer">12</attr1> <attr2 type="integer">12</attr2> <order> <name>foo</name> <desc>bar</desc> <my-avg> <avg type="integer">123</avg> <foo>ok</foo> </my-avg> </order> <updated-at type="datetime">2014-04-14t11:16:56-03:00</updated-at> </my-model> but want change xml encoding iso_8859_1 instead of utf8. i haven't seen encoding option on activerecord::serialization module. if add 1 encoding option creates xml attribute instead of ch...

Matlab large array (1e6 values) computation speed -

i trying optimize matlab code statistic calculation large array of data (1e6 values). tried several methods, loops or fun functions, diff or basic math. need calculate accumulation set of data , standard deviation it. i cannot running under 24 seconds. there way improve code, without using additional toolboxes? here tried until now: clear close mydata = rand(1e5, 1)/5e6; m = 1000; n = length(mydata)-m; pkpk = nan(m, 1); std = nan(m, 1); mymat = nan (1, n); %%%%%%%%%%%%%%%%%%%%%%%%%% peak2peak part of signal processing toolbox: %%%%%%%%%%%%%%%%%%%%%%%%%% can use max()-min() tic x = 1 : m mymat = diff( (reshape(mydata(1:x*floor(n/x)),x,floor(n/x)))') ; pkpk (x) = peak2peak(mymat(:)) ; std(x) = sqrt(sum(sum((mymat-mean(mymat(:))).^2))/numel(mymat)); end time1 = toc; %%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%% tic x = 1 : m mymat = bsxfun(@minus, mydata(x+1 : x+n) , mydata(1:n)) '; % edit here: transpose pkpk (x) = peak2peak(...

php - Submitting values to database from form -

i have billing page fetches data cart. i having problem submitting these values database. how correct php submit database correctly? for example, have transactions table in database, , want payment details go there, can later fetched , outputted in admin section receipt of order. i cannot name, address, email, phone submit correctly. comes 0 in database, how fix this? how can use ajax when button clicked show loading bar/page , success message? i error: notice: undefined index: command in f:\xamppnew\htdocs\web\billing.php on line 5 code: <?php include "storescripts/connect_to_mysql.php"; session_start(); if($_request['command']=='update'){ $name=$_request['name']; $email=$_request['email']; $address=$_request['address']; $phone=$_request['phone']; $item_id = $_session['item_id']; $quantityorder = $each_item['quantity'] = $_session[...

time - f# break function evaluation -

i have minimize quite complicate function. minimization use nonlinearprogram extreme optimization library. since there´s no way find global minimum, use different startpoints , choose, "best minimum". problem there can startpoints, evaluatin can take long time. there general way in f# or special method in extreme optimization, stop evaluation let´s after 10 min , give list [nan; nan; nan; nan; nan; nan] back? let funcfindpara (startpoint:float list) func = let nlp = new nonlinearprogram(6) // add function nlp.objectivefunction <- (fun x -> func x.[0] x.[1] x.[2] x.[3] x.[4] x.[5]) // add lineare constraints nlp.addlinearconstraint("a + d > 0", vector.create(1.0, 0.0, 0.0, 1.0, 0.0, 0.0), 1.0e-5, infinity) |> ignore nlp.addlinearconstraint("c > 0", vector.create(0.0, 0.0, 1.0, 0.0, 0.0, 0.0), 1.0e-5, infinity) |> ignore nlp.addlinearconstraint("d > 0", vector.create(0.0, 0.0, 0.0, 1.0, 0.0...

jquery - Scrolling to content after a Bootstrap Accordion is opened -

i have bootstrap accordion has many panels in it. issue facing if panel opens off page user has no idea panel open , can scroll down it. to solve wanted able scroll content open know content open , saves them scrolling it. i seem running issues though when trying attempt this. this function looks like $('.acclink').on('click', function(){ if($(this).parent().next('.panel-collapse').hasclass('in')){ }else{ //this scroll happen } }); so far have tried... $('html, body').animate({ scrolltop: ($(this).parent().next('.panel-collapse')) },500); and $('div').animate({ scrolltop: ($(this).parent().next('.panel-collapse')) },500); i have tried this... function scrolltoelement(ele) { $(window).scrolltop(ele.offset().top).scrollleft(ele.offset().left); } var element = $(this).parent().next('.panel-collapse').attr('id'); scrolltoelement($('#'+element)); but neith...

javascript - Google Maps and Revealing Module Pattern – Context -

i created little function, puts map (google maps) on website. structure code bit used revealing module pattern (multiple instances of same module multiple maps). on page load load google maps api ajax , attach click event listener each marker. i created fiddle basic code: http://jsfiddle.net/k9mqz/ . if there 1 .map in html works fine, put second .map in html , click on marker in first map, content gets shown in second map. i'm not sure, think part, broken part in google maps api event listener: google.maps.event.addlistener( marker[ idx ], 'click', function( e ) { // doesn't refer right instance of module. instead uses last instances time, if click marker on first map. clickmarker( idx, data ); }); if put console.log($el) in clickmarker function, returns second map. suggestions make work? you never defined $eltitle , $eldescription , therefore, when set them, being set globally on window . second call overwrote value set in first....

c# - Custom UI Binding objects to controls -

i creating own ui binding system, ties controls associated objects. better using series of if-statements? if add new controls serve new track items, not want update series of if statements every time. timelinetrackcontrol control; type objecttype = track.gettype(); if (objecttype == typeof(shottrack)) { control = new shottrackcontrol(); } else if (objecttype == typeof(audiotrack)) { control = new audiotrackcontrol(); } else if (objecttype == typeof(globalitemtrack)) { control = new globalitemtrackcontrol(); } else { control = new timelinetrackcontrol(); } control.targettrack = track; timelinetrackmap.add(track, control); you could: create dictionary<type, type> contains track types , corresponding control types: private static readonly dictionary<type, type> controltypes = new dictionary<type, type> { { typeof(shottrack), typeof(shottrackcontrol) }, ... }; to corresponding control: control = activator.createinstance(c...