Posts

Showing posts from March, 2013

r - Link id with name -

this question has answer here: how join (merge) data frames (inner, outer, left, right)? 11 answers i know quite simple question i'm still quite new r. if have 2 tables this id = c(1,2,3,4,5,6) cost = c(11,22,33,44,55,66) name =c("aa","bb","cc","dd","ee","ff") tableone = cbind (id, cost) tabletwo = cbind(name,id) how can add correct names (as in tabletwo) tableone costs? in reality table1 more complex multiple duplications etc. here's way using data.table package: load package: library(data.table) load vectors had them defined: id <- c(1,2,3,4,5,6) cost <- c(11,22,33,44,55,66) name <- c("aa","bb","cc","dd","ee","ff") turn vectors single column data tables: id.dt<-data.table(id) setnames(id.dt,"id&

node.js - Node/Express memory increase on every request -

i have simple express 3.2 app returns 200 when posted to. watch memory rss of node (v0.10.5) process , every request increases memory 4kb or so. the server code quite simple: var express = require('express'); var app = module.exports = express(); app.set('port', process.env.port || 3000); app.use(express.favicon()); app.use(express.bodyparser()); require('./apps/events/index')(app); app.listen(app.get('port'), function(){ console.log("express server starting..."); }); and corresponding controller code : // ./apps/events/index.js var events = function(app) { app.post('/events', function(req, res) { res.writehead(200); res.end(); }); } module.exports = events; is there in code causing this? normal (hopefully not). or measuring wrong thing? put version of script production , node process started @ 16mb memory use, , after load testing (20,000 hits) increased 32mb. keep profiling server.

mysql - Transactions when writing to two or more different data-storages -

let's suppose have 2 data storages: mysql(innodb) & redis. need write data both storages , in transaction. try { $mysql->transaction(); //start mysql transaction $mysql->somecommands(); //exec sql $redis->multi(); //start redis transaction $redis->somecommands(); //exec redis commands $redis->exec() //redis commit $mysql->commit(); //mysql commit } catch (exception $e) { $mysql->rollback(); //mysql rollback $redis->discard(); //redis rollback } if error occures on $mysql->commit() have our data in redis , unable rollback it. best practices? mysql 5.0.3 , supports xa, redis not, can't perform distributed transactions in traditional sense both participators understand prepare , commit , rollback semantics. in case, since have 1 non-xa compliant participant (redis), redis work last. if redis operation successful, commit mysql. if redis not successful, rollback mysql. in ter

c++ - How to correctly access ATL control from ATL Dialog? -

i have msvc 2010 solution contains 2 projects: atl dll project, contains dhtml control (named dhtmlcontrol, pretty built wizard). think have placed control second project though. atl exe project, contains main dialog (cmaindialog), created wizard. i have managed add dhtmlcontrol dialog: added dhtmlcontrol toolbox dragged onto main dialog in resource view removed dhtmlcontrol toolbox (to avoid access denial on build) however, problem not know how use control! assuming in scope of maindialog, in: lresult cmaindialog::oninitdialog(uint umsg, wparam wparam, lparam lparam, bool& bhandled) what right way invoke dhtmlcontrol's methods? say, navigate url or after button on main dialog pressed. how can pointer/reference dhtmlcontrol (cdhtmlcontrol? idhtmlcontrol?) being inside of cmaindialog class? sorry if sounds bit messy struggling atl. thank you. include generated _i.h dialog's header (do not include actual control's header - not meant

ajax - Liferay portlet issue with Richfaces 4.2 and PortletBridge 3.1 -

we have application numerous portlets liferay 6.0.6 using jsf1.2 richfaces 3.3.3.final , portletbridge 2.1.1 , working fine. decided upgrade our stuff jsf2 richfaces 4.2.3.final , portletbridge 3.1.2. seemed fine until tried use ajax-enabled command buttons (a4j:commandbutton or h:commandbutton f:ajax) navigation: in case portlet navigation whole liferay screen disappears , jsf components remain on screen. if try use navigation again, it'll fail (after 1-3 tries) exception: [#|2013-05-08t14:15:33.104+0200|severe|glassfish3.0.1|com.sun.grizzly.config.grizzlyservicelistener|_threadid=26;_threadname=thread-1;|unblocking keep-alive exception java.lang.illegalargumentexception: request header large it logs interesting things this: [#|2013-05-08t14:11:42.203+0200|info|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_threadid=26;_threadname=thread-1;|unable find component clientid 'pb_richtest_war_richtest_instance_hlc1__j_id1:j_id2', no ne

java - Multiple theads access Memcache -

what happen if multiple thread access same object stored in memcached ?? i have object objstore stored in memcached. each thread retrieve objstore memcached , change , again store memcached. at same time in module if want fetch same object objstore memcached, return empty object. i using memcache 1.4 version. memcached hold last version of object. if get, modify , put have no guarantee put applies same value get. use cas operations ( gets , cas ) if need synchronize.

bitmap - Downloading images using AsyncTask in android -

i stuck @ 1 point. need suggestions same. creating application involves json parsing. after parsing getting data involves event name, event description, event place, event image url , on. data huge. can imagine facebook kinda stuff. now problem data getting parsed because event image in form of url, need convert bitmap. have kept process of json parsing , bitmap conversion 1 asynctask(doinbackground()). this taking lot amount of time. want facebook data gets loaded , shown end user images load , steadily. (i mean when scroll facebook, images don't come immediately). i want similar functionality. need suggestions. you can still use asynctask, you'll need use 2 seperate tasks. 1 loading , parsing of json, , 1 loading of image. after parsing json, you'll need start asynctask every image you're trying load, making them load on own thread. show once item done loading.

arrays - Populate VB6 ListBox with single instruction -

Image
in vb6 can't seem able that: mylistbox.list = listcontentstringarrray vb complaining compile error saying "argument not optional", because .list(index) requires, well, index. the following code works in vba: private sub commandbutton1_click() dim result() string redim result(0) result(0) = "hello" redim preserve result(1) result(1) = "world" listbox1.list = result end sub looking @ object browser found listbox in vba msforms.listbox , in vb6 it's vb.listbox . the vba listbox's list property declared property list([pvargindex], [pvargcolumn]) , in vb6 it's property list(integer) string , problem comes from. is there way "swap" vb.listbox msforms.listbox in existing code base without breaking anything, or msforms designed use in vba "vb" library isn't included in vba? if reference fm20.dll in vb6 project, can see msforms.listbox in object browser, not in toolbox.

java - Generating different passwords according to a string - Activation Key -

i'm trying make program activated password on java. while user registering, "teacher pass" given authorized personal asked , if it's correct, program allow user use itself. students can use program can't reach of content. private static string encrypt() { string s = "cornflakes"; string pass = ""; random rnd = new random(); int = rnd.nextint(s.length()); for(int j = 0; j < 7; j++) { pass += ""+ + s.charat(i); = rnd.nextint(s.length()); } return pass; } private static boolean decrypt (string s) { if(s.length() != 14) return false; string teacherpass = "cornflakes"; string[] tokens = s.split("a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|q|p|r|s|t|u|v|w|x|y|z"); int loc; for(int = 0; i< 7; i++) { loc = integer.parseint(tokens[i]); if(s.charat(2*i+1) != teacherpass.charat(loc)) return false; } re

How to load portable .NET library within Iron Python script? -

i have serious troubles loading portable .net library (to used in standard .net , silverlight environment) python script. .net dll file version 4.0.3.319.233 (system.core.dll), ironpython 2.7.1, running in 32bit/x86 mode. visual studio 2010 c# under .net 4. microsoft .net update kb2468871 portable library usage installed (version 2). if try load library python script: clr.addreferencetofileandpath(usedpath+"\\mynamespace\\myportablelibrary.dll") it can't accessed, , when script reaches type, says: "attribute [type in portable assembly] of 'namespace#' read-only" indicating assembly has not been loaded @ (or silverlight, , can't used python script). changing code to: (assembly class system.reflection) portableassembly = assembly.loadfrom(usedpath+"\\mynamespace\\myportablelibrary.dll") # load through .net reflection, python won't load portable assembly properly! clr.addreference(portableassembly) results in error: exce

.net - Which store to use when installing an x509 certificate -

ok, app needs interact 3rd party web app uses client certificates authenticate user. (i need open window web browser control, , navigate site). the vendor has tossed me 6 .cer files. 1 root, assume there 1 or more intermediate certs, , 1 or more client certs. no idea which. these self-issued certs, don't expect issuer cert trusted default -- need install root trusted publishers. so, know need install these certs key store, don't know cert goes store. need figure out? i assume using ms windows of sort if running other os stop reading here :-) to go correct way should this: root certificate --> trusted root certification authorities intermediate certificate --> intermediate certification authorities client certificate --> personal. in experience can’t relay on windows import guide put certificates in right stores have tell in store put certificates. to sort certificates have make certificate “chain sort” @ certificates , sort them in 1

java - Serial Mark-Sweep-Compact (PSOldGen) PS stands for? -

when searched psoldgen garbage collector saw in gc log, found out serial mark-sweep-compact. if gc serial, ps in psoldgen stand for? afaik parallel scavenge. confuses me. [full gc [psyounggen: 647k->0k(60352k)] [psoldgen: 45361k->45875k(54528k)] 46008k->45875k(114880k) [pspermgen: 10201k->10201k(21248k)], 0.0359430 secs] there 2 collectors in jvm: young space collector , old space collector. hotspot jvm implementing bunch of algorithms, combination of collectors workable. psyounggen "parallel scavenge" young space gc algorithm, not compatible default serial algorithm old space ( tenured ). psoldgen serial old space algorithm added work parallel scavenge young space algorithm - psyounggen . you can enable parallel algorithm old space ( -xx:+useparalleloldgc ), in case see psyounggen , paroldgen pair of algorithms @ work. you can enable parallel young space algorithm -xx:+useparnewgc , tandem default serial old space algorithm tenured . h

sql server - how to update syscolumns of a view after alter table - T-SQL? -

this question has answer here: how dependent views update automatically in sql server? 2 answers today noticed when alter table in view, syscolumns of view not updated without run sp_refreshview. code bellow show i'm talking about create table test ( n1 decimal(12,4) ) go create view vtest select * test; go sp_help vtest go alter table test alter column n1 decimal(12,2) go sp_help vtest note vtest stay static, there someway automate process ? you need call sp_refreshview update view create table test ( n1 decimal(12,4) ) go create view vtest select * test; go sp_help vtest go alter table test alter column n1 decimal(12,2) exec sp_refreshview vtest go sp_help vtest

Concurrent conditional inserts in Hibernate -

i implement call conditional insert using hibernate. let's have entity named maps corresponding table a. before persiting new row table want't check if row present , insert new 1 if isn't. have multiple clients concurrently write table a. in opinion have lock entire table before doing check prevent concurrent access many clients. so question how in hibernate. possible. or wrong , there maybe different solution.

jquery - Javascript Error - Undefined -

i trying create format graph. when try getting undefined console.log before data. here's code $(document).ready(function () { var graphdata = new array(); $.getjson("ds/js.json", function (data) { datalength = returneddata.data.length; var x = new array(); var y = new array(); var mytext, dataa, f; (i = 0; < datalength; i++) { x[i] = data.data[i].avgprice; y[i] = data.data[i].numproducts; } (var = 0; < 6; a++) { mytext = "x:" + x[a] + "," + "y:" + y[a] + "}" + "," + "{"; dataa = dataa + mytext; } console.log(dataa); var f = "[{data : [{" + dataa; console.log(f); }); drawgraph(graphdata); }); console output : undefinedx:87.6,y:85},{x:116.08,y:61},{x:113.11,y:49},{x:181.37,y:65},{x:138.14,y:74},{x:66.03,y:89},x:66.03,y:89},

asp.net web api - Caching Data in Web API -

i have need cache collection of objects static (might have changes 1x per day) avaliable in asp.net web api odata service. result set used across calls (meaning not client call specific) needs cached @ application level. i did bunch of searching on 'caching in web api' of results 'output caching'. not i'm looking here. want cache 'people' collection reused on subsequent calls (might have sliding expiration). my question is, since still asp.net, use traditional application caching techniques persisting collection in memory, or there else need do? collection not directly returned user, rather used source behind scenes odata queries via api calls. there no reason me go out database on every call exact same information on every call. expiring hourly should suffice. any 1 know how cache data in scenario? yes, output caching not looking for. can cache data in memory memorycache example, http://msdn.microsoft.com/en-us/library/system.runtime.ca

java - 3D graph with live updating -

so have been doing hours , hours of research, , cannot find efficient in python need. things found in java , c work, data need graph held in pandas dataframe , better if graphing work in python. i have looked matplotlibs 3d graphing using color 3rd axis, feel though not best way because need live updating. my data accelerometry phone data every second on span of 2 months , able have point updated show change in accelerometry , such. here quick video of need, using java: https://www.youtube.com/watch?feature=player_embedded&v=vblcfz291vw so there way in python? dataframe example: x.mean y.mean z.mean time 0 -1.982905 3.395062 8.558263 2012-01-18 14:00:03 1 0.025276 -0.399172 7.404849 2012-01-18 14:00:04 2 -0.156906 -8.875595 1.925565 2012-01-18 14:00:05 3 2.643088 -8.307801 2.382624 2012-01-18 14:00:06 4 3.562265 -7.875230 2.312898 2012-01-18 14:00:07 5 4.441432 -7.907592 2.851774 2012-01-18 14:00:08 6 4.124187 -7.854146 2

asp.net - I want an HTML anchor call a page method and JUST that method;No page_load. Is that posiible?if it is then HOW? -

<a href="a.aspx?qs=2"></a> clicking should fire method getmedata(obj sender, eventargs e) in codebehind of a.aspx getmedata() bound aspbutton ineed reuse method on click event within html link. public void page_init(object o, eventargs e) { if (!string.isnullorempty(request.querystring["curpage"])) { filterordersbydate(); } } public void filterordersbydate(object sender, eventargs e) { //with bll logic calls: list<esalesorder> list = bsales.getsalesorderadminbydate(esalesdate,curpage,perpage); } but call on filterordersbydate(); never reaches nevertheless satisfies above condition...instead goes through page load , execute whatever finds in page_load , done..there all. well... passing query string isn't issue @ all. question: binding data? if don't want invoke method on page_load should invoke on_item_data_bound on web control suppose. method this: protected v

android - requestLocationUpdates vs Location Listener -

what difference between using location manager object requestlocationupdates() vs using locationlistener? both same thing , work same way? whats advantage of 1 on other? locationmanager lm = (locationmanager)getsystemservice(context.location_service); lm.requestlocationupdates(locationmanager.gps_provicer, 0, 0, new locationlistener()){ //all appropriate methods here } vs. locationlistener mylocationlistener = new locationlistener(){ // appropriate methods here } your question technically incorrect. locationmanager registers listener via requestlocationupdates. listener callback when location manager realizes timeout or distance travel has occurred. in case location listener called immediately. but beware, location manager request updates 0,0 parameters not known instantaneous. there may delay. so question on what difference incorrect. asking difference between print this , system.out.println() :)

vb.net - .NET XML Node Self Closing Tag -

i have piece of xml contains self closing tag follows: <givennode /> <givennode>this has data in it</givennode> how test if "givennode" empty? if not objchildnode.selectsinglenode("givennode").value nothing 'do or other end if this returns false either way, know must pretty easy cant figure out. rather not have change either code using @ moment of xmlfile can if have to. thanks help. if else has same problem me got around using following code if not objchildnode.selectsinglenode("givennode").innertext = string.empty //do or other end if

java - How to logout from Google+ Account? -

after signin google plus on android app. how can logout, can sign in account. don't know if googleauthutil.invalidatetoken answer or not... thanks if using google+ sign in (and should - work flow better, both developers , users), can sign out user following guide's example : @override public void onclick(view view) { if (view.getid() == r.id.sign_out_button) { if (mplusclient.isconnected()) { mplusclient.cleardefaultaccount(); mplusclient.disconnect(); mplusclient.connect(); } } }

azure - Is it a bad practice to do WebRequests from ASP.NET MVC app? -

i'm doing web application (asp.net mvc) running/deployed in windows azure. is bad practice if lot of webrequests application?, is: actionresult someaction() { webrequest.create(some url); .... } someaction called lot of times. someaction might create 100 webrequests, or more. is bad practice? should using windows service instead? is: actionresult someaction() { //save request in db , let windows service poll db //and webrequests outside mvc application } it not bad practice until mandatory project. btw can wrap remote call using best practice like: if data in remote url don't change ofter can cache results avoiding multiple web request use async await methods (if using .net 4.5) web request asyncronous , better performance application

jpa - CDI EntityManager fail -

hibernate says "an exception thrown hibernate means have rollback database transaction , close session immediately". when persist method throws sqlexception , entitymanager becomes dirty, if close entitymanager, still in conversation scope. i'm using: tomcat 7, cdi 1.1, hibernate 4.1; is there way produce new entitymanager current conversation replace dirty? @produces @conversationscoped public entitymanager create(entitymanagerfactory emf) { entitymanager em = emf.createentitymanager(); ... viewbean @named @conversationscoped public class myview implements serializable { enter code here @inject @getter private entitymanager em; ... public void persist(){ try{ getem().gettransaction().begin(); getem().persist(entityinstance); getem().gettransaction().commit(); }catch(exception e){ e.printstacktrace(); if(getem().gettransaction().isactive()){ getem().gettransaction().rollback(); }

c# - Selecting a Table Cell -

i have table automatically generated based off of 2 grid values. able select each individual cell (not multiple cells), , on cell select, radwindow should appear. selected cell's outer box should become bold. within radwindow radcolor picker, , color picked change cell's background. looked @ bunch of examples of similar events online, because of lack of jquery , js knowledge i'm unsure how go this. my table looks this: <asp:table id="table1" runat="server" borderstyle="solid" borderwidth="7px" cellpadding="40" cellspacing="15" font-bold="true" font-size="xx-large" gridlines="both" horizontalalign = "center"> </asp:table> the code-behind table generation is: public void generate_matrix() { // total number of rows. int rowcnt = cct.rows.count; // current row count. int rowctr; // current cell counter int cellctr = 0

debugging - Obtaining profiling information on running python app -

if have python application in production (i.e not running under debugger or profiler), is there way attach python process/instance , examine it? useful know: what code consuming time what using memory any insight appreciated.

How to get jenkins to build my code even if there are no changes -

i using jenkins matrix plugin testing project. have upstream, kick-off build fired of every night @ fixed time. build performs checkout , part 1 of tests. passes subversion url (svn_url) , revision (svn_revision) downstream build. downstream build uses passed in subversion url , revision checkout source (this way, know both upstream , downstream builds targeting same revision), , performs part 2 of tests. the problem have downstream job doesn't run saying there no changes in checked out source since last build (no change since previous build). downstream build build every single time invoked, if there no changes. pointers on how that? thanks (edited in reponse question) detailed jobs description: 1. kickoff job. run periodically. captures svn_url , svn_revision. fires of part1-job , part2-job. not else. 2. part1-job , part2-job matrix jobs not have triggers on them. merely run kickoff job. part2-job have problem. curiosly, problem mentioned above not happen part1-job.

compression - PHP to convert a string of 20 alphanumeric characters into 10 alphanumeric characters -

for work, we'll given alphanumeric string of 20 characters. need find out if can convert 20 character string 10 characters, , able reverse later. i thinking of converting alpha characters numbers, dividing number, 16.8347464849, give me smaller number. going other way, multiply small number 16.8347464849 original, converting numbers letters tricky. is there way other storing database on server of converted values? example: $string = "8d89a6df8fg7fg87f87"; $converted = $string / magic; //$converted = "8a0s9872aa"; you can not without other information format of original string. if input string can have * * 20 alphanumeric characters, , transforming 10 alphanumeric characters, there several 20 character strings output same 10 character string, making impossible revert transformation.

wordpress - how to hide content on index page and show this when a post is opened? -

Image
i use wordpress. my idea stackoverflow . want on index page content doesn't show when opeded post content's shown, stackoverflow <article id="container"> <?php if(have_posts()):?> <?php while(have_posts()): the_post();?> <div class="post" id="post-<?php the_id(); ?>"> <div class="postmetadata small-font"> <ul> <li><?php bawpvc_views_sc('post_view', 'bawpvc_views_sc'); ?></li> <li><?php comments_popup_link();?></li> </ul> </div> <div class="post-header"> <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3> <?php get_template_part( 'content', get_post_format() ); ?> <?php the_excerpt(); ?> <

media player - Android MediaPlayer Error 1,-2147483648 only for Emulator 2.2 and 2.3 -

i'm facing problem playing videos url (streaming). these videos playing on newest versions of emulators. tested on 3.2, 4.2, 4.2 playing don't play on 2.2 , 2.3. i'm using videoview , mediacontroller play videos , format of videos mp4. here exception-log. having idea it. 05-08 15:07:28.530: d/videoview(2402): error: 1,-2147483648 05-08 15:07:33.199: e/resourcetype(2402): style contains key bad entry: 0x010102ce 05-08 15:07:33.199: e/resourcetype(2402): style contains key bad entry: 0x010102d7 05-08 15:07:33.220: e/resourcetype(2402): style contains key bad entry: 0x010102f3 05-08 15:07:33.220: e/resourcetype(2402): style contains key bad entry: 0x01010300 05-08 15:07:33.220: e/resourcetype(2402): style contains key bad entry: 0x0101039c 05-08 15:07:33.940: d/mediaplayer(2402): couldn't open file on client side, trying server side 05-08 15:07:33.970: e/mediaplayer(2402): error (1, -2147483648) 05-08 15:07:34.190: e/mediaplayer(2402): error (1,-2147483648) 05-08 15:

java - how to use setLocation to move componets -

i'm trying set components of application set location using setlocation far haven't been able move components. there more code calling , setting code part. ideas? import javax.swing.*; public class hangmanpanel extends jpanel { private static final long serialversionuid = -5793357804828609325l; public hangmanpanel(){ jlabel heading = new jlabel("welcome hangman app"); jbutton button = new jbutton("ok"); //button.addactionlistener(); jlabel tflable = new jlabel("please enter letter"); jtextfield text = new jtextfield(10); string input = text.gettext(); heading.setlocation(50, 20); tflable.setlocation(20, 100); text.setlocation(320, 50); button.setlocation(230, 100); this.add(heading); this.add(tflable); this.add(text); this.add(button); } } you should not use setlocation() layout swing components, bett

jquery - Can I reference input:text as an #id? -

i'm looking create "filtering input field" eliminates tiles page don't match input. so far have this... html - <input name="filter" type="text" value="find you're looking for" /> <a href='#' id='b_submit'>submit</a> <article id='johns'>content</article> <article id='bobg'>content</article> <article id='saml'>content</article> <article id='ronaldy'>content</article> script - $("#b_submit").click(function() { var filter_text = $('input:text').val(); //this sets filter_text input value $('article:not(??not sue call here??)').fadeout(); //this need help, need call value #id eliminate non-matching articles. }); what's proper syntax this? on complicating simple filtering? help? :d i think you're looking for: $('article:not(#'+filter_tex

PHP and MySql using PDO 'String data, right truncated' Error after insert image in PHPMyAdmin -

i pretty new php , mysql , having trouble think longblob column in db. entire error here fatal error: uncaught exception 'pdoexception' message 'sqlstate[01004]: string data, right truncated' in client.php:110 stack trace: #0 client.php(110): client::findbyownerid() #1 user.php(91): client->findbyownerid('2') #2 usercontroller.php(26): user->findbyid('2') #3 {main} thrown in client.php on line 110 i seem error if upload image longblob column. if delete row image works great. i using pdo connect to database, have searched solution have found similar problems not seem mention images... is sql config issue, missing pdo attribute? here pdo code $dbconnstring = "mysql:host=" . db_server . ";port=".db_port."; dbname=" . db_database; $this->dbconnection = new pdo($dbconnstring, db_username, db_password); $this->dbconnection->setattribute(pdo::attr_emulate_prepares, false); $this->dbconnecti

javascript - MouseOver sound effect, a Better way than this -

i need sound on mouse on event, have way problem comes delay between mouse on , sound playing, due (i supposed) embed sound deal on code. know if there better way using js/jquery). not new html5 audio tag don't want implement in particular case. an ajax call loads file, attached mouseover function named playsound() function playsound() { $setsound = document.getelementbyid("soundwrapper").innerhtml="<embed id='sound' src='href' type=audio/mpeg hidden=false autostart=true volume=12>"; } then mouseout event function named stopsound() function stopsound() { $stopsound = document.getelementbyid("soundwrapper").innerhtml=""; } nothing fancy work. problem said delay playing sound. there way play/stop embedded sound, not embed new 1 every time, or alike?. thanks time , help. greetings. if have ajax load audio tag ( http://www.w3schools.com/tags/tag_audio.asp ) desired place, can play using .play()

git - Getting file to add that was previously on ignore-paths -

we have large svn repository locally use git , git-svn interact with. recently created repository ignored file starting trunk. fixed ignore-paths ignores directory trunk , not file starting trunk. now git svn "was not found in commit" error since commits git syncs have file git missing original file commit. usually 1 use git svn reset -rxxxx , git fetch -rxxxx 2 year old repository , can not roll when file created. how git pull file down svn? idea 1: create svn working copy. then: svn rm <paths want un-ignore> svn commit -m "ignore workaround" svn merge -r committed:prev . svn commit -m "reverting: ignore workaround" then edit .git/config amend ignore-paths , git svn rebase . idea 2: just copy files manually git repo svn repo, commit them , ditch svn. idea 3: don't worry , reset 2 year old git repo.

sql server - Query optimization.: Insert few raws from a table into same table after modifiying one or few column: -

well, need insert rows table (dbo.orderdata) mathematical modification(here multiplication -1) column(unit price) keeping other columns value is. here code: considering northwind db: create table dbo.orderdata ( orderid int not null, productid int not null, unitprice money not null, quantity smallint not null, discount real not null ) insert dbo.orderdata select * dbo.[order details] and insert code follows : insert dbo.orderdata (orderid, productid, unitprice, quantity, discount) select orderid, productid, unitprice * -1, quantity, discount dbo.orderdata orderid = 10530 i escaped inbuilt dbo.[order details] table due many key-constraint, i'm bit lazy ;) finally alternatives above insertion script need not specify columns name .please note in scenario 1 column may identity column. all answers , comments appreciated. if orderid, or combination of orderid , productid, pk, insert duplicates pk fai

html - GWT wrap a table and manipulate contents programmatically -

i have formatted html table (the html text generated reporting tool) , want turn "programmable" table in gwt . need show content provided, need inspect dom, tables, , add clickhandler 's rows , cells. i able similar images: html html = new html(htmltext); imageelement domelement = getchildimagebytagandid(html.getelement(), "img", "blah"); image image = image.wrap(domelement); image.addclickhandler(...); my question is: correct way tables? i not find wrap() method <table> , <tr> , , <td> elements. note: question asked (and not answered) in comments in accepted answer here . i unaware of easy way wrap existing table sub tr , td elements. given constraint relying on third party tool, recommend trying build custom table parser parse existing table, build flextable, , replace existing table new flextable. as ugly is, not sure there better way... it may depend on how table setup, may try playing around below e

android - Retrieve Contact name from phone number -

i've been looking everywhere since past few days find way retrieve contact name using phone number have stored in variable, unfortunately found far seems using deprecated functions/calls. of course, tried doing own way feel android/java knowledge not enough understand concept yet, keep getting errors or force close when try run anything. so far best thing find this: public string getcontactname(final string phonenumber) { uri uri; string[] projection; if (build.version.sdk_int >= 5) { uri = uri.parse("content://com.android.contacts/phone_lookup"); projection = new string[] { "display_name" }; } else { uri = uri.parse("content://contacts/phones/filter"); projection = new string[] { "name" }; } uri = uri.withappendedpath(uri, uri.encode(phonenumber)); cursor cursor = context.getcontentresolver

ios - How to switch window view -

in app have 1 .xib file 3 window s. i'm not using storyboard. change view between window s when pressing button, used code: -(ibaction) switchview1 { [window sethidden:no]; [window1 sethidden:yes]; [window2 sethidden:yes]; } however i'm having problems. there alternative case? thank in advance. yes, window, window1 , window2 instances of uiwindow an ios app has 1 uiwindow. created @ app launch , never changes. not otherwise. wrong, foolish, , unnecessary. is, quite simply, not how ios programming done. see answer here, documentation citations: https://stackoverflow.com/a/15909159/341994

mysql - Update table1 with count from table1 when count is null -

i had query updated row in table1 count(*) table - update t1 set a=(select count(b) t2 c=10 group c)) id=20 the problem if there no entries in t2 c=10, query fails select returns null or nothing. there way make work if sub-select statement returns null? p.s. have tried using ifnull, looks doesn't work. one of mysql's many curiosities that, if 1 drops group by clause (mysql implicitly group rows if aggregate function used in absence of explicit group by clause), return aggregated results if there no underlying records; in case of count() function, returns result of 0 desired: update t1 set a=(select count(*) t2 c=10) id=20 see on sqlfiddle .

iphone - Client server ios Application -

whats best way application phone server , others phones clients. clients requests server , server respond..requests maybe server sends real time audio capturing..whats best way in ios? using udp multicast? or tcp socket per client? using udp multicast cast messages all devices in network (hence name). not guarantee delivery , not garauntee delivery order (fofi) either. in situations, udp isn't idea. tcp great alternative, it's easy use, , garuantee things , there many frameworks or c libraries out there can lot. personally, i'ld recommend using libuv , attaching uv runloop nsrunloop , can use asyncsocket too, if you'ld rather stick objective-c.

c++ - How to receive messages using a message-only window in a console application? -

i've created simple win32 console application creates hidden message-only window , waits messages, full code below. #include <iostream> #include <windows.h> namespace { lresult callback windowprocedure(hwnd hwnd, uint umsg, wparam wparam, lparam lparam) { if (umsg == wm_copydata) std::cout << "got message!" << std::endl; return defwindowproc(hwnd, umsg, wparam, lparam); } } int main() { wndclass windowclass = {}; windowclass.lpfnwndproc = windowprocedure; lpcwstr windowclassname = l"foobarmessageonlywindow"; windowclass.lpszclassname = windowclassname; if (!registerclass(&windowclass)) { std::cout << "failed register window class" << std::endl; return 1; } hwnd messagewindow = createwindow(windowclassname, 0, 0, 0, 0, 0, 0, hwnd_message, 0, 0, 0); if (!messagewindow) { std::cout << "failed create message-only window" << std::endl; r

node.js - mongodb messaging schema design -

i'm working on nodejs & mongodb project i'm implement instant messaging feature website between users. need object structure stored in our mongodb database. requirements are: any user of website should able send message user messages should grouped in threads similar forum, each thread created when user sends message user via presentation page sender and/or recipient should able reply thread even if recipient/sender removes entire thread (or specific message in thread), other user should still see messages (if he/she not delete them) each user have inbox , sent, trash common mail box this have far messages:[{ '_id' : '502c21e3833ea71307001d56', 'from' : { '_id': '503fdbfa294f6db74de649ea', 'name': 'kumar' }, 'to' : { '_id' : '5061e2a61ac427f716000378', 'name' : 'elan' }

swing - DRY code to implement action listener (JAVA) -

i'm implementing tray game, in use jbutton represent tray. tray makes 7x7, implement action listener it's not fun. have code : public void actionperformed(actionevent ae) { if (ae.getsource() == bouton11) { this.posepion(1, 1, bouton11); } else if (ae.getsource() == bouton21) { this.posepion(2, 1, bouton21); } else if (ae.getsource() == bouton31) { this.posepion(3, 1, bouton31); } ...... } how can reduce sort of code please ? :/ thank :) make own listener type. type should implement actionlistener (and actionperformed method), , constructed 3 parameters: button , 2 integers. reason why need these 3 parameters can pass them posepion method (which should capitalized posepion , way). for example: class poseactionlistener implements actionlistener { private jbutton button; pri

javascript - Writing a function that "solves" an equation -

i want write function allow me "solve" equation in js. what want (not in programming language): function f(x) { 1 + x * x } var z = 2 var y = f(z) //y 5 number what have written in js: function p(cfg) { .... this.equation = "1 + x"; ....}; p.prototype.eqn = function(x) { var tmp = eval(this.equation); return tmp; }; .... p.prototype.draw = function() {.... for(var = 0; < z; i++) ctx.lineto(i, this.eqn(i)); ....}; also i've read using eval in loop not idea, have not figured out way (yet) (js beginner)... the problem code is, @ least in ff var tmp still contain string this.equation instead of calculated value. i appreciate further insight much! thank time :) edit: because question not formulated well: after execution of line var tmp = eval(this.equation); var tmp hold string equals string this.equation, instead of desired solution y value. not mean solve evaluate, tip :) based on example, i'd want "evalua

Convert ajax script from 1.8.3 jquery to 1.9 -

i'm trying use pagination script. use jquery ver. 1.9.1 on website, , script works version 1.8.3... i'm new jquery, , don't know how fix it. think, there syntax problem ajax , parseint... jsfiddle example original script jquery $(document).ready(function(){ function loading_show(){ $('#loading').html("<img src='images/loading.gif'/>").fadein('fast'); } function loading_hide(){ $('#loading').fadeout('fast'); } function loaddata(page){ loading_show(); $.ajax ({ type: "post", url: "load_data.php", data: "page="+page, success: function(msg) { $("#container").ajaxcomplete(function(event, request, settings)

html - Div height = 100% while scrolling -

i've been looking around , answers 100% div height says have specify in html,body, etc., , works great until have scroll down see more content on page. here example of issue: http://503rephotography.com/_temp/test2.html - looks ok until scroll down see more content. pardon lack of style here, it's not pretty, trying grasp concept before moving ahead. here's example works fine since there little content on page: http://503rephotography.com/_temp/test3.html does know how can make div on left keep going end of page regardless of how content on there? input appreciated, thanks!! you specify fixed positioning (position:fixed;) , higher z-index else (z-index:1000;) on nav.

html - What is the best/right way to vertical centralize this with css? -

i want vertical centralize "red" square text. have inner <a> inside div, doens't know if affect something... css below works, seems have vertical-align: middle; in every single tag. know how make more simple same html tree? thanks! html: <div> <a href="#"></a> </div> <span>testing...</span> css: div{ display: inline-block; margin: 0 3px; vertical-align: middle; } a{ width: 5px; height: 5px; background-color: red; display: block; vertical-align: middle; } span{ font-size: 26px; vertical-align: middle; } http://jsfiddle.net/sggzb/6/ only span needs vertical-align rule. span{ font-size: 26px; vertical-align: middle; } jsfiddle example

version control - Mercurial Error 400: Bad Request with return code 255 -

our repository consists of 2 branches default branch(where new features developed) , stable branch(where bug fixes implemented). when developer merges default branch stable branch , pushes other developers receive error 400: bad request return code 255 when attempting pull or push changes. we have multiple other repositories reside on same server used different teams not seem suffer same issues. repository in question used our web development team in conjunction webstorm ide. this second time have run problem same repository. last time happened created new repository , lost of our history. not ideal solution , highly undesirable. determine cause is leading error. when clone repository problem resolved temporarily until pushes new change involving merging 2 branches, person pushed change begins receive error. the following output of hg --debug --traceback pull c:\dev\hosedprism>hg --debug --traceback pull using http://mercurialserver01:8080/hg/rproxweb_old/ sending capa

Have someone a function for SQL Server that given a pattern and a value could return a normalized value -

i'm programming function in sql 2008r2 give parameters value varchar, pattern varchar, separator char , filler char. give value '22687' patter '000.000.000.000', separator '.' , filler '0', expect function return '000.000.022.687', 1 have function done can this? something this: declare @valor varchar(30) declare @formato varchar(30) declare @separador char(1) declare @rellenarcon char(1) select @valor = '22959' select @formato = '000.000.000.000' select @separador = '.' select @rellenarcon = '0' declare @n integer declare @m integer declare @i integer declare @j integer select @n = len(@formato) select @m = len(@valor) select @i = 1 select @j = 1 declare @res2 varchar(30) select @res2 = '' select @valor = reverse(@valor) while @i<=@n begin if substring(@formato,@i,1) <> @separador begin if @j<=@m begin select @res2 =

javascript - Make form fields required only if a file is not attached/uplodad? -

i have page job application form users can fill in contact info, , either upload resume document, or fill out rest of form. the problem is, need make fields required if there no resume attached. splitting separate forms not option. is there way use javascript require fields when there no resume attached? or alternatively, automatically fill in required fields "see resume" when user attaches resume file? you can bind change handler file input element , update required fields so: $('#myfileinput').change(function() { $('.myrequiredfield').val("see resume"); });

c# - Using DBNullable Types -

here's code: protected void btnsearch_click(object sender, eventargs e) { list<statbatter> completelist = new list<statbatter>(); dalbatter batter = new dalbatter(); batter.namelast = txtlastname.text; datatable batters = dalbatter.getbattersbylastname(batter); (int = 0; < batters.rows.count; i++) { datarow bat = batters.rows[i]; statbatter stat = new statbatter(); stat.playerid = bat.field<string>("playerid"); stat.g = bat.field<int32>("g"); stat.ab = bat.field<int32>("ab"); stat.h = bat.field<int32>("h"); stat.bb = bat.field<int32>("bb"); stat.cs = bat.field<int32>("cs"); stat.doub = bat.field<int32>("2b"); stat.trip = bat.field<int32>("3b"); stat.hr = bat.field<int32>("hr"); stat.rbi = bat.f

javascript - can you add properties on to functions in Dart? -

can add properties on functions in dart? tried this: void main(){ fn(){ //dosomething }; fn.id = 1; //exception nosuchmethod } only nosuchmethod exception thrown. there way add properties functions or type of object matter @ runtime in javascript? (also why saying no such method exception when i'm assigning property?) you can not add property on function . can define object can call function (see emulating functions in dart ). here's example : class wannabefunction { var id; call(int a, int b) => + b; } main() { var wf = new wannabefunction(); wf.id = 1; wf(3, 4); // 7 } for nosuchmethoderror : when use fn.id = 1 call implicite setter id= on fn . why error.

java - JPA: Retrieve a list from secondary table using a composite key -

well, here have example of i'm trying no success. sorry dummy example. have following tables: create table house( house_name varchar2(255), owner_id varchar2(255), primary key(folder_name, user_id) ); create table pet( house_name varchar2(255) not null, owner_id varchar2(255) not null, pet_name varchar2(255) not null ); alter table pet add constraint fk_pet_house foreign key(house_name, owner_id) references house(house_name, owner_id) on delete cascade; insert house values('house 1', 'owner 1'); insert house values('house 2', 'owner 1'); insert house values('house 3', 'owner 1'); insert pet values('house 1', 'owner 1', 'dog'); insert pet values('house 1', 'owner 1', 'cat'); insert pet values('house 2', 'owner 1', 'duck'); insert pet values('house 3', 'owner 1', 'bird'); as can see i'm using composi

opengl - how to make my cube rotate using the key functions from the keyboard -

im creating simple textured cube im have problem keyboard functions not seem interact,i want cube move in x , y direction not moving,i used function void specialkeys( int key, int x, int y ) { if (key == glut_key_right) rotate_y += 5; else if (key == glut_key_left) rotate_y -= 5; else if (key == glut_key_up) rotate_x += 5; else if (key == glut_key_down) rotate_x -= 5; glutpostredisplay(); } and in main function used code glutspecialfunc(specialkeys); this whole code #include <stdlib.h> #include <gl/glut.h> #include "rgbimage.h" void specialkeys(); double rotate_y=0; double rotate_x=0; glfloat xrotated, yrotated, zrotated; gluint texture[1]; // storage 1 texture ( new ) void loadtexturefromfile(char *filename) { glclearcolor (0.0, 0.0, 0.0, 0.0); glshademodel(gl_flat); glenable(gl_depth_test); rgbimage thetexmap( filename ); glgentextures(1, &texture[0]); // create textur

client - Teradata - run a file/script at Unix Linux command prompt -

i have client/ttu installed on unix box teradata. if following, works. "..." teradata bteq normal output , once following done, i'm @ prompt. $ bteq ... .... . logon dbname/dbuser,dbpassword select date, time; .logoff; .quit; .. ... $ now, lets put following lines in file called " testtd.bteq " . logon dbname/dbuser,$dbpassword select date, time; .logoff; .quit; what want ... how can run script (.bteq) @ unix $ prompt ??? i tried following methods far, didn't work, may im missing anything: 1. bteq < /path/to/testtd.bteq > testtd.log 2. bteq < .run /path/to/testtd.bteq heredocendshere any ideas? have provide ". logon dbname/dbuser,dbpassword" first, if i'm using heredocument way? running bteq command on $ prompt doesn't give me help/options can use, other commands. i.e. cmd -u user -p password -f file etc... the best practice i'm aware of store teradata credentials in ~/.tdlogon file

neo4j - When deleting a relationship, does an index that points to that relationship get removed before reclamation of the relationship id? -

when deleting relationship, index points relationship removed before reclamation of relationship id? believe i'm seeing weird issue i'm not able reproduce high degree of certainty. i have relationship i'm putting in index , referencing uuid. when delete bunch of relationships in neo4j , , add bunch, think of relationship id's being reused(i know standard , i'm okay this). deleting of relationships delete, i'm not removing index held them. when go index , search uuid, bunch of bad results, ie unexpected items code never put in there. i know practice remove entity index, has seen problem before? expected behavior? are using auto-indexes? (if not, how indexes work until 2.0.) when you're not using auto-indexes, have explicitly add , remove things indexes. indexes pointers node ids or rel ids.

Getting rid of "Attending?" in Android calendar event, using the Calendar API -

i'm creating local calendar on android device, , inserting events this. here code (using dummy data now): public static uri createcalendarwithname(context ctx, string calendarname, string displayname, account account) { uri target = uri.parse(calendarcontract.calendars.content_uri.tostring()); target = target.buildupon().appendqueryparameter(calendarcontract.caller_is_syncadapter, "true") .appendqueryparameter(calendarcontract.calendars.account_name, account.name) .appendqueryparameter(calendarcontract.calendars.account_type, account.type).build(); contentvalues values = new contentvalues(); values.put(calendars.account_name, account.name); values.put(calendars.account_type, account.type); values.put(calendars.name, calendarname); values.put(calendars.calendar_display_name, displayname); values.put(calendars.calendar_color, calendar_color); values.put(calendars.calendar_access_level, calendarcontract.calendars.cal_access