Posts

Perl - how to grep a block of text from a file -

it can in xml or text format. how in general grep block of text in perl? <track type="ws"> <range> <rangestart>0</rangestart> <rangeend>146.912</rangeend> <locationindex>0</locationindex> <propertyindex>0</propertyindex> </range> </track> <track type="ps" id="1"> <range> <rangestart>0</rangestart> <rangeend>146.912</rangeend> <locationindex>1</locationindex> <propertyindex>1</propertyindex> </range> </track> i want grep type="ps" , till </range> . one solution open file, read line line , match block. open(fh, "file.txt"); foreach $line (<fh>) { if ($line =~ m/type="cc"(.*?)<\/range>/) { print $1; } } but there more optimal solution without reading file line l...

android Nullpointerexception with intent data=null always -

i creating app, contains 3 activities, say, a, b , c. activity main activity, launches when app opens. activity called activity b using startactivityforresult(intent, 1); activity b returns result, captured, , within onactivityresult of activity a, launching activity c using startactivityforresult(intent2, 2); here onactivityresult activity a @override protected void onactivityresult(int requestcode, int resultcode, intent data){ log.d("main","inside on activity result requestcode : " + requestcode); if(requestcode == 1){ if(resultcode == result_ok){ log.d("mainact", "inside result code ok"); if(data.getstringextra("puzzleid")!=null){ log.d("mainact", "inside puzzle has been selected"); string puzzleidresult = data.getstringextra("puzzleid"); intent puzzleintent = new intent(mainactivity.this, trialactivity.cla...

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

Image
if set mycoolbar.fixedorder true,only grip on first band hidden. well,if use delphi 7 create vcl forms application,then put coolbar on , create 3 coolbans hold other controls,only grip , top coolbands can hidden setting mycoolbar.fixedorder:=true. i've uploaded picture make things clear. you got fixedorder property wrong. fixed property not allow bands rearranged if set true . setting property of coolbar true keep user changing bands order @ runtime, user can still move , resize bands. can give advice can do, actual solution problem, well, have wait answer. my advice use 3 coolbars in row , setting "fixedorder" property true , bandborderstyle bsnone . way grip hidden on of them. about property, it's not bug of ide, actual preference of property.

mysql - Can PHP 5.4 run on PHP 5.3 configured server -

first of all, novice web developer. my question "a website developed php 5.4 can run on php 5.3 configured server?" (detail description) configure myself apache 2.4, mysql 5.6 , php 5.4.12 on windows. everything's ok. errors occur when changed website folder machine configured wampserver. wampserver configured apache 2.2.11, php 5.3 , mysql 5.1.36. i install mysql 5.6 on machine , database connected. "parse error occur code" such $country = mysql_fetch_row(querymysql("----"))[0]; in addition, showed other errors such "table 'emp.productcateogry' doesn't exist". please, give me suggestions. the short answer is: no, should not expect to, if using new features of php 5.4 within code. the specific error referring with: parse error occur code is because line $country = mysql_fetch_row(querymysql("----"))[0]; is using new feature: function array dereferencing which, prior php...

connection - Bluecove : restart bluetooth stack programmically -

i'm trying close bluetooth service, bluecove has bug on connection close method ( https://code.google.com/p/bluecove/issues/detail?id=90 ) , trying workaround restart service. think restarting bluetoot stack solve problem. can programmically? i'am using microsoft bluetooth stack. problem solved in way. i restart application, firstly shut down bluecove manually. bluecoveimpl.shutdown(); if restart application, bluecove shut down, cannot initialize bluetooth stack during start. here restart method: public static void restartapplication(runnable runbeforerestart) throws ioexception { try { // java binary string java = system.getproperty("java.home") + "/bin/java"; // vm arguments list<string> vmarguments = managementfactory.getruntimemxbean() .getinputarguments(); stringbuffer vmargsoneline = new stringbuffer(); (string arg : vmarguments) { ...

how to use preloader in Grid View in android -

Image
i want use preloader image in gridview images when loading form remote server. while loading server @ time want show preloader image this(same progress bar or progress bar). i want show small progress bar there in gridview image item or preloader image dnt know can use me achieve this. can please me how can thing in android. i want make ios. image form ios. here android layout xml file : activity_image_grid.xml <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" > <include android:id="@+id/title_bar" android:layout_alignparenttop="true" layout="@layout/activity_top_header_bar" /> <gridview android:id="@+id/gridview" android:layout_width="fill_parent" an...

javascript - Animating array of divs; only the final element is modified -

this baffling me @ moment. i'm experienced programmer looking throw bit of surprise fiancee on countdown page our wedding. desired effect simulated confetti falling behind main page. setup follows: i have array of divs in javascript. each div absolutely positioned on page. have interval set updates every 50 or milliseconds. on each tick, run loop on array of divs, , calculations , update positions. problem problem having, however, though can see divs created, stored array, , modified (in case, each has slight randomized rotation) during initialization phase, once tick update position starts, div stored in whatever last slot of array gets position updated. tried hard-coding each div index testing purposes, strictly last element update position. upon printing current "left" , "top" style values each div before , after calculations shows value has been changed, no visible change noticeable. here's basic code: javascript var container; ...

Java endpoint - perl consumer web service -

i've problem calling java endpoint (code below) perl client (activeperl 5.16). code snippets book java web services , running package ch01.ts; import javax.jws.webmethod; import javax.jws.webservice; import javax.jws.soap.soapbinding; import javax.jws.soap.soapbinding.style; @webservice @soapbinding(style=style.rpc) public interface timeserver { @webmethod string gettimeasstring(); @webmethod long gettimeaselapsed(); } package ch01.ts; import java.util.date; import javax.jws.webservice; @webservice(endpointinterface="ch01.ts.timeserver") public class timeserverimpl implements timeserver { public string gettimeasstring() { return new date().tostring(); } public long gettimeaselapsed() { return new date().gettime(); } } package ch01.ts; import javax.xml.ws.endpoint; public class timeserverpublisher { public static void main(string[] args) { endpoint.publish("http://127.0.0.1:9876/ts...

android - how to show inbox messages in list view -

i want show inbox messages in list view. have tried many way's seem there error .. can tell different approach . public class inbox extends listactivity { arraylist<string> listitems = new arraylist<string>(); arrayadapter<string> adapter; protected void oncreate(bundle savedinstancestate) { uri urisms = uri.parse("content://sms/inbox"); cursor c = getcontentresolver().query(urisms, null, null ,null,null); if(c.movetofirst()) { for(int i=0; < c.getcount(); i++) { string body = c.getstring(c.getcolumnindexorthrow("body")).tostring(); listitems.add(body); c.movetonext(); } if(listitems.isempty()) listitems.add(...

delphi - Show error message that is raised from SQL Server -

i use "adoconnection" connect sql server , use below code in adoquery : begin try ... end try begin catch raiserror(ltrim(str(error_number()))) end catch when call error message : "adoconnection.errors[0].nativeerror" returns "5000" and when call error message : "adoconnection.errors[0].number" returns negative number! how can right error number sql server? all own errors mssql have error_number 50000. can register own messages using sp_addmessage , using them clumsy. mssql 2012 have new keyword throw , want. so can on 2008, assuming recover failure in catch block: you can construct own error message, in exception.message error_number worthless error_severity severity different purposes hey, there error_state, can use :) for stored procedures, can use return value or output parameter passing information success or failure begin try begin tran -- -- code -- if @@rowcount = 0 or @someyourval...

iphone - Event handling in subclass of UIView -

as guide event handling guide ios mentions, when create own subclass of uiview: all views process touches expect receive full touch-event stream, when create subclass, keep in mind following rules: - if custom responder subclass of uiview or uiviewcontroller, should implement of event handling methods. - if subclass other responder class, can have null implementation of event methods. **- in methods, sure call superclass implementation of method.** however in "best practices handling multitouch events" part of guide, says: if handle events in subclass of uiview, uiviewcontroller, or uiresponder: - implement of event handling methods, if implementations of methods nothing. **- not call superclass implementation of methods.** if handle events in subclass of other uikit responder class: - not have implement of event handling methods. **- in methods implement, sure call superclass implementation. example, [super touchesbegan:touches withevent:event]....

c++11 - How to enable C++ multithreading? -

i've been trying multithreaded c++. installed new dev c++ 5.4.1 , added -std=c++11 compiler options. added #include <thread> somewhere in source code, , std::thread mythread (some_func) . when compile source file, compiler error "thread defined in scope". what have have working? official build of mingw (that compiler dev-c++ uses) has no support standard library threads now. you can use boost::thread drop in replacement (api similiar enough) or use microsoft visual c++, or try programming g++ on linux (this have done recently, using virtual machine).

OCaml standard committee? -

i doing presentation on ocaml, want put if there standard comittee or not. searched internet far , wide , couldn't answer that, asking here. ocaml not follow national or international standard. language whatever gallium (formerly cristal) group @ inria want be.

python huffman coding Exception Unorderable Types -

i trying write huffman coding in python 3 code http://en.literateprograms.org/huffman_coding_%28python%29 doesn't work. if run code in python 2.7, works well. the following lines problem: heapq.heapify(trees) while len(trees) > 1: childr, childl = heapq.heappop(trees), heapq.heappop(trees) parent = (childl[0] + childr[0], childl, childr) heapq.heappush(trees, parent) i typeerror in heapq.heappush(u,parent): "unorderable types: tuple() < str()" so i've searched solution, , think, have implement _ lt _ function. possible 2 or more nodes have same frequency, heapq tries compare tuples , think, can't compare tuple of tuple. dont know , how have create compare-method solve problem? can help? ;-) the reason in python3x can't compare items of 2 different type: >>> "foo" < 1 traceback (most recent call last): file "<ipython-input-5-de2fb49cc8c4>", line 1, in <module> "f...

java - Android metadata with manifest file - nullPointerException -

i attempting access metadata activity manifest file. the manifest looks : <activity android:name="co.uk.benbun.nvrrclubapp.mainactivity" android:label="@string/app_name" > <meta-data android:value="newstag" android:name="news"></meta-data> <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> the code access it, looks : try { applicationinfo ai = getpackagemanager().getapplicationinfo(this.getpackagename(), packagemanager.get_meta_data); bundle bundle = ai.metadata; string myapikey = bundle.getstring("news"); } catch (namenotfoundexception e) { log.e("metadata", "failed load meta-data, namenotfound: " + e.getmessage()); ...

javascript - How to make time function update itself? -

when load in browser it'll show time when page loaded, won't update every second. how do this? var h = date.gethours(); if(h<10) h = "0"+h; var m = date.getminutes(); if(m<10) m = "0"+m; var s = date.getseconds(); if(s<10) s = "0"+s; document.write(h + " : " + m + " : " + s); use setinterval : setinterval(clock, 1000); function clock() { var date = new date(); var h = date.gethours(); if(h<10) h = "0"+h; var m = date.getminutes(); if(m<10) m = "0"+m; var s = date.getseconds(); if(s<10) s = "0"+s; document.write(h + " : " + m + " : " + s); } although want update html element rather document.write page every second. http://jsfiddle.net/bqnwj/

Can't add member into MongoDB replica-set -

i using mongodb 2.4.3, , following wizard: http://docs.mongodb.org/manual/tutorial/deploy-replica-set/ but when adding other members replica-set, following error: root@vm3:~# mongo mongodb shell version: 2.4.3 connecting to: test rs1:primary> rs.add("vm1") { "errmsg" : "exception: set name not match set name host vm1:27017 expects", "code" : 13145, "ok" : 0 } rs1:primary> rs.add("vm4") { "errmsg" : "exception: set name not match set name host vm4:27017 expects", "code" : 13145, "ok" : 0 } vm1, vm3 , vm4 know each other because configured /etc/hosts files correctly. any idea? don't understand error message mean! after restarting vms, works now. root@vm3:~# mongo mongodb shell version: 2.4.3 connecting to: test rs1:primary> rs.add("vm4") { "ok" : 1 } rs1:primary> rs.add("vm1") { "ok" : 1 ...

sed - How to process only one column and convert unix time in text file in BASH -

i have text file table like 367612510.243586 717.860170 367612512.493918 722.249134 367668441.429983 692.407935 367668479.810461 692.407935 367668482.618858 727.953771 367668515.150386 727.953771 where first column unix time, , second value. want display list human readable date , time in bash. how it? it possible additional script file , xargs, i'm looking way in 1 line. try awk '{print strftime("%c",$1)}' input.txt another approach using while-loop in bash while read d _; date -d @$d; done < input.txt update: bash solution print second field well while read f1 f2; echo $(date -d @$f1) $f2; done < input.txt

html - Is it possible to use the URL to change the CSS being applied? -

i have 2 pages have related topics, , share significant amount of data & text between 2 pages. since these 2 pages both linked same location, side side, wondering if can use argument link change css being applied , have data on 1 page. the original setup: domain.com/subdir/one.page.php domain.com/subdir/two.page.php can use instead? domain.com/subdir/full.page.php?one domain.com/subdir/full.page.php?two and that, have page selectively use css visible attribute change displayed on screen? no, css cannot affected url. instead, should use server-side programming language display appropriate content.

java - Can't get System.exit() to work in dragon12 project -

i have working system.exit(0) . should exit time remaining if button pressed. i'm not sure do. appreciated. /* creates perfect hard-boiled(simulates 12 minutes in boiling water) or soft-boiled egg(simulates 6 minutes in boiling water). both options require 10 seconds of rinsing under cold water after necessary time boiling. allow user exit remaining time. */ import java.io.*; import java.util.*; public class advancedeggmaker { public static void main(string[] args) { mcu mcu = null; try { mcu = new mcu(new communicator(args[0])); } catch (ioexception e) { system.out.println(e); } mcu.println("sw2 - hb egg", 0); mcu.println("sw3 - sb egg", 1); while (true) { int sw = mcu.getswitch(); if (sw == 2) { mcu.println("hard boiled egg", 0); mcu.println("place egg in...