Posts

Showing posts from June, 2012

regex - how to do recursive replacement with incremented alphanumeric value in a file using sed/awk/perl -

how can make shell script using sed or awk recursive replacement of same value incremented alphanumeric values , inside again recursive incremented alphanumeric values. should happen till nth value end of file ---input file follow---- <first line has same value testname="tran cont" enabled="true"> <inner first line has url testname="/" enabled="true"> <inner second line has url testname="/test/dui/views?" enabled="true"> <first line has same value testname="tran cont" enabled="true"> <inner first line has url testname="/test/tedi/perf" enabled="true"> <inner second line has url testname="/dest/content/surf" enabled="true"> <inner third line has url testname="/cest/dui/duff" enabled="true"> <first line has same value testname="tran cont" enabled="true">

android - why fragment can't hide bottom bar -

why fragment can't hide bottom bar but activity can hide top , bottom use following code : view decorview = getwindow().getdecorview(); int uioptions = view.system_ui_flag_hide_navigation| view.system_ui_flag_fullscreen; decorview.setsystemuivisibility(uioptions); getactionbar().hide(); fragment side didn't work i try answer 1 still not work when touch fragment area show top , bottom ,let me confused lot following code: (fragment side) @override public void oncreate(bundle savedinstancestate) { view decorview = getactivity().getwindow().getdecorview(); int uioptions = view.system_ui_flag_hide_navigation|view.system_ui_flag_fullscreen; decorview.setsystemuivisibility(uioptions); getactivity().getactionbar().hide(); } @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view rootview = inflater.inflate(r.layout.fragment_ge, container, false); return rootview; }

c# - How to pass Datatable to SQL Server using asp.net -

i working on asp.net web application passing datatable asp.net application sql server stored procedure. my table in sql server student(id bigint, name nvarchar(max), reg bigint). in table, id primary key , auto incremented. c# code pass datatable stored procedure on button click is: protected void btnsubmit_click(object sender, eventargs e) { try { datatable dt = new datatable("student"); dt.columns.add("reg", typeof(long)); dt.columns.add("name", typeof(string)); // create new row (int = 0; < 3; i++) { datarow newrow = dt.newrow(); if (i == 0) { newrow["name"] = "raunak"; newrow["reg"] = convert.toint64(1); ; } if (i == 1) { newrow["name"] = "vikash"; newrow["reg"] = convert.toint64(1);

refresh - Stop listview from updating previous items and only update current items -

i new here. few months started learn android , want create listview , parent & child relationship, when clicking parent value in child value should me modified. did. problem when clicking 1st parent it's working fine while clicking 1 values getting refresh. my code //int slno = 1; int rs; int pcount =1; int finalrs; string ip_address, url, tableno, itmename; private string item_name = "itemname"; private string item_price = "price"; int in, totalqut , totalv; string strvalp; //public activity activity; //initialize variables private static final string str_checked = " has checked!"; private static final string str_unchecked = " has unchecked!"; private int parentclickstatus=-1; private int childclickstatus=-1; private arraylist<par

javascript - Audio Player in HTML 5 not working properly in chrome.(Forward & Rewind play) -

i having problem in running html5 audio player in chrome.it working fine in ie 9+ , firefox. have written javascript functions forwarding , rewinding audio player on f7 & f8 key press,its woring fine in ie , ff reasons not working in chrome.following code. $(document).keydown(function (e) { if (e.keycode == 118) { rewindaudio(); return false; } else if (e.keycode == 119) { forwardaudio(); return false; } } // rewinds audio file 30 seconds. function rewindaudio() { // check audio element support. if (window.htmlaudioelement) { try { var oaudio = audioplayerinfocus[0]; oaudio.currenttime -= 1.0; } catch (e) { // fail silently show in f12 developer tools console if (window.console && console.error("error:" + e)); } } } // fast forwards

php echo variable stored in mysql field -

i'm trying find out how can echo variable name stored in mysql database. example: in field 'variable' of table have stored: $target["year"] php code: $target["year"]="2013"; while ($row = mysql_fetch_array($query)) { echo $row['variable']; // output should 2013 } i read article variables variable on php.net can't find solution problem

jquery - Check @media rule with javascript by detecting css rule -

i know matchmedia.js thinking detect current @media rule easy this. however, it's not working in firefox – (which means it's not correct in first place...) looking @ now, shouldn't content on :after pseudo element? advice? have codepen here: css #test { content: "small" } @media screen , (min-width: $bp1) { #test { content: "medium" } } jquery var sizecheck = function() { if ( $("#test").css('content') === 'small') { $('.proof').text('jquery knows page small reading css @media rules.'); } else if ( $("#test").css('content') === 'medium') { $('.proof').text('jquery knows page medium reading css @media rules.'); } }; // run function on document ready $(document).ready(sizecheck); // , run function on window resize event $(window).resize(sizecheck); you've got quite interesting test there! to answer question: ye

python - Server sent events with Flask and Tornado -

i have been playing around sending server sent events flask , tornado. took @ blog article: https://s-n.me/blog/2012/10/16/realtime-websites-with-flask/ i decided try writing own flask app send server sent events exercise. here code flask app called sse_server.py: #! /usr/bin/python flask import flask, request, response, render_template tornado.wsgi import wsgicontainer tornado.httpserver import httpserver tornado.ioloop import ioloop app = flask(__name__) def event_stream(): count = 0 while true: print 'data: {0}\n\n'.format(count) yield 'data: {0}\n\n'.format(count) count += 1 @app.route('/my_event_source') def sse_request(): return response( event_stream(), mimetype='text/event-stream') @app.route('/') def page(): return render_template('index.html') if __name__ == '__main__': print "please open web browser http://127.0.0.1:5000." # spin app http_serv

android - MediaRecorder start failing -

i start failed: -19 when try run following code, pretty sure have elements need begin video capture, have surfaceview set camera preview , below rest of code initialized in @override public void surfacecreated( surfaceholder surfaceholder ) i e/mediarecorder﹕ start failed: -19 when trying run method starts recorder. there else need add before starting actual recorder? if(mcamera == null) { mcamera = camera.open(); mcamera.unlock(); } if(mrecorder == null) mrecorder = new mediarecorder(); try { mrecorder.setcamera( mcamera ); mrecorder.setvideosource(mediarecorder.videosource.camera); mrecorder.setaudiosource(mediarecorder.audiosource.mic); mrecorder.setoutputformat(mediarecorder.outputformat.mpeg_4); //audio mrecorder.setaudioencoder(mediarecorder.audioencoder.amr_nb); //video mrecorder.setvideoencoder(mediarecorder.videoencoder.mpeg_4_sp); mrecorder.se

css - Convert a horizontal menu into vertical -

i have horizontal menu need convert vertical menu (using @media when width below threshold). i working on menu provided here however not able convert menu vertical one. tried display:inline; , position:relative not working. any appreciated. have got relevant code in fiddle . thanks as per have understood when use on mobile device want make navigation vertical, if case can use media queries eg : @media (max-width: 600px) {ul.menu li {float: none !important;}} you can reffer http://dabblet.com/gist/11203269 note: there no need use important demo

ruby on rails - Heroku and Development behaving differently -

i have app runs bug fixes correctly on dev machine. stopped using sqlite3 , use pg in local machine. i deployed app new heroku app still behaves differently on production , development. here how push heroku. >git commit files have modified > git push origin master > git push heroku master the other difference pg on local machine 9.3.2 , pg on heroku seems 9.3.3 same code behaves in differently. appreciated. def pro_user @pro_user = subscription.where(:email => current_user.email).pluck(:email) rescue activerecord::recordnotfound end view code follows : <% if current_user %> <% if pro_user.empty? %> <!-- not premium user logged in user free stuff --> <% else %> <!-- premium user display --> <% end %> <% else %> <!-- not logged in--> <% end %>

apache - How to change date format in solr yyyy-mm-ddThh:mm:ssZ into " yyyy-mm-dd"? -

i want change default date format in solr "yyyy-mm-ddthh:mm:ssz" "yyyy-mm-dd". change date format file should change inside solr folder? , configuration file can configure date foramt? the date format used restricted form of canonical representation of datetime in xml schema specification . can not change solr default date format. and schema.xml file configure date field. example: <field name="date" datetimeformat="yyyy-mm-dd't'hh:mm:sss'z'" indexed="true" multivalued="false" stored='true' type="date"> </field>

Read video using VideoReader function in Matlab? -

i want read video folder , extract frames it.i used vidoereader function.but gives error.my code shown below along error. mov=videoreader('11.mp4'); vidframes=read(mov); nframes=mov.numberofframes; i=1:nframes imshow(vidframes(:,:,i),[]); end and error show given below error using videoreader/init file not appear have video data. error in videoreader (line 147) obj.init(filename); error in video (line 7) mov=videoreader('11.mp4'); i think matlab version related problem. faced same problem when using matlab 2013a . however, when changed matlab 2014b problem disappeared.

mysql - Following SQL query returns resultset for only available months, how to get all month if data is not present? -

following query gives result-set available months , how can months if data not present . eg:- apr-2013 , may-2013 having value june-2013 no value how can june-2013 in result set total 0 . select concat(substr(monthname(fileddate) , 1, 3) , "-", year(fileddate)) month, count(*) carstore store=20 , (soldstate = 2 or soldstate = 3) , cartype '%toyoto%' , fileddate between date('2013-04-07') , date('2014-04-30') group month order year(fileddate), month(fileddate) ; +----------+----------+ | month | count(*) | +----------+----------+ | apr-2013 | 2 | | may-2013 | 2 | | jul-2013 | 14 | | aug-2013 | 3 | | sep-2013 | 2 | | nov-2013 | 4 | | dec-2013 | 19 | | jan-2014 | 61 | | feb-2014 | 21 | | apr-2014 | 3 | +----------+----------+

Apache storm 9.2 missing in storm-starter -

i download storm-starter github: https://github.com/apache/incubator-storm/tree/master/examples/storm-starter there missing dependency: <dependency> <groupid>org.apache.storm</groupid> <artifactid>storm-core</artifactid> <version>0.9.2-incubating-snapshot</version> <!-- keep storm out of jar-with-dependencies --> <scope>provided</scope> </dependency> with 0.9.1-incubating meven resolve dependency. can use in storm-starter example? there incompatibilities? this how solved problem. first of have tu use version 0.9.1-incubating (with "0.9.2-incubating-snapshot" maven can not solve dependency). secondly, using eclipse, add org.eclipse.m2e plugin. notice comment: <!--this plugin's configuration used store eclipse m2e settings only. has no influence on maven build itself.--> this not true seems tag <versionrange>[1.3.18,)</versionrange> causes download of

ms word - How to write a VBA script to insert, move and text wrap an image -

i making vba script generate default pages template document, going except when try insert image right aligned , text wrapped. used vba many years ago excel not sure how structure vba script. started making vba script image later integrated can find below. what want achieve vba script for insert image file within same directory template file (do have put full path or can put truncated 1 specify in same directory?) for inserted image square text wrapped (default distances) for image aligned left margin relative line have inserted in the height of image @ 200 x 150 would kindly able elaborate on mwe have below. thank you: sub insert_picture() ' ' insert_picture macro ' dim imagepath string imagepath = "c:\users\edoardo\documents\my work\phd\skydrive\tutoring\houria\image replacement.jpg" activedocument.shapes.addpicture filename:=imagepath, _ linktofile:=false, _ savewithdocument:=true, _ left:=-5, _ top:=5, _ ancho

ios - Crash on iOS7, but works fine on iOS6 devices -

team, i upgrading application ios7. seeing inconsistent crashes in application when pushed app background , play around other apps , bring application foreground , perform actions, crashes.. not able reproduce crash without pushing application background. device logs: apr 18 04:15:36 iphone-5c adtcommercial[7516] <notice>: +[datautil isdiscountavalablefor:] - set number of records: 0 joblinetype: rental apr 18 04:15:37 iphone-5c adtcommercial[7516] <notice>: amountthresholdvalue: 0.000000 type: parts apr 18 04:15:37 iphone-5c adtcommercial[7516] <notice>: amountthresholdvalue: 0.000000 type: parts apr 18 04:15:37 iphone-5c adtcommercial[7516] <notice>: amountthresholdvalue: 0.000000 type: labor apr 18 04:15:37 iphone-5c adtcommercial[7516] <notice>: amountthresholdvalue: 0.000000 type: labor apr 18 04:15:37 iphone-5c adtcommercial[7516] <notice>: amountthresholdvalue: 0.000000 type: tripfee apr 18 04:15:37 iphone-5c adtcommercial[7516] <

html - Preview page on link hover -

quick question: can enable website preview on of links in web page? i.e. when user moves mouse on link in page, want show simple popup window loads page in link. if it's important, i'm using asp.net you can use iframe tag display page. <iframe src="http://www.example.com"></iframe> your html <a class="tiptext">a link <iframe class="description" src="http://www.example.com"></iframe> </a> your css .tiptext { color:#069; cursor:pointer; } .description { display:none; position:absolute; border:1px solid #000; width:400px; height:400px; } your js $(".tiptext").mouseover(function() { $(this).children(".description").show(); }).mouseout(function() { $(this).children(".description").hide(); }); jsfiddle: http://jsfiddle.net/yboss/q29tp/

subprocess - Automate stdin with Python using stdin.write() -

i trying automate setup of generating self-signed ssl certificate. code: #!/usr/bin/env python import subprocess pass_phrase = 'example' common_name = 'example.com' webmaster_email = 'webmaster@example.com' proc = subprocess.popen(['openssl', 'req', '-x509', '-newkey', 'rsa:2048', '-rand', '/dev/urandom', '-keyout', '/etc/pki/tls/private/server.key', '-out', '/etc/pki/tls/certs/server.crt', '-days', '180'], stdout=subprocess.pipe, stdin=subprocess.pipe, stderr=subprocess.pipe) in range(2): proc.stdin.write(pass_phrase) in range(5): proc.stdin.write('.') proc.stdin.write(common_name) proc.stdin.write(webmaster_email) proc.stdin.flush() stdout, stderr = proc.communicate() when run it, still prompts me pem passphrase, returns error: country name (2 letter code) [xx]:weird input :-( problems making certificate request it should

How to replace a substring in C when the substring is similar to the replacement string? -

i've created program in c uses strstr , strncpy , , sprintf functions replace substrings replacement string. flaw program when looking replace e.g. searching "the" , wanting replace "there", causes infinite loop, program keeps finding replaced. how fix in c, or there way implement such function in c? thanks. replacement function: (its called multiple times until there no longer matches found). char *searchandreplace(char *text, char *search, char *replace){ char buffer[max_l]; char *ptr; char *modtext = malloc(4096); if(!(ptr = strstr(text, search))){ return; } strncpy(buffer, text, ptr-text); sprintf(buffer+(ptr-text), "%s%s", replace, ptr + strlen(search)); strcpy(text, buffer); you can return pointer place in original string after previous replacement, , call function next time using pointer instead of original pointer. note should use strncpy instead of strcpy everywhere in code below, tr

core - Object Creation in java and finalize -

class fdemo { int x; fdemo(int i) { x = i; } protected void finalize() { system.out.println("finalizing " + x); } void generator(int i) { fdemo o = new fdemo(i); system.out.println("creat obj no: " + x); // line } } class finalize { public static void main(string args[]) { int count; fdemo ob = new fdemo(0); for(count=1; count < 100000; count++) ob.generator(count); } } } in line have commented, value of x shows 0(value of x in object ob), why isnt showing value of object o?? know if use o.x ll getting value of x in object o. still in code why show value of abject ob rather object o?? if want reference x in fdemo you've created, should add getx() function , call instead of x, david wallace said. (i prefer using getters instead of .variable). add class: public int getx(){ return x; } and change prob

java.util.scanner - Java Scanner: Continuous loop -

when input valid option (a,b,c) if statement thinks option a, b, or c, , lead continuous loop. package other; import java.util.scanner; public class menu implements interfacemenu{ private string option; public void greeting(){ system.out.println("this program use pythagorean theorem"); system.out.println("to calculate missing side.\n"); system.out.println("choose option!\n"); system.out.println("choose option missing side c"); system.out.println("choose option b missing side b"); system.out.println("choose option c missing side a\n"); } public string optionget(){ system.out.print("choose option: "); scanner ad = new scanner(system.in); option=ad.next().touppercase(); if( (option=="a") || (option=="b") || (option=="c") ){ ad.close(); } else{ optionget(); } return option; } } aside using wrong

java - ThreadPoolExecutor With PriorityBlockong Queque do not create(dynamicly) non core Thread -

here qu see priority threadpoolexecutor - work good, problem not create new thread if number of сorepool еhread achieved. import java.util.comparator; import java.util.concurrent.callable; import java.util.concurrent.future; import java.util.concurrent.futuretask; import java.util.concurrent.priorityblockingqueue; import java.util.concurrent.rejectedexecutionhandler; import java.util.concurrent.runnablefuture; import java.util.concurrent.threadfactory; import java.util.concurrent.threadpoolexecutor; import java.util.concurrent.timeunit; /** * created ngrigoriev on 4/24/14. */ public class priorityexecutor extends threadpoolexecutor { public priorityexecutor(int corepoolsize, int maxpoolsize, int quequsize) { super(corepoolsize, maxpoolsize, 60l, timeunit.seconds, new priorityblockingqueue<>(quequsize, new prioritytaskcomparator())); } public priorityexecutor(int corepoolsize, int maxpoolsize, long time, timeunit unit, int quequsize) { super(

java - application crashing however logcat shows no Caused by: -

my application crashing while submitting on register page logcat not showing caused (i think might php server app making crash im unsure) if there code link me show issue please comment , try , help. 04-24 10:36:43.910: e/androidruntime(8764): fatal exception: main 04-24 10:36:43.910: e/androidruntime(8764): java.lang.nullpointerexception 04-24 10:36:43.910: e/androidruntime(8764): @ com.loggedin.login$processlogin.onpostexecute(login.java:173) 04-24 10:36:43.910: e/androidruntime(8764): @ com.loggedin.login$processlogin.onpostexecute(login.java:1) 04-24 10:36:43.910: e/androidruntime(8764): @ android.os.asynctask.finish(asynctask.java:631) 04-24 10:36:43.910: e/androidruntime(8764): @ android.os.asynctask.access$600(asynctask.java:177) 04-24 10:36:43.910: e/androidruntime(8764): @ android.os.asynctask$internalhandler.handlemessage(asynctask.java:644) 04-24 10:36:43.910: e/androidruntime(8764): @ android.os.handler.dispatchmessage(handler.java:99) 04-24

XSLT: Add content to an XML depending on conditions -

i trying transform xml-file xml-file, content added in case not provided. my xml looks this: <bookstore> <book> <title>book1</title> <author>author1</author> <chapters> <chapter> <ch-name>blabla</ch-name> <ch-number>1</ch-number> </chapter> </chapters> </book> <book> <title>book2</title> <author>author2</author> <chapters> <chapter> <ch-name>test</ch-name> <ch-number>1</ch-number> </chapter> </chapters> </book> <book> <title>book3</title> <author>author3</author> </book> </bookstore> now, want add chapters element (and child elements) books, does