Posts

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: ...