Posts

xml - Android : Parse using xmlpullparser -

i have xml file in location res/xml/data.xml need parse xml file xmlresourceparser xrp=context.getresources().getxml(r.xml.data); i used code file. returns xmlresourceparser tried xmlpullparser xmlpullparserfactory factory = xmlpullparserfactory.newinstance(); factory.setnamespaceaware(true); xmlpullparser xpp = factory.newpullparser(); i not getting clear idea between these 2 parser. question how parse xml file in resource folder using xmlpullparser ? xmlresourceparser interface extends xmlpullparser . getxml wil return xmlresourceparser object. can read parser text similar how parse input stream or string using xmlpullparser here sample code parse resource xml try { xmlresourceparser xmlresourceparser = getresources().getxml(r.xml.data); int eventtype = xmlresourceparser.geteventtype(); while (eventtype != xmlpullparser.end_document) { if (eventtype == xmlpullparser.start_document) { system.out.pr...

unicode - Number of bytes of CString in C++ -

i have unicode string stored in cstring , need know number bytes string takes in utf-8 encoding. know cstring has method getlength() , returns number of charactes, not bytes. i tried (beside other things) converting char array, (logically, guess) array of wchar_t , doesn't solve problem. to clear goal. input lets "aaa" want "3" output (since "a" takes 1 byte in utf-8). input "āaa", i'd see output "4" (since ā 2 byte character). i think has quite common request, after 1,5 hours of search , experimenting, couldn't find correct solution. i have little experience windows programming, maybe left out crucial information. if feel that, please let me know, i'll add information request. use widechartomultibyte output charset cp_utf8 the function return number of bytes written output buffer, or length of utf-8 encoded string lpcstr instr; char outstr[max_outstr_size]; int utf8_len = widechartomultibyte(c...

ruby on rails 4 - Why is db:create making development DB when all other indications are it's in production -

i have strange problem. i have following database.yml production: adapter: postgresql encoding: unicode database: mydb_production # details on connection pooling, see rails configuration guide # http://guides.rubyonrails.org/configuring.html#database-pooling pool: 5 test: adapter: postgresql host: localhost username: password: database: test # or whatever name encoding: utf8 development: adapter: postgresql encoding: unicode database: mydb_development pool: 5 username: dazzaroonie password: my environment.rb has: # load rails application. require file.expand_path('../application', __file__) env['rails_env'] ||= 'production' # initialize rails application. chatrpix::application.initialize! my passenger vhost is: <virtualhost *:80> ... <directory /users/dazzaroonie/sites/newapp/public> allowoverride options -multiviews railsenv production </directory...

php - url error in wordpress site -

i have set wordpress site okay in localhost when upload in server there problem in url. i have checked table wp-options , other table , wp-config files not working. wordpress url uinter.com when use in server shows uinter.com/uinter.com/ . show correct page if url this. need make url appear uinter.com . appreciated. i spending lot of time on , not found solution. me out this.

Rails NoMethodError when converting strings to date from submitted form -

rails 4.0.3. have form date field. in other words, works when use date_select. works on dev machine. when deploy production, form refuses submit , throws nomethoderror upon reaching date, complaining lack of utc method. can't trace because production server's log never tells me more line fails, line model.new(params[:form]) line , failure during type conversion magic. the field text field value supplied jquery ui datepicker, problem exists when plain rails formhelper date_field. gets date, fails... works in dev , i'm deploying production using git, know on same page. locally, i'm working in jruby , using neo4j.rb 2.3 db. have mimicked dev environment running production app server, torquebox, , still local, fails remote. i'm running same version of jruby in both locations , have of gems locked specific versions rule out weird version-specific bug. thoughts appreciated! try code , see if works:- date_string = "#{review_params['date(1i)'...

clojure - Iteratively apply function to its result without generating a seq -

this 1 of "is there built-in/better/idiomatic/clever way this?" questions. i want function--call fn-pow --that apply function f result of applying f argument, apply result of applying result, etc., n times. example, (fn-pow inc 0 3) would equivalent to (inc (inc (inc 0))) it's easy iterate : (defn fn-pow-0 [f x n] (nth (iterate f x) n)) but creates , throws away unnecessary lazy sequence. it's not hard write function scratch. here 1 version: (defn fn-pow-1 [f x n] (if (> n 0) (recur f (f x) (dec n)) x)) i found twice fast fn-pow-0 , using criterium on (fn-pow inc 0 10000000) . i don't consider definition of fn-pow-1 unidiomatic, fn-pow seems might standard built-in function, or there may simple way define couple of higher-order functions in clever arrangement. haven't succeeded in discovering either. missing something? the built-in looking dotimes . i'll tell why in round-about fashion. time ...

javascript - round to 2 decimal places in js invoice -

i have invoice js script done , working, cant figure out how round grand total 2 decimal spaces. js: var item = document.getelementbyid('item'); var item1 = document.getelementbyid('item1'); var item2 = document.getelementbyid('item2'); var item3 = document.getelementbyid('item3'); item.onchange = function() { price.innerhtml = "$" + this.value; qty.value = 1; //order 1 default. add(); }; qty.onchange = function() { add(); } item1.onchange = function() { price1.innerhtml = "$" + this.value; qty1.value = 1; //order 1 default. add(); }; qty1.onchange = function() { add(); } item2.onchange = function() { price2.innerhtml = "$" + this.value; qty2.value = 1; //order 1 default. add(); }; qty2.onchange = function() { add(); } item3.onchange = function () { price3.innerhtml = "$...