Posts

Showing posts from August, 2011

javascript - Filling two textbox with the same functions in php -

i need fill code , initials of employment same javascript functions. java script function <script type="text/javascript"> function expedisi(t) { var y = document.getelementbyid("code"); y.value = t.value; } </script> <tr> <td width="200px" align="right"><label for=""><font color="0099ff"size="3px">code</font><span></span></label></td> <td align="left"><input type="text" id="code" name="code" value=" <?php echo ($addflag == 0) ? $get['loan'] : ""; ?>" class="form-input-code" readonly /> </tr> <tr> <td width="200px" align="right"><label for=""><font color="0099ff" size="3px">employee name </font><span></span></label>

iphone - Change UIButton background images randomly -

i want change background image of uibutton randomly. have images (5) want switch between randomly background images uibutton . how can implement this? please me out problem. how nsinteger randomnumber = arc4random_uniform(5); // random number, either 0,1,2,3 or 4 uiimage *randomimage = [uiimage imagenamed:[nsstring stringwithformat:@"img%u.png",randomnumber]]; //uibutton *mybutton; [mybutton setbackgroundimage:randomimage forstate:uicontrolstatenormal]; alternate solution perhaps easier understand nsinteger randomnumber = arc4random_uniform(5); // random number, either 0,1,2,3 or 4 uiimage *randomimage; switch (randomnumber) { case 0: randomimage = [uiimage imagenamed:@"img0.png"]; break; case 1: randomimage = [uiimage imagenamed:@"img1.png"]; break; case 2: randomimage = [uiimage imagenamed:@"img2.png"]; break; case 3: randomimage = [uiimage imagenam

java - Only take URL Part from String -

i want url string can show url in webview . example strings: exp 1- hello dilip refer url www.google.com. exp 2- hi ramesh android http://android.com i want www.google.com , http://android.com how can split them out of string assuming string below can use regex below extract www.google.com , http://android.com . string s = "hello dilip refer url www.google.com. hi ramesh android http://android.com"; pattern pc = pattern.compile("((http://)|(www.))[a-z,a-z]+.com"); matcher matcher = pc.matcher(s); while(matcher.find()) { system.out.println("string extracted "+matcher.group()); } output string extracted www.google.com string extracted http://android.com note: above not work these kind of urls http://meta.stackoverflow.com ,www.google.co.uk , b3ta.com. edit: string s = "hello dilip refer www.google.co.uk www.google.co.in url www.google.com. hi ramesh android http://android.com hello there meta.stack

slideshow - js.cycle.js and jquery.js conflict -

i new javascript , jquery. want design website contains both accordion navigation , slideshow on same page. in order this, downloaded auto scrolling slideshow plugin htmldrive.net: http://www.htmldrive.net/items/show/110/auto-scrolling-slideshow-tabs-jquery- (this plugin links "ajax.googleapis" remotely. makes use of "jquery.cycle.js" plugin, , main javascript located in "slideshow.js".) and accordion plugin, htmldrive.net: the other plugin on htmldrive. it's called "making-accordions-with-the-tabsjquery (i can't supply 2nd link in post dont have reputation of 10 haha) (this plugin makes use of jquery.js plugin. has inline javascript in html) i have managed these 2 plugins working on separate pages, problem running seem cause conflicts when both put on same page. conflict seems come linking jquery.js , jquery.cycle.js files same page. interestingly, changing order in link them gives different errors. the errors when linking

mysql - Why is my union of two queries not ordering correctly? -

(select `size`, `type` `table` `type`='a' order `size` asc) union (select `size`,`type` `table` `type`='b' order `size` desc) why isn't query working hope? separates result array types 'a' , types 'b', within type 'a' results, not ordered size (size positive bigint). any suggestions? :) the results of query not ordered, unless use order by clause (or in mysql group by clause). try want: (select `size`, `type` `table` `type`='a') union (select `size`,`type` `table` `type`='b') order type, (case when `type` = 'a' size end) asc, (case when `type` = 'b' size end) desc; ordering clauses on subqueries ignored (the exception when have limit ). and, when not ignored may have not effect on outer query. actually, forget union all entirely: select size, `type` table type in ('a', 'b') order type, (case when `type` = 'a' size end) asc,

ctags - creating tags for a script language for easy browsing in vim -

i use ctags+vim lot of projects , ability browse through large chunks of code quickly. i using stata, statistical package, has script language. though can have routines in code, code tends series of commands perform data , statistics operations. , code files can long. find myself in need of way browse efficiently. since use vim, can use marks. wondering if use ctags this. is, want create tag marker (1) won't cause problem when run script (2) easy introduce ctags. because supposed not break script, needs comment. in stata, comment lines start * , flow comments can made /* ..... */ . it great, example, have sections in code, marked comments: * section: data and ctags picks "data manipulation" tag. can see list of sections , jump them without needs creating marks. is there anyway this? i'd appreciate comments. you need way generate tags database stata files. format simple, see :help tags-file-format . default tags program, exuberant ctags can

matlab - How to create two or more matrices from a single one under certain conditions? -

hello new in matlab , cannot figure out how solve problem. i have matrix1: 1 0 2 334.456 3 654.7654 4 65.76543 1 0 2 543.43567 3 98.432 4 54.9876 5 12.456 and matrix2: 1 2 2 3 3 4 1 2 2 3 3 4 4 5 matrix2 represents links found in matrix1 in order appear. i separate links in blocks (matrices) each block starts stop 1. analysing matrix2 should produce 2 new matrices 1 links (1,2)(2,3)(3,4) , other links (1,2)(2,3)(3,4)(4,5). each time find stop 1, starts building new matrix. a , b come out as: a= [1,2, 334.456; 2,3,654.7654;3,4,65.76543] b=[1,2,543.43567;2,3,98.432;3,4,54.9876;4,5,12.456] i think want. matrices cell array containing amount of distinct matrices required (based on amount of 1's in column 1 of matrix2). matrix1=[1 0; 2 334.456;3 654.7654;4 65.76543;1 0;2 543.43567;3 98.432;4 54.9876;5 12.456]; matrix2=[1 2; 2 3; 3 4; 1 2; 2 3; 3 4; 4 5]; rows=find(matrix2(:,1)==1); % find

ruby - rails security: converting parameters to symbols for hash lookup -

i have hash of constants refer throughout code like: categories = { business: '1002', education: '1003', entertainment: '1004', # etc... } in 1 of controllers need test existing of category via parameter, i'd like: categories.has_key? params[:category].to_sym however seems invitation denial of service attack, attacker blow ruby symbol table providing random strings category params. seems easiest solution convert category keys strings rather symbols: categories = { 'business' => '1002', 'education' => '1003', 'entertainment' => '1004', # etc... } or perhaps: def self.valid_category(category_s) categories.keys.any? { |key| key.to_s == category_s } end is there better or more idiomatic way in rails? is there better or more idiomatic way in rails? the common approach i've seen second solution provided, i.e.: def self.valid_category(categ

jsf 2 - How to call to get the source page which requets another JSF page -

i want know how name of page requests jsf page further call specific methods in bean according source page, don't want use <f:event type="prerenderview" listener="#{beanname.prerender}" /> because specified page has components that's rendered according source page as far know has handcoded , best way in @webfilter . , request.getrequesturi(); then save pages in suitible fashion example arraydeque . the arraydeque example saved in @sessionscoped bean.

indexing - Rails: Sunspot and Will_Paginate Issue -

i've hit snag college project regarding use of sunspot search gem , will_paginate. i've been using sunspot in project index controller , working fine when added pagination same index created problem. cant seem have both search , pagination @ same time. this gives me pagination (see below): def index @projects = project.all @projects = project.paginate :per_page => 4, :page => params[:page] respond_to |format| format.html # index.html.erb format.json { render json: @projects } end end this gives me search index (see below): def index @projects = project.all @search = project.search fulltext params[:search] end @projects = @search.results respond_to |format| format.html # index.html.erb format.json { render json: @projects } end end but when add pagination doesn't work/display (see below): def index @projects = project.paginate :per_page => 4, :page => params[:page] @search = project.search fulltext params[:search] end @projec

gpgpu - Count the number of cycles in a CUDA kernel -

how can count number of cycles performed function following. should count straight forward number of sums , muls , divs? can check how many cycles addition takes in cuda? __global__ void mandelbrotset_per_element(grayscale *image){ float minr = -2.0f, maxr = 1.0f; float mini = -1.2f, maxi = mini + (maxr-minr) * c_rows / c_cols; float realfactor = (maxr - minr) / (c_cols-1); float imagfactor = (maxi - mini) / (c_rows-1); bool isinset; float c_real, c_imag, z_real, z_imag; int y = blockdim.y * blockidx.y + threadidx.y; int x = blockdim.x * blockidx.x + threadidx.x; while (y < c_rows){ while (x < c_cols) { c_real = minr + x * realfactor; c_imag = maxi - y * imagfactor; z_real = c_real; z_imag = c_imag; isinset = true; (int k = 0; k < c_iterations; k++){ float z_real2 = z_real * z_real; float z_imag2 = z_imag * z_imag;

multithreading - How to create iterative boost threads? -

i working boost threads library in c++ , want create different threads process buckets of data. firstly, load data smaller buckets (100 elements each) , assign each bucket thread. available threads four, avoid create new threads until there free new thread. pseudocode follows: while(pool1->has_next()){ int tmp = pool->get_next(); pool2->pushback(tmp); if(pool2->size()%100==0){ while(working_threads>=4){ wait(); } new thread (proc(pool2)); } pool2->clear(); } how can done boost threads? sounds want thread pool or thread group, have example of on github: git@github.com:cdesjardins/jobbatcher.git

wpf - Command to trigger a mousewheel event -

i doing research of kinect browse pictures. my application has ability change pictures sending command system.windows.forms.sendkeys.sendwait("{right}") . enlarge picture, want trigger mousewheel event. how write code {system.windows.forms.sendkeys.sendwait("{right}"); } right key? method appreciated.

paypal - Using a hosted button with quantities for options -

i use paypal in conjunction web form selling conference tickets. tickets available in various types , prices - standard, student, couple. i users able select variety of tickets in 1 transaction - example, 2 standard tickets , 1 student ticket. ideally have paypal manage inventory people can't make payments when tickets have run out. limit on tickets on total; numbers within categories don't matter. i can set ticket item on paypal , limit appropriate number, , can set option prices. can't work out how send request paypal more 1 "option + quantity" pair selected. any gratefully received! you not able send more 1 option + quantity pair on paypal standard add cart or buy buttons , have paypal keep track of inventory. best options either set inventory on paypal side, , use add cart buttons each option + quantity. another option use cart upload method, pass on item details during checkout. similar 3rd party carts do. keep track of buyer ad

javascript - Ember: transition to route passing the ID instead of obj -

i have route /ads/:ad_id , controller can do this.transitiontoroute('ads.ad', adobj) how can similar thing time passing id instead of loaded object? o course understand can load obj id first, ember's power in doing lost of boilerplate us. update : so, default ember serializes model url params doing like mode_instance -> { model_name_id: model_instance.id } my trivial attempt doing this.transitiontoroute('ads.ad', { id: adobjid }) but when passed model object ember not re-fetch it. so, question: have route (single ad view) depends on ad id. have id number. want transition route if entered url /ads/id what's use case this? cases when want specify object id, have object pass transitionto . can provide more context you're trying do? think can accomplish without using object id. in case, don't think there's way this, because when transition via transitionto(someroute, somemodel) , route's model hook not called, , m

php - PDO stop execution of transaction on duplicate PK -

i inserting data table this: $queryupdateposts = "update posts set likes = likes + 1 id = $id"; error_log('user: '.$_session['userid'].' post '.$id); $userid = $_session['userid']; $queryinsertuserlike = "insert likes (user_id, post_id) values ($userid, $id)"; try { $db -> begintransaction(); $statement1 = $db -> prepare($queryinsertuserlike); $statement1 -> execute(); $statement2 = $db -> prepare($queryupdateposts); $statement2 -> execute(); $row = $statement -> fetch(); $db -> commit(); } catch (exception $e) { $db -> rollback(); } in "likes" table, user_id , post_id defined primary-key this alter table likes add primary key (`post_id`, `user_id`) now want statement behave is, quit execution when $statement1 fails because of pk. i hope it's clear want , can help. thanks! i going quote on - " want statement behave is, quit executio

playframework - Play Framework: Page cannot be resolved -

im trying use method routing in controller class public static result show(string page) { string content = **page**.getcontentof(page); response().setcontenttype("text/html"); return ok(content); } but im getting import error ,page cannot resolved tried each import , got error which api need import?? im using link referance javarouting i accidentaly discovered, copied part of documentation , right ? :) this sample, hypothetical case usage of method getcontntentof(string page) class page doesn't exist default in play. can simplify sample (for learning purposes) to: public static result show(string page) { return ok(page); } or, better put real logic there.

command line - How to send email with attachment on OpenWRT? -

i have installed openwrt on ruter msmtp package. i'm able send regular email can't figure out how add attachment. i've searched google , seems should use uuencode can't find proper package. the questions are: does uuencode or it's substitute exists openwrt? if not then: how send email attachment on openwrt without uuencode? you can use mutt. here example how send email attachment: echo "this message body" | mutt -a "/path/to/file.to.attach" -s "subject of message" -- recipient@domain.com as of openwrt attitude adjustment 12.09 mutt package available.

arrays - what is the correct string terminator in c -

as know string terminating character in c '\0'. can use '0' terminating character too? when assign 0 specific index in char array, , use printf, prints upto specific index. hence, both ways equivalent? null character equal literal 0? the value can used null terminator numerical value 0. 0 is numerical value 0. '\0' is also way of representing numerical value 0 in code '0' is not numerical value 0 (it's digit zero) , cannot used terminator. all strings literals implicitly contain null terminator after last visible character. in other cases, may or may not there automatically (depending on how string constructed), have sure in every case null terminator there.

java - Automatically instantiate Objects and set Value for a given Path -

i want set values given path string in nested java object structure. if collction property dosen't exists property should automatically instantiated: public class { list<b> bs; // getter/setter } public class b { string b1; string b2; // getter/setter } public object setvalueforpath(string path, object value){ // magic starts // set value path // automatically instantiate objects if nessesary } result = setvalueforpath("bs[0].b1", "test") // return full object structure assertequal(result.getbbs().get(0).getb1(), "test"); how can solve problem? you can use ognl's sequence operator , accomplish this, make ognl expression bit more difficult read. a = new a() ognl.setvalue("bs.add(0, new com.full.qualified.package.b()), bs[0].b1" a, "test") assertequals("test", a.getbbs().get(0).getb1())

browser - Play a loaded file in javascript -

i'm trying load file user , want play javascript. the file loaded correctly, , can access seeing name, type , on, filelist api. what can't play obtained file. tried do myfile.play(); like loaded file, doesn't work. any idea? if want play media content, instead of using filereader, suggest use createobjecturl method. more efficient since not create string containing file content. https://developer.mozilla.org/fr/docs/dom/window.url.createobjecturl just : audio/video.src=window.url.createobjecturl(myfile); don"t forget revoke uri when loading media file avoid memory leaks : window.url.revokeobjecturl(audio/video.src);

garbage collection - Python: find which objects are marked for deletion by gc? -

let's following output gc.get_count() gc.get_count() (2, 1, 0) what want know these 3 objects gc.get_count() counting? can id? name? size etc.? (i know threshold value , 3 stage collection in python). you can use gc.get_objects() instead. see python garbage collector interface documentation.

firefox - Automated form fill script from server -

is there extension browser automatically perform tasks (like autoit udfs or selenium) works this: set link script form server , task performed automatically? you can try imacros firefox or chrome . see download page desktop version , ie browser.

3 divs -- two are changed by one hover css -

i have 3 divs in order 1 - 2 - 3 i want change background of 1 & 3 when hover on 2 (using css) so far div 3 change use classes style them on hover in css. example: <div class="one"> first </div> <div class="two"> second </div> <div class="three"> third </div> .one:hover, .three:hover { background: pink; }

JavaScript Animations: value of changed property after animation? -

i have javascript code slides div left right changing 'left' css property when mouse clicked on div. code working fine. initially, div's 'left = 0' suppose want slide div random number. like. function move(){ var final = math.random()*100 //lets suppose final gets value equal 145 in case ....code sliding goes here } so, div's left should equal 145px now. now, when click on div again, happen: function move(){ var final = math.random()*100 //lets suppose final gets value equal 30 in case ....code sliding goes here } now, shouldn't div slide 145px 30 px? because when clicked on div first time left became 145 px , no longer remains 0. in case happens when click on again, first goes 0 px , moves 30px. this sounds lot easier transition: css: .moving_element {transition:all 0.4s ease; -webkit-transition:all 0.4s ease;} (replace class needed code) js: elem.style.left = math.random()*100+"px"; that's need.

rebase - In Mercurial, how to combine unrelated repositories, leaving only one root? -

i have 4 versions of project. versions 1-3 "prototypes" not under source control (they exist separate directories in filesystem). version 4 has been under source control since inception , has long history of commits. i want combine these versions 1-3 become individual changesets each 1 descendant of previous. root of version 4 should become descendant of version 3 (and no collapsing of version 4's history of course). all changes private, not public (there no problem rewriting history, were). what i've done far , tried: 1. setup new hg repositories in directory of prototype versions 2. cloned repository of version 4 3. pulled (with hg pull --force ) unrelated repositories versions 1-3 cloned repository. this gives me 4 unrelated "roots" (changesets no ancestors) in single repository. when combine them don't want remember these 4 roots. hg rebase should let me move changesets , destroy originals, unlike hg merge . here i'll

java - importing final fields using interface (RIGHT/WRONG) -

this question has answer here: what use of interface constants? 7 answers recently saw in somebody's code implements final class variable fields inside interface ex: public interface commentschema{ static final string db_table_name = "comment"; ... } & had implemented class need these variables this: public class dbcomment implements commentschema { // use db_table_name value here ... ... } as know if make instance of dbcomment class because of inheritance aspect, he's gonna able access db_table_name not proper because want use values inside dbcomment methods. now have several questions: 1) implementation proper & ok ? 2) if it's not, how have declare these variables outside of dbcomment class & make class class see these values. (we don't want use abstract class coz class can extends 1 other class in java)

Automatically create pages in phpfox -

i have array of information of places , wanna use them create multiple pages in phpfox site. first tried manually insert data in phpfox database (in tables of phpfox_pages , phpfox_pages_text ). the page shown in site when opening it's link, site says: the page looking cannot found. do know other tables should manipulate make work? or know plugin phpfox same? thanks, solved ( @purefan guide): "pages" has user if take @ phpfox_user table, you'll found out how fetch new records on that. there 2 ambiguous fields in table ( password & password_salt ). can use script create values fields: <?php function generaterandomstring() { $length = 164; $characters = '-_0123456789abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz'; $randomstring = ''; ($i = 0; $i < $length; $i++) { $randomstring .= $characters[rand(0, strlen($characters) - 1)]; } return $randomstring; } $ssalt = '';

node.js - How to run TopoJSON? -

i need convert geojson file topojson , possibly simplify topojson file. i've managed install node.js , topojson package. have no idea how run topojson. the wiki lists bunch of command line options, run commands? i've tried running them both in command prompt , node shell. node, gdal, ogr2ogr , topojson new concepts me, i'm bit confused , overwhelmed. i'm running on windows way. this should work fine on windows too install nodejs http://nodejs.org/ install npm https://npmjs.org/doc/readme.html run npm install -g topojson in command prompt use command prompt cd geojson file run topojson -o mynewtopojsonfile.json myoldgeojsonfile.json origin https://gis.stackexchange.com/questions/45138/convert-geojson-to-topojson

casperjs - Setting paperSize for PDF printing in Casper -

in generating pdfs in phantom, can set paper size this: page.papersize = { height: '8.5in', width: '11in', orientation: 'landscape', border: '0.4in' }; then page.render(output) function generates pdf properly. in other words, size correct , has many pages of size. i can't work in casper (and i'm not sure if supported). example, following: var casper = require('casper').create({ papersize: { height: '8.5in', width: '11in', orientation: 'landscape', border: '0.4in' }, loglevel: 'debug', verbose: true }); ....this.capture('print.pdf'); ... creates pdf single, long page. setting viewportsize not fix problem. is there way access pagesize object within casperjs? you can access papersize through casper.page.papersize , need set after calling casper.start() , otherwise casper.page equal null. here's example: var cas

nullpointerexception - Spring managed object always null. wicket framework -

today have had infuriating problem follows: i have wicket based application using spring manage objects connecting application database, in past has worked fine me. i using inbuilt jetty server in eclipse run application , note when put breakpoint in datasource method in class populating, @ startup setter seems called , datasource object has data want. however when go use object spring has injected values it's datasource object comes null object. a code snippet follows: declaring class be managed spring: public class homepage extends webpage { @springbean(name = "userimpl") private userimpl userimp; /** * */ where calling object: protected void onsubmit() { super.onsubmit(); try { person returneduser = userimp.finduser(model.getusername(), model.getpassword()); setresponsepage(studentpage.class); returneduser.getemail(); } catch (except

apache - configure URL access control for domains using .htaccess or other methods -

i having scenario following: for example,i have website http://www.mywebsite.com , , have setup subdomain http://image.mywebsite.com . in apache virtual host setting, using same folder (e.g. /home/mywebsite/). (these 2 domains have different bandwidth setup using mod_cband). i have subfolders "/home/mywebsite/files/images", want make accessible subdomain " http://image.mywebsite.com/files/images/ ..." not " http://www.mywebsite.com/files/images/ ..." how shall configure .htaccess file or other equivalent methods? thanks guys since use same directory way can via rewriterule main domain. put in file called .htaccess in root of website. options +followsymlinks -multiviews rewriteengine on # if request www.example.com ... rewritecond %{http_host} ^www\.example\.com$ [nc] # ... , url starts files/images, deny access ([f] = forbidden) rewriterule ^files/images - [f]

PHP inside JavaScript -

i have 1 line of javascript i'd appreciate with. req.open("get", 'update.php?id=<?php $id ?>', true); where $id = 12345, trying contents of update.php?id=12345. using php inside javascript doesn't seem working me. any suggestions? first, make sure inside php file, or have server configured process whatever file extension using php. then, can echo data directly javascript. best compatibility , avoid potential xss vulnerabilities, json-encode data. req.open('get', 'update.php?id=' + <?php echo json_encode($id); ?>, true); personally, prefer have block of variables assigned on php. keeps javascript cleaner. <?php $options = new stdclass(); $options->id = 12345; $options->dinnerselection = 'pizza'; echo 'var options = ', json_encode($options), ';' ?> // later on in js... req.open('get', 'update.php?id=' + options.id, true);

r - Using ggplot2, connect x- and y-coordinates by a third variable -

i plot latitude vs longitude , connect points via date , time, have stored in object of class posixlt. have many, many gps points, here small set of them plot using ggplot2. my data so: description lat lon 6/16/2012 17:22 12.117017 -89.69692 6/17/2012 9:15 12.1178 -89.69675 6/17/2012 9:33 12.117783 -89.69673 6/17/2012 10:19 12.11785 -89.69665 6/17/2012 10:45 12.11775 -89.69677 6/17/2012 11:22 12.1178 -89.69673 6/17/2012 11:39 12.117817 -89.69662 6/17/2012 11:59 12.117717 -89.69677 6/17/2012 12:10 12.117717 -89.69655 6/16/2012 16:38 12.11795 -89.6965 6/16/2012 18:29 12.1178 -89.69688 6/16/2012 17:11 12.117417 -89.69703 6/16/2012 17:36 12.116967 -89.69668 6/16/2012 17:50 12.117217 -89.69695 6/16/2012 18:02 12.117583 -89.69715 6/16/2012 18:15 12.11785 -89.69665 6/16/2012 18:27 12.117

ruby on rails - Formtastic form doesn't recognize text area added with javascript -

i have form i'm dynamically adding textareas. form comes way: <%= semantic_form_for :requisito, :url => update_requisitos_tramites_path, :html =>{ :id => "form_edit_req" } |f| %> ... <% end %> when button clicked, function triggered , adds inside form next code: <textarea rows="3" class="textarea-obs" name="requisito[observacion]">¿por qué?</textarea> and gets rendered expected (and code in right place, checked chrome's js console.) i understand input type :text in form gets converted textarea id , class name model[attribute] getting value params in controller like: params[:model][:attribute] or in case: params[:requisito][:observacion] but i'm printing params in server's log , not value stored symbols. ideas? i didn't solved recognition problem, changed code, wrote textarea in view hidden. javascript showing , hiding it, , if write name way said, works perfect

Preserve newlines when setting html in a div from a textarea - Jquery -

i got little html -: <div id="viewone"></div> <textarea id="viewtwo"></textarea> <button id="copytodiv" value="copy div"></button> this jquery snippet-: $("#copytodiv").on("click",function(){ $("#viewone").html( $("#viewtwo").val() ) }); but strips of new line characters textarea's val , string new lines stripped off. how preserve newlines when setting html of div. lot :) the new lines preserved, not converted html new lines ( <br/> ), ignored. you can convert them <br/> .replace : $("#copytodiv").on("click",function(){ $("#viewone").html( $("#viewtwo").val().replace("\n","<br/>") ) });

vim - Multi-user secure shell session sharing -

i'm looking pair programming collegue remotely, , i'm looking best tool achieve this. ideally i'd prefer remote user have little access possible, , it'd preferrable if monitor actions. gui access not required, shell enough. for example, shared tmux or screen sessions work well, if easy setup , secure. just create new, non-root user account on machine, run tmux under account. screen sharing easy , "just happen" if both "attach" same screen session. if there nothing under temporary user account care about, there little damage do, afaik, though question may more appropriate https://serverfault.com/ .

ios development - How to do JSON parser? -

i'm new ios development. json file server. i use nsdictionary objects. when debug, "name", "address" values. but don't know how can "dish" elements "recommendation" object? in java development, know recommendation object, , "dish" array element. don't know happen in ios. { "results": [ { "name": "ollise", "address": "columbia university", "geo": [ { "coordinates": 40 }, { "coordinates": 70 } ], "logo": "http:\/\/a0.twimg.com\/profile_images\/3159758591\/1548f0b16181c0ea890c71b3a55653f7_normal.jpeg", "recommendation": [ { "dish": "dish1" }, { "dish": "dish2"

Best practice to keep source code of phonegap project for android and ios -

i'm using mac os x. i'm working on phonegap app both android , ios. same source code (www folder) in 2 locations android , ios. inconvenience update source codes @ both location. suggestions? apache cordova cli provides example on how organise sources when developing cordova/phonegap.

x86 - idivl of two numbers where the first is less than the second (in assembly) -

to understanding, idivl command in c assembly takes 64-bit number represented %edx (the more significant half) , %eax (the less significant), divides argument, , stores result in %edx:%eax again. the behavior when / b , > b expect: 10 / 2 yields 0's in %edx , 5 in %eax. however, i'm not sure why / b when b > produces does. example, when switch 2 two / 10 (that is, %edx 0's , and %eax 2, , 'argument' that's given idivl 10), result this: %edx has 2; %eax has 0's why result? if mash %edx , %eax together, mean 2 / 10 = 0000000000000000000000000000001000000000000000000000000000000000 in binary 2^33 in decimal, not anywhere near 2/10. thanks! you're right divides edx:eax operand, doesn't store result there. instead, puts quotient in eax , remainder in edx.

jar - Integrating another android app inside my own application -

i'm total newbie android app development, excuse lengthy explanation. anyways, have developed application (running successfully). now, want integrate open source app (quiz) application. so, when user presses button in app, run quiz application. i have learnt here (answer denys nikolayenko) there way converting quiz app .jar file, , adding current project. have done that; point of adding .jar file build path (and appears in referenced libraries) stated here . plus, .jar file checked under 'order , export' tab. now, have problem integrating .jar file 1 of button (so quiz app runs when press button, mentioned earlier). there way integrate .jar file in button (i couldn't find sample code anywhere)? or concept of executing .jar file wrong all-together? if concept wrong, how integrate quiz app app? i'm using eclipse. i have learnt here (answer denys nikolayenko) there way converting quiz app .jar file, , adding current project. that insufficient,

html - move <div> to inside page -

Image
question i trying create loginform dropdown on mouseover. form drops top left side of miniloginform div causes drop off screen. how drop down top right side of miniloginform div? html <li id="login"><?=anchor('users/login', 'login')?> <div id="miniloginform"> <?=form_open('users/login')?> <p>username: <?=form_input('username')?></p> <p>password: <?=form_password('password')?></p> <p><?=form_submit('login', 'login')?></p> <?=form_close()?> <p>new user? <?=anchor('users/register', 'click here')?></p> </div> </li> css #miniloginform { margin: auto auto; display: block; border: 1px solid black; width: 250px; position: absolute; } nav { wid

magento - Manually Cancel An Order -

i have orders need cancelled because pre-authorized through auth.net, not cancel. "no transaction found" message when trying cancel/void. because of want cancel orders manually in database , skip standard void process. know specific tables in magento database need modified cancel order? be careful this. table in 1.7 sales_flat_order . columns state , status . going set them both canceled . note: can use select , clause verify names. should work i'm not 100% sure not cause problems. i'm answering question. you can mess things method smart backup database before try anything. gl

android - Application load time is so slow when using many sounds in Soundpool... any substitutions? -

long story short, making soundboard. short clips, researching, soundpool seemed best option. has worked out phenomenally me, except overall load time getting longer , longer. have many sound clips in there, , have them load in oncreate() in main activity, in order remove further loading time between other activities. said, load time long, , plan on having many more sound clips added in. there sort of substitution load faster? have seen soundboard loads larger amount of sound clips, , application loaded, , sounds ready play when buttons clicked. if has suggestions, appreciate it!! this app talking about, if see in action: https://play.google.com/store/apps/details?id=com.cr5315.grump&feature=search_result#?t=w251bgwsmswxldesimnvbs5jcjuzmtuuz3j1bxaixq .. don't load them in oncreate- load them in asynctask gets launched in oncreate. way load in background app running. you'll have add null checks each sound, or not play sounds until entire set of sounds downlo

python - Train two models concurrently -

all need is, train 2 regression models (using scikit-learn) on same data @ same time, using different cores. i've tried figured out myself using process without success. gb1 = gradientboostingregressor(n_estimators=10) gb2 = gradientboostingregressor(n_estimators=100) def train_model(model, data, target): model.fit(data, target) live_data # pandas dataframe object target # numpy array object p1 = process(target=train_model, args=(gb1, live_data, target)) # same data p2 = process(target=train_model, args=(gb2, live_data, target)) # same data p1.start() p2.start() if run code above following error while trying start p1 process. traceback (most recent call last): file "<pyshell#28>", line 1, in <module> p1.start() file "c:\python27\lib\multiprocessing\process.py", line 130, in start self._popen = popen(self) file "c:\python27\lib\multiprocessing\forking.py", line 274, in __init__ to_child.close() ioerror: [err

How to populate active directory users data in a sharepoint 2010 new list item form? -

i have custom list in sharepoint 2010 website. when adding new item list, want populate data active directory in respective fields when enter exact user id in first field. can done through sharepoint designer or through browser? depending on user information want populate list, may find easier use sharepoint api directly , call spuser object instead. spuser user = web.ensureuser(listitem["userfield""]); the ensureuser() method require give username in format: domain\user. that being said, you'd behoove make field in question spuser field in first place. way default new item / editor makes field uses peoplepicker object bring in actual users. if need call active directory directly, can that, too, guess, since virtually in ad can exposed in sharepoint either automatically or editing user profile service application, there's not reason invoke ad directly in scenarios.

java - Not sure how to create a menu which uses methods from my other classes -

so far have created 2 classes, show below i have tested both classes , both seem work. i need create menu use 2 classes have created , allow users enter information , find information on account following: add customers details make deposit business account record meter reading business account display current balance of business account display full account details change discount value business account change cost per unit business accounts how use menu system while have tried best find out how using resources online lost. point every time have tried create menu system not work. appreciate if me basics on how go doing it. thanks :) public class gasaccount { private int intaccrefno; private string strname; private string straddress; public double dblbalance; private double dblunits; public static double dblunitscosts = 0.02; public gasaccount (int intnewaccrefno , string strnewname , string strnewaddress) { } public

jquery - Chrome Extension: Unbind event listener added by script executed on the fly -

i have chrome extension bind mousedown event listener on "body" when browser action clicked . , when browser action clicked again, unbind mousedown event. but reason, unbind not working though logs codes executed. have tried bind()/unbind() methods no avail. any appreciated. thanks! manifest.json { "name": "my extension", "description": "view font info", "manifest_version": 2, "version": "1", "permissions": ["tabs", "http://*/*", "https://*/*"], "browser_action": { "default_icon": "f.png" }, "background": { "scripts": ["background.js"] } } background.js var toggle = false; chrome.browseraction.onclicked.addlistener(function(tab) { toggle = !toggle; if(toggle){ chrome.browseraction.seticon({path: "f.png", tabid:tab.id}); chrome.tabs.executesc

vsto - Determine Excel 2007 addin vs excel 2010 addin -

i have received ms excel addin project build in vs2010. how determine whether excel 2007 addin or excel 2010 addin project ? you can check references added project. not sure kinda of addin is, i'll assume using interop assemblies. can check version on microsoft.office.interop.excel assembly. if 12.0.0.0 targeting excel 2007, version 14.0.0.0 mean excel 2010.

APNS mis-triggering the push notifications to some devices -

i'm encountered strange issue now.. the problem though central server in charge of pushing notifications apns using apns-php (open source push sending management built on top of php language.) didn't fire duplicated message, devices showing same messages gotten apns on , over. the differences may distinguish normal messages follows: sound parameter not affected on problematic message. (even though configured custom sound each message, duplicated message sounds default.) time value inappropriately displayed on iphone standby screen following example: a app: push 4 hours ago b app: blah blah.. 3 mins ago a app: take present:xxx... 4 mins ago a app: message arrived:xx.. 4 mins ago b app: lalala... 7 mins ago as can see in above, recent message should listed on top duplicated message arrived couple times pops again sound , vibration of normal messages time precisely d

javascript - Using Extendscript to Import a Visio Object By Reference into FrameMaker -

my colleagues , import our visio files framemaker via following mechanism: file > import > object... > create file (with link checked). i want accomplish same action using extendscript, file being imported selected automatically (via script). i've tried numerous import-script settings using import() method, fv_badimportscriptvalue error. think because hint string object linking , embedding not published anywhere (that can find). ultimately, i'm trying accomplish rename visio file has been linked , embedded, , reimport renamed file. can rename files first extracting old file name ole2 facet , renaming old file on disk new name. can't reimport renamed file, however. when do, badimportscriptvalue error. in lieu of reimporting renamed file, tweaking existing ole2 facet link newly renamed file option, if knew how that. reimporting seemed cleanest approach--i can't work. any appreciated. thanks, paul