Posts

Showing posts from September, 2010

javascript - Why is simplejson encoder for html escaping with \\u0026 instead of & letting an XSS happen? -

i trying automatically html escape strings going json objects. simplejson has jsonencoderforhtml supposed that. how escapes html: chunk = chunk.replace('&', '\\u0026') chunk = chunk.replace('<', '\\u003c') chunk = chunk.replace('>', '\\u003e') 1) why using these codes instead of html encoding cgi.escape uses? which is: chunk = chunk.replace('&', '&amp;') chunk = chunk.replace('<', '&lt;') chunk = chunk.replace('>', '&gt;') each of them state: simplejson: to embed json content in, say, script tag on web page, characters &, < , > should escaped. they cannot escaped usual entities (e.g. &) because not expanded within tags. cgi.escape: replace special characters "&", "<" , ">" html-safe sequences. 2) part in bold mean here? other not understanding differences here, core of problem simpl

vb.net - How to save File info over restart -

ok have application when click "browse" button if open file dialog, in dialog select dll , takes file sends listbox. (openfiledialog1 code:) private sub openfiledialog1_fileok(sender object, e system.componentmodel.canceleventargs) handles openfiledialog1.fileok dim filename string = openfiledialog1.filename.substring(openfiledialog1.filename.lastindexof("\")) dim dllfilename string = filename.replace("\", "") listbox1.items.add(dllfilename) dlls.add(dllfilename, openfiledialog1.filename) dim filehistory string = dllfilename + "|" + openfiledialog1.filename strlist.add(filehistory) ''dim stringtosplit string() = openfiledialog1namedata.split("|") ''dim filenametoassign string = stringtosplit(0) ''dim pathtoassign string = stringtosplit(1) 'msgbox(filenametoassign) 'msgbox(pathtoassign) end sub as can see i'm splitting info , idea create str

html - How to maintain the size of webpage to be same in every browser/full screen? -

i've written html , looks nice in google chrome when on firefox, has white space @ bottom. when go full screen, has white space @ bottom. how can solve problem? thanks. my code: .mainwrapper { margin-left: auto; margin-right: auto; background-image: url(../img/homebg.png); background-repeat: no-repeat; background-attachment: fixed; -webkit-background-size: cover; -moz-background-size: 100% 100%, auto; -o-background-size: 100% 100%, auto; background-size: 100% 100%, auto; height: 100%; margin-top: 0px; margin-bottom: 0px; } body { margin: 0; padding: 0; font-family: kaiti, "arial unicode ms"; font-size: 100%; color: #000; } sometimes helps put height of html , body @ 100% . padding: 0 , margin: 0 should in html , body styles ensure there no unwanted borders. .mainwrapper { background: url(bg.png) no-repeat center center fixed; -webkit-background-size: cover; -moz-b

ruby on rails - unknown action in controller - routes.rb issue? weird results by changing from singular to plural? -

i'm getting strange reaction 'destroy' method. error when trying destroy project: unknown action action '5' not found projectscontroller i figured out when when change routes.rb file resources :projects (plural) resources :project (singular), destroy action works should (and returns index) show method works update , new methods throw undefined method projects_path'` errors. why happening?? class projectscontroller < applicationcontroller def index @projects = project.sorted end def show @project = project.find(params[:id]) end def new @project = project.new @project_count = project.count + 1 end def create # instantiate new object using form parameters @project = project.new(project_params) # save object if @project.save # if save succeeds, redirect index action flash[:notice] = "project created successfully." redirect_to(:action => 'index')

internet explorer - MSPointerDown event is not working in jquery -

i added function in mspointerdown event in jquery. not working @ ie of window tablet. <div id="mytag" style="-ms-touch-action: none;"></div> $('body').on('mspointerdown', '#mytag', function(){alert('hi');}); how can add function work in ie of window tablet.

bash - Automatic triggering of a job -

i want batch script check in share drive file(file name partially fixed) , if file exists, trigger mail , trigger sql job. create simple script tests file , takes desired actions, install crontab crontab -e run @ frequency like. example: #!/bin/bash if test -e "/path/to/filename"; echo "hey, file want: filename -- exists." | \ mail -s "file: filename exists" you@yourhost.com mysql -uuser -hhost -nb -e "your sql command here" fi name filetest.sh , make executable chmod 0755 filetest.sh . install crontab crontab -e . set run whenever every 10 minutes: 0,10,20,30,40,50 * * * * /path/to/filetest.sh save , pretty done.

javascript - difference between named and anonymous callback function in JS -

i wrote following practice code compare differences between named , anonymous callback function, named callback function throws errors, wondering why , what's right way of using named callback function. looking friends = ["john", "mike", "resch", "tony"]; friends.foreach(function(value, index) { console.log('index of ' + index + ', value is: ' + value); }); function iterate(value, index) { console.log('index of ' + index + ', value is: ' + value); } friends.foreach(iterate(value, index)); the last line should be: friends.foreach(iterate); this pass function , iterate , .foreach() can call , provide arguments parameters, value , index . by including additional parenthesis after it, iterate being called , (attempt to) pass foreach() returned value ( undefined default). the errors because value , index don't exist outside of iterate() . for comparison, equivalent of:

java - Querstion regarding hadoop-env.sh -

i facing error: java heap space , error: gc overhead limit exceeded so started looking hadoop-env.sh. so thats understand far, please correct me if wrong. if hadoop_heapsize=7168 in hadoop-env.sh this invoke datanode daemon , tasktracker daemon on datanode 7gb memory assigned each(datanode(7gb)+ tasktracker(7gb) = 14gb) and mapred.tasktracker.reduce.tasks.maximum = 3 mapred.tasktracker.map.tasks.maximum = 6 , mapred.child.java.opts -xmx1024m so invoke 9 child jvms 1gb memory, total of 9gb but tasktracker invoked 7gb memory, wil conflict. max memory tasktracker , child jvms invoked tasktracker 7gb, consuming 9g. so heap space error occured, calculation correct?

Highlight coordinates dygraph -

i generating graph using digraph combined library. there way highlight coordinate points in graph, colourful dots or highlight coordinate points. sure. see custom points option or this question .

how to refresh the list in jquery javascript -

hi m having 1 page 1 textbox named search , 1 search button. when i'm searching first time it's showing me right data when i'm searching other things next time elements listed before appended below of new list. suppose i'm searching state name k give me right list of karnataka, kerala. if start search again g, show me in output goa,gujrat,karnataka kerala. tried using refresh option still not working. js code $.each(response.state, function (i, state) { $('#statelist').append( '<li>' + '<a href="#">' + +'<b>'+ '<font color="green">'+'<h3>'+ state.name +'</h3>'+'</font>' +'</b>'+ '</a>' + '</li>' ); }); $('li img').width(100); $('.ui-li-icon li

Getting Fatal Error Uncaught exception 'Balanced\Errors\Declined' -

when trying debit card visa 4444444444444448 123 processor failure which gives fatal error uncaught exception 'balanced\errors\declined'. so not able catch error or response balanced. is there way capture kind of errors ? yes, wrap code in try/catch , catch exception. you'll able more information out of it.

java - javafx how to get selected data from tableview using FXML -

i working on project want selected data of tableview using fxml. i have codes no-fxml unable use fxml. code: public class person1 { private final stringproperty firstname = new simplestringproperty(""); private final stringproperty surname = new simplestringproperty(""); private final stringproperty goodnameof1 = new simplestringproperty(""); public person1(string firstname) { setfirstname(firstname); } public string getfirstname() { return firstname.get(); } public void setfirstname(string name) { this.firstname.set(name); } public stringproperty firstnameproperty() { return firstname; } public string getsurname() { return surname.get(); } public void setsurname(string name) { surname.set(name); } public stringproperty surnameproperty() { return surname; } public string getgoodnameof1() { return goodname

php - URL Rewrite keeps returning 404 Error -

i've created .htaccess file url rewrite, , tested using http://htaccess.madewithlove.be/ , says url rewrite correct, when testing page keeps giving me 404 error. here .htaccess: rewriteengine on rewritebase / rewritecond %{request_filename} !-f rewriterule ^article/(.*)$ /article/index.php?id=$1 the url rewrite need following: http://www.mydomain.com/article/test // redirect to: http://www.mydomain.com/article/index.php?k=test can tell me messing up? thank you! first, make sure file exists named /article/index.php , give try: rewriteengine on rewritebase / # condition: requested file non-existent rewritecond %{request_filename} !-f rewriterule ^article/(.*)$ /article/index.php?id=$1 [l,r=301]

ssh - Perl SFTP really really slow -

i'm using perl net:ssh2 library sftp. works enough super slow. starts off being 7x slower link speed (something handle) pretty has transferred 2mb of data drops being 1000x slower. here's cut down version of code. used linux command create 10m file of random data dd if=/dev/urandom of=10m.dat bs=1m count=10 . run code please enter details server, user, password etc. #!/usr/bin/perl use strict; use warnings; use fcntl ('o_wronly', 'o_creat'); use net::ssh2; use time::hires qw(gettimeofday); $server = 'myserver'; $username = 'myusername'; $password = 'mypassword'; $remotefile = 'delme.dat'; $localfile = '10m.dat'; $ssh = net::ssh2->new(); $ssh->connect($server) or die('failed connect remote server sftp'); $ssh->auth_password($username, $password); $ssh->auth_ok() or die('invalid username or password'); $sftp = $ssh->sftp() or die('ahhh!!'); open(my $localhandle, '<',

Mistaken duplicate JSON nested object - Rails -

i have rails api returns json using rabl gem. here's /show template extended /index template well. object @deal attributes :headline, :text, :image, :id, :created_at child :vendor attributes :image_url, :id end both deal , vendor have images, uploaded through carrierwave/fog s3. problem i'm seeing here returned json includes , image object deal . so: "deal":{"image":{"image":{"url":"httpxxxxxxxxxxxx"}}} in contrast, json vendor returns appropriately: "vendor":{"image_url":"httpxxxxxxxxxxx"} my uploaders below: class dealuploader < carrierwave::uploader::base def store_dir "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" end end # vendor image uploader class imageuploader < carrierwave::uploader::base def store_dir "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" end end why getting redunda

print same ID for all the elements in text1 and then icrementing the ID and priting for text2. -Python -

i have 2 text files text1.txt , text2.txt. text1.txt contains: sam mat tom text2.txt contains: robbie peter steve i want output like:- sam1 mat1 tom1 robbie2 peter2 steve2 so text1.txt elements, want print same id elements , increment id 1 , print corresponding elements/names in text2.txt shown above. any help? thanks try out: files = ['text1.txt', 'text2.txt'] (id, file) in enumerate(files, start=1): open(file, 'r') f: line in f.xreadlines(): print line.strip() + str(id)

ios - Issue in NSUserDefaults LoginView with UISwitch -

i'm unable store username , password in loginview when enable rememberme switch. here code, kindly me! - (void)viewdidload { if (rememberswitch.on == yes){ self.usernamefield.text = usernamefield.text; self.passwordfield.text = passwordfield.text ; }else{ nslog(@"switch off"); self.usernamefield.text = @""; self.passwordfield.text = @""; } } - (ibaction)remembermetouched:(id)sender { nsuserdefaults *userdefaults = [nsuserdefaults standarduserdefaults]; if (rememberswitch.on == yes) { nsstring *userstring = usernamefield.text; [userdefaults setobject:userstring forkey:@"userstring"]; nsstring *passwordstring = passwordfield.text; [userdefaults setobject:passwordstring forkey:@"passwordstring"]; } [userdefaults setobject:(rememberswitch.on ? @"true" : @"false") forkey:@"isremember&q

ruby on rails - How to group by hourly or 15 minutes using postgres -

i tried group hourly, failed. here query self .where{ name =~ 'memoryinfo' } .where{ sony_alarm_test_id.eq(test_id)} .group("date_part('hour', utc_time )").count the error message d, [2014-06-27t15:34:39.713265 #26124] debug -- : (0.6ms) select count(*) count_all, date_part('hour', utc_time ) date_part_hour_utc_time "sony_alarm_logs" "sony_alarm_logs"."sony_alarm_test_id" = 1 , "sony_alarm_logs"."name" ilike 'memoryinfo' group date_part('hour', utc_time ) order utc_time e, [2014-06-27t15:34:39.713421 #26124] error -- : pg::undefinedfunction: error: function date_part(unknown, double precision) not exist line 1: select count(*) count_all, date_part('hour', utc_time ) a... data +-------+------------+------------------+--------------------+--------------------------------------------------------+ | id | name | utc_time | sony_alarm_t

php - What could possibly be wrong with this query in phpmyadmin? -

this query update `sites_configuration` set `configuration_value`= `value` `configuration_id` = 41 , `sites_id` = 2 limit 0, 30 gives me error #1064 - have error in sql syntax; check manual corresponds mysql server version right syntax use near ' 30' @ line 1 what syntax error referring to? tried putting semicolon or wrapping statement in quotation marks, doesn't work. as can see in mysql documentation can give rowcount in limit not offset. update [low_priority] [ignore] tbl_name set col_name1=expr1 [, col_name2=expr2 ...] [where where_condition] [order ...] [limit row_count] cange query update `sites_configuration` set `configuration_value`= `value` `configuration_id` = 41 , `sites_id` = 2 limit 30

iphone - Facebook messenger in iOS app -

i wanted integrate facebook messenger iphone application. can me integration, tried use https://github.com/quickblox/chattar-ios/blob/master/readme.md but not have steps of integration, pretty complicated. thanks in advance help. i don't understand mean integrating facebook messenger. if looking share content via facebook messenger here code : [fbdialogs presentmessagedialogwithlink:[nsurl urlwithstring:@"https://developers.facebook.com/docs/ios/"] handler:^(fbappcall *call, nsdictionary *results, nserror *error) { if(error) { // error occurred, need handle error // see: https://developers.facebook.com/docs/ios/errors nslog([nsstring stringwithformat:@"error messaging link: %@", error.description]); } else {

jsp - "Sending a redirect is forbidden after the response has been committed" in sendRedirect -

if(insertlen==6) { nextpag="&whichpage=/jsp/dealer/callcentre/careprocess.jsp" redirectpath += actionpath+nextpag; response.sendredirect(redirectpath); return; } else { nextpag="&whichpage=/jsp/dealer/callcentre/complaintfeedback.jsp"; response.sendredirect(redirectpath); } here when execute above, got following error : sending redirect forbidden after response has been committed may know why happening?

How this jquery code will work? -

<a id="page-help" href="page.html" onclick="window.open(this.href, 'popupwindow', 'width=500,height=300'); return false;">what this?</a> $(document).ready(function() { $('#page-help').each(function() { var $link = $(this); var $dialog = $('<div></div>') .load($link.attr('href')) .dialog({ autoopen: false, title: $link.attr('title'), width: 500, height: 300 }); $link.click(function() { $dialog.dialog('open'); return false; }); }); }); please see above code , tell me how works. far knowledge seems when page load jquery dialog created , loaded shown when user click on link. right if yes approach not because if attach way jquery code links in page many jquery dialog load in page content , may slow down page loa

apache - Is Solr complete re-index required when adding new products? -

suppose, have 100 products in db, did indexing , created documents. added 10 more products db. now, should update/add these 10 products existing indexed document? doing is, deleting existing documents , doing indexing. think not proper way. please guide me in this. note: in between not changing in schema.xml , solrconfig.xml just add new / modified documents solr , that's it. there's no need delete entire index 1 update. if document id 1 has field title change foo bar , add document same id field index, keeping unchanged fields old values (for example 'text':'old value' , 'date' : 'old date') , title field set new foo value. solr (or rather solr , lucene) take care of rest.

html - Why is navbar breaking in when i re-size the browser -

i have logo , account name in navbar works fine in desktop , larger devices. moment when re-size tablet or mobile resolution, breaks. <div class="navbar navbar-default navbar-fixed-top" role="navigation"> <div class="container-fluid"> <div class="row"> <div class="col-sm-6 col-md-4 col-xs-6 col-lg-4"> <div class="navbar-header"> <ul class="nav navbar-nav"> <li><a class="navbar-brand" href="#">something</a></li> <li class="divider-vertical"></li> <li><h4 style="margin-top: 15px">acme - new york</h4></li> </ul> </div> </div>

python - Access data from existing table using Flask-Alchemy -

i know mysql , writing queries easy there time when becomes complicated , decided choose orm (sqlalchemy). using flask framework , using flask-sqlalchemy. documentation clear on how build model , insert data , how access model there in database. have database name collection has image table inside it. model.py from flask import flask flask_sqlalchemy import sqlalchemy sqlalchemy import table, column, integer, string, date, float import config # db class app = flask(__name__) app.config['sqlalchemy_database_uri'] = config.db_uri db = sqlalchemy(app) config.py dbhost = 'localhost' dbuser = 'root' dbpass = 'pass' dbname = 'collection' db_uri = 'mysql://' + dbuser + ':' + dbpass + '@' + dbhost + '/' +dbname now access records: model.py data = db.session.execute("select * image;") r in data: print r it print row. writing sql queries directly only. how access existing table data using

html - Bootstrap 3 - How to keep the Nav Collapse Component Open onLoad -

i using bootstrap3 , using collapsible element in design. <!-- search filter --> <div id="search-filter"> <div class="container"> <div class="row"> <div class="col-md-5 col-xs-12"> <!-- collapse search --> <button type="button" class="navbar-toggle navbar-toggle-search-filter" data-toggle="collapse" data-target="#searchbar-collapse-set"> <span class="sr-only">toggle navigation</span> <span class="glyphicon glyphicon-chevron-down"></span> </button> <!-- /collapse search --> <h3>showing 345 results <small>(hill stations around bangalore)</small></h3> </div> <!-- collect nav links, forms, , other content toggling --> <div class="collapse navbar-collapse" id="searchbar-collapse-set">

How to persist Firebase objects to disk in iOS? -

it seems firebase ios implementation doesn't support offline caching of client model. means in practice that: for firebase apps requiring authentication, need first authenticate , wait firebase finish login (check user identity, open socket, etc.) before can start moving data. require 1-8 seconds (usually 2-5) depending on network conditions, @ least here in finland. after authenticating, firebase first downloads initial set of data , initializes client cache. time perform depends on size of data add listeners for, it's quite fast. the problem here if you're using firebase implement, example messaging app, you'd want show user cached version of message threads , messages, before actual connection backend server established. i'd assume correct implementation need handle: the client-side model <-> firebase json mapping (i use mantle this) persisting client-side model disk (manual implementation using nskeyedarchiver, or core data or such?) syn

java - SQL Order String Primary Key -

i wondering how sort sql primary keys varchar composed of 3 parts. generate new key need find largest number current year. mc-#year-#number e.g. mc-2014-1 order in database table: mc-2013-5 mc-2014-1 mc-2014-2 mc-2014-11 something order cast(replace(substring(mc-2014-11,4),'_','') signed) however, linked java programme alo retrieve , sort keys. the maximum number current year select max(cast(substring(code,9) int)) mytable code concat('mc-', year(now()), '%'); but agree others must think locking, if retrieve maximum number way make insert.

Android manifest merger fails for receivers with same name but different content -

i'm having problem manifest merger duplicated receivers content different. use following receivers different api levels, had no issue far until merger. build fails due merger says element receiver#.receivers.updatereceiver duplicated element declared @ androidmanifest.xml:124:9 i don't want create receiver , continue schema. there way disable merger situations or merge receivers in 1 option of enabling action different intent? <receiver android:name=".receivers.updatereceiver" android:enabled="@bool/is_api_below_12"> <intent-filter> <action android:name="android.intent.action.package_replaced" /> <data android:scheme="package" /> </intent-filter> </receiver> <receiver android:name=".receivers.updatereceiver" android:enabled="@bool/is_api_12_and_above"> <intent-filter> <action android:name="android.inte

powershell - What does force do in the Set-AzureDeployment poweshell script -

i unable find documentation force parameter in powershell command set-azuredeployment. set-azuredeployment [-upgrade] [-servicename] [-package] [-configuration] [-slot] [[-mode] ] [[-label] ] [[-rolename] ] [[-force]] [[-extensionconfiguration] ] [ ] has else been able find documentation around this, or have experience of does? looking @ documentation upgrade deployment implemented set-azuredeployment cmdlet, here's found regarding force parameter: indicates whether rollback should proceed when cause local data lost role instances. true if rollback should proceed; otherwise false. the force element available using version 2011-10-01 or higher.

asp.net - .mdf file does not show in VS -

i using vs 2013 express web . using code first paradigm stored data in localdb . file movie.mdf has been created , shows data not appear in app_data folder. refreshed , restarted vs still .mdf files not appear in folder. if want see files generated outside of vs, need either include in project or show files in solution explorer.

ios - Non Consumable and Dynamic in app purchase -

i having issue implementing kind of in-app purchase application demands, need sell story books books , prices not fixed book list comes server. price range fixed i.e book having price 3 prices(0.99$, 1.99$, 2.99$).apple demands purchase of books non-consumable purchase, issue create 3 in-app purchase mentioned there can number of books having price 0.99$ once have purchased book in-app id of price 0.99$, if purchase book same in-app id have purchased item.we want create single in-app id , use them multiple books of same price.please me out solution regarding issue. for non-consumable in-app purchase need create in-app purchase code in itunesconnect each product. can't use generic product code content purchases need restorable (and have problem pointed out of not being able purchase more 1 product @ each price point). each content in-app purchasable item needs submitted apple approval.

ruby - Padrino: how to send form data to app method -

i'm having trouble sending variables form post method sends emails. method receives variable names instead of content. form = form_tag url(:amenities, :email_booking, name: :name, email_addr: :email, message: :message), :method => 'post' = flash_tag(:notice) = field_set_tag %p = text_field_tag :name, :placeholder => "please enter name" %p = text_field_tag :email, :placeholder => "please enter email address", %p = text_area_tag :message, :placeholder => "message" = field_set_tag(:class => 'buttons') = submit_tag 'send message' controller tourapart::app.controllers :amenities post :email_booking, with: [:name, :email_addr, :message] name = params[:name] email_addr = params[:email_addr] message = params[:message] email "bookings@example.com" cc "customer@example.com" email_addr subject "we hope

php - How to install apcu in windows -

how can install apcu in windows? i found this . need solution windows. i use php 5.5.6 (i have xampp package). this short , straight point tutorial should you install apcu on windows assumptions i assume know apc - alternative php cache you want install apcu because apc not compatible anymore php 5.5.x you want install apcu wamp, xampp. windows web development platforms php instructions pre: directory locations might different depending on wamp installation folder , php/apache versions. go http://pecl.php.net/package/apcu , there table available releases choose whatever release suits better (i chose 4.0.5 dll) choose package dll list, depending on windows using (32 bits/64 bits) , php version. in case chose 5.5 thread safe (ts) x86 unzip archive, copy php_apcu.dll in c:\wamp\bin\php\php5.5.12\ext . go c:\wamp\bin\apache\apache2.4.9\bin open php.ini , add following lines (i added them @ end of file): [apcu] extension="c:\wamp\bin\php\php

python - How to display localized time from datetime in django template -

to brief. next_contact utc datetime when write in template {{ event.next_contact }} i localized date , time in place want output time do: {{ event.next_contact.time }} and non localized time how fix it?? use {{ event.next_contact|localtime|date:"h:i" }} . if have set use_tz=true can skip localtime filter. as of django 1.7 when passed datetime value attached timezone information (a time-zone-aware datetime instance) time filter accept timezone-related format specifiers 'e', 'o' , 't' , 'z'.

python - Don't understand the pyqt error -

i apologize in advance if title sounds vague... feel free edit if necessary? in bit of dilemma here used work last time after changing bit of code in main script, ui seems having problem. there 2 scripts here, mmvstool.py (execution script) , mmvstoolui.py (ui interface script) correct me if wrong, using from pyqt4 import qtcore, qtgui importing sentence pyqt widgets , in scripts have been using pyside... when error seems telling me use otherwise? # traceback (most recent call last): # file "<string>", line 1, in <module> # file "/user_data/maya/python/mmvstool.py", line 14, in __init__ # self.setupui( self ) # file "/user_data/maya/python/mmvstoolui.py", line 18, in setupui # mmvsftool.setwindowicon(icon) # typeerror: # 'pyside.qtgui.qwidget.setwindowicon' called wrong argument types: # pyside.qtgui.qwidget.setwindowicon(qicon) # supported signatures: pyside.qtgui.qwidget.setwindowicon(pyside.qtgui.qicon)

javascript - How to replace lots of terms in AJAX-driven page text, and in select attributes -- using a Tampermonkey script? -

i'm translating text inside html document using tree walker affect text nodes: var replacearry = [ [/view user account/gi, 'tu cuenta'], // etc. ]; var numterms = replacearry.length; var txtwalker = document.createtreewalker ( document.body, nodefilter.show_text, { acceptnode: function (node) { //-- skip whitespace-only nodes if (node.nodevalue.trim() ) return nodefilter.filter_accept; return nodefilter.filter_skip; } }, false ); var txtnode = null; while (txtnode = txtwalker.nextnode () ) { var oldtxt = txtnode.nodevalue; (var j = 0; j < numterms; j++) { oldtxt = oldtxt.replace (replacearry[j][0], replacearry[j][1]); } txtnode.nodevalue = oldtxt; } works on static pages (and doesn't bust hyperlinks or event handlers), want also: catch ajax'd-in content replace text in placeholder attributes how do without resorti

How to deserialize JSON array of list elements in Java? -

i have given json: { "facility-no": "2011", "standard-counter": [ { "id": "0", "type": "0", "text": "gebucht", "free": "0", "present": "0", "percent": "100", "max": "0", "status": "frei", "status-value": "0" }, ... ], ... } and want deserialize classes... a wrapper class: public class counters { @jsonproperty("facility-no") private string facilityid; @jsonproperty("standard-counter") private list<xcounter> xcounters; } the class implementing object kept list in wrapper class: public class xcounter { protected string id; @jsonignore public static final countertypeenum type = countertypeenum.x_counter; // standard & level counter pr

php - Laravel Custom Validation Rules -

i studying framework laravel , enjoying it, i'm having little problem in "validator". need make custom rule. searched documentation , in sites on internet , managed so: 1º created folder called "app / validators /" 2º created file called "cpfvalidation.php" inside folder class. 3º in file "app / start / global.php" included line: app_path (). '/ validators' 4 in controller insert code: validator::extend('validacpf', 'cpfvalidation@validacpf'); $validacao = validator::make( array( 'nome_completo' => input::get('nome_completo'), 'cpf' => input::get('cpf'), 'email' => input::get('email'), 'telefone' => input::get('telefone'), 'logradouro' => input::get('logradouro'), 'estado' => input::get('estado') ),

java - Android SDK Manager MacOS Could Not Select Items For Install -

i install android sdk mac development. open android sdk manager , want install several items list shown in program. when list of sdk shown , want select items click item or checkbox in front of item, cannot select no errors show. moment cannot install anything. my mac in osx 10.9.3 , java version jdk 1.7.0_25. try both eclipse + adt , android studio 0.8. in fact encountered problem several months ago , several version of adt. i'm not sure because of java version or else. have same problem similar me? thanks, wilson actually found problem few weeks ago. found did not set java_home environment variable in mac. after set java_home environment variable, problem not appear again. may check if java_home set or not , try again after changed. wilson

ruby on rails - How to write a gem? Preparing with 'lib' directory -

Image
can explain few moments? want create gem, me, self-study. for this, write gem`s code in 'lib' folder, can test in app. for now, have next questions: how can extend 'views'? want create separate layout. how can extend controllers? example - applications controller, want extend few methods. for extended user model, this: #app/models/user.rb class user < activerecord::base require 'auth' ... #lib/auth.rb class user require 'digest' before_save :encrypt_password def xxx .... is right way? for now, need extend application controller , add application layout, not know how. you can check out gem made if like -- gems rails gems zip-files rails app when "install" rails gem, gem files inside gem put rails application. take our gem example: the folders marked in red inserted rails application when install gem. can't see them, they'll there engine it's opinion majority of rails g

ios - How to add "See all" button in table view cell -

how add "see >" button right of title in uitableviewcell in app store app? http://i.stack.imgur.com/kj5tx.jpg you can add button (and header title) custom uiview , add table header (using -[uitableview tableheaderview]

mysql - Group by Where(field.id is the same) -

table header x---id---x---short_name---------x | 1 | alcatel | | 2 | nexus | | 3 | zte | x--------x----------------------x table detail x---id---x---------code---------x---header.id---x | 1 | xxx | 1 | | 2 | zzz | 2 | | 3 | zzz | 2 | | 4 | xxx | 3 | x--------x----------------------x---------------x and need group code field.id same, example: in case 2 rows same field.id need group field code in case if field.id same.. (very hard me explain...) i need x---header.id---x--detail.id--x-----short_name----x---detail.code---x | 1 | 1 | alcatel | xxx | | 2 | 3 | nexus | zzz | | 3 | 4 | zte | xxx | x---------------x-------------x------------------x-----

java - How to properly perform HttpPost on onPageFinished in Android -

in app have webview. if webview loads, want perform httppost fetch variable script. keep getting exception errors, tell me need perform httppost in asynctask . don't know how this, since i'm enough in android developing yet. this httppost wrote: httpclient httpclient = new defaulthttpclient(); httppost httppost = new; httppost("myscript.php"); try { // add data list<namevaluepair> namevaluepairs = new arraylist<namevaluepair>(2); namevaluepairs.add(new basicnamevaluepair("website", "google.com")); httppost.setentity(new urlencodedformentity(namevaluepairs)); // execute http post request httpresponse response = httpclient.execute(httppost); // writing response log log.d("http response:", response.tostring()); } catch (clientprotocolexception e) { // todo auto-generated catch block } catch (ioexception e) { // todo auto-generate

Gitolite update copy at server when push -

in gitolite i've set new repository on server , able clone machine. it's web project need latest working copy @ /var/www/my-project, every push made developer update files there. how can achieve that? thanks the repos managed gitolite managed in ~/repositories you can add own hook in ~/repositories/yourrepo.git/hooks called post-receive hook in order checkout, on each push, index working tree of choice (like /var/www/my-project ) see instance " how process files on branch in post-receive hook in git " (which can check branch pushed). the checkout uses: git checkout --work-tree=/var/www/my-project

using javascript in selenium javascript executor -

i want verify if required text appearing on page. cant use selenium webdriver's gettext() method throwing permission exception. using javascript compare text. string scripttoexec = "var result = document.getelementsbyclassname('sender'); for(var element in result){ if (element.text.contains('mytext')) {return true;} else {return false;}}"; javascriptexecutor js = (javascriptexecutor) driver; boolean result = (boolean) (js.executescript(scripttoexec)); i getting exception: org.openqa.selenium.remote. errorhandler $unknownserverexception: element.text undefined many javascript issues here severe lack of understanding selectors. contains isn't part of standard , won't work older browsers: https://developer.mozilla.org/en-us/docs/web/javascript/reference/global_objects/string/contains if there element.text undefined whatever reason, you'll need cope that: if (element && el

selenium - Windows 8/Windows Phone 8 app submission automation -

i want automate process of app submission (both windows 8 , windows phone 8 apps). exact, want automate steps logging in, filling forms app out, , on. there software/script thingies, provide such functionality (first straightforward thing comes mind selenium automation, searching specific software)? unfortunately, seems you'll have wait promised windows store unification have features shown in post: http://blogs.msdn.com/b/windowsstore/archive/2012/02/13/submitting-your-windows-8-apps.aspx

.net - Azure continuous deployment clear dlls -

after updating latest version of devexpress dll files got name changed somename.13.2.dll somename.14.1.dll. included latest in project when deploy, old still in bin folder on azure. there way can modify build definition deletes unnecessary files? tried setting allow upgrade false did not help.

php - How do I validate multiple models with Yii? -

i using following code save , validate booking , bookingroom(link table) models, can validate 1 @ time. have had success in following saves , populates database, validation occurs in sequence. $booking->save(); $bookingroom->save(); how validate , save multiple models? you should call validate() method model, example bellow: // populate input data $a , $b $a->attributes=$_post['a']; $b->attributes=$_post['b']; // validate both $a , $b $valid=$a->validate(); $valid=$b->validate() && $valid; if($valid) { // use false parameter disable validation $a->save(false); $b->save(false); // ...redirect page } see link more information.

jquery slidetoggle where show/hide links are different -

here code i'm using (found elsewhere on site) pretty straight-forward slidetoggle. <script> $(document).ready(function () { $(".slidingdiv").hide(); $('.show_hide').click(function (e) { $(".slidingdiv").slidetoggle("fast"); e.preventdefault(); }); }); </script> html: <div class="section-hold"> <h4>section</h4> <p><a href="#" class="show_hide">find out more >></a></p> </div> <div class="slidingdiv"> <h4>my content.</p> </div> what though when click show slidingdiv, "find out more" link disappears , toggle hide slidingdiv content different link, contained within div itself. html become this: <div class="section-hold"> <h4>section</h4> <p><a href="#" cla

xml - Configure log4j to log filenames without .java filetype -

i log class names (excluding package prefix) methods in following way: <classname>.<methodname> currently xml layout <layout class="org.apache.log4j.patternlayout"> <param name="conversionpattern" value="%d %5p [%t] (%f.%m) - %m%n" /> </layout> which returns filename includes .java file type. is there way configure log4j remove .java filename? if want class name, should consider %c conversion character, described in javadoc patternlayout . for instance, specify unqualified class name: <layout class="org.apache.log4j.patternlayout"> <param name="conversionpattern" value="%d %5p [%t] (%c{1}.%m) - %m%n" /> </layout> note usage of {1} qualifier, designates first rightmost component of qualified class name.

c++ - Rcpp: error occured building shared library -

i have cpp code in file named psm.cpp given below, #include <rcpp.h> // [[rcpp::export]] std::vector<std::string> useinitlists() { std::vector<std::string> vec = {"larry", "curly", "moe"}; return vec; } when source following code, following error. > rcpp::sourcecpp("psm.cpp") g++ -m64 -i"c:/progra~1/r/r-30~1.2/include" -dndebug -i"c:/users/30708/documents/r/win-library/3.0/rcpp/include" -i"d:/rcompile/cranpkg/extralibs64/local/include" -o2 -wall -mtune=core2 -c psm.cpp -o psm.o psm.cpp: in function 'std::vector<std::basic_string<char> > useinitlists()': psm.cpp:5:60: error: in c++98 'vec' must initialized constructor, not '{...}' psm.cpp:5:60: error: not convert '{"larry", "curly", "moe"}' '<brace-enclosed initializer list>' 'std::vector<std::basic_string<char> >

php - Pass parameter to form action in HTML -

This summary is not available. Please click here to view the post.

php - Authenticate Laravel user without Laravel tools - connecting 2 programs -

in project have company cms resides in public folder. has it's own users , stuff creating pages , other sorts of web items. now have hook laravel users table in cms, fine. except can't verify user seeing laravel takes care of somewhere(!) in framework. , seeing cms large piece of coding has been around @ least 10 years i'm not going put in routes, models , controllers. so simple solution verify user password/username. cannot find reference user verification outside of laravel. so, question is: how can verify user table users, has been created laravel, against username/login program not loading laravel. all need check if username , password match, using bcrypt password hashing. so semi pseudocode (since dont know functions cms provides) $username = $_post['username']; // user record table $user = $db->find->user($username); if (password_verify($_post['password'], $user->password)) { // login user } else { // wrong p

javascript - Enable spellcheck on all page text -

is there way enable spellcheck on page text ? i mean, if text not editable ? i made search , found way desactivate on editable text. no way activate on non-editable text... i seen if activate contenteditable, click on contenteditable div, , go out, underlined text stay underlined (even if delete contenteditable attribute (with js) ). thank you after typing "spellcheck html" in google found : the spellcheck attribute specifies whether element have spelling , grammar checked or not. the following can spellchecked: text values in input elements (not password) text in < textarea > elements text in editable elements conclusion : can't apply spellcheck on div s

adb - Android Wear Preview not connecting to Wear Emulator -

Image
i trying setup development environment google wear , have followed google's instructions setup port forwarding ( adb -d forward tcp:5601 tcp:5601 ) getting error on device; connection closed, waiting before trying again i have emulator running on pc , android device nexus 4, 4.4.4. if you've updated everything, , have new emulator, might need android wear (not android wear preview). follow these steps: http://developer.android.com/preview/google-play-services-wear.html you may have done recently, google play services 5.0, , android wear out (unofficially) it's worth trying again latest updates. or , may need click emulator button in screenshot, let app know you're connecting emulator.

c# - Stream was not readable is caused when use readbinary -

i trying send value socket .so have 2 parts in project client , server . the client sends value server using code : networkstream networkstream = socketforserver.getstream(); system.io.binarywriter binarywriter = new system.io.binarywriter(networkstream); //------ int messagesource = 0; int messagedesitination = 0; int interlockingid = 0; int trackid = 0; int trainid = 2; int direction = 0; int messagetype = 0; int informationtype = 0; int datetime = 0; foreach (sensor leftsensorlist in leftsensor) { binarywriter.write(messagesource); binarywriter.write(messagedesitination); binarywriter.write(interlockingid); binarywriter.write(trackid); binarywriter.write(trainid); binarywriter.write(direction