Posts

Showing posts from 2013

c++ - How to use shared libraries in a static library without forcing end-users to link against these? -

let's i'm working on static library foo.a , makes use of function in bar.so . how build library in such way uses foo.a in project doesn't have explicitly link against bar.so ? what can in libfoo.a make call dlopen dynamically link libbar.so . then, use dlsym locate function want use. typedef void (*barfunctiontype) (const char *); functiontype barfunction; void initialize_foo_lib () { void *h = dlopen("libbar.so", rtld_lazy); barfunctiontype barfunction = (barfunctiontype) dlsym(h, "barfunction"); // note scary looking cast function pointer. //... rest of code can call barfunction } libbar.so should c library, or function should extern "c" if c++ library, find function name properly. otherwise need mangle name find function dlsym . can use objdump -t on library check if names in library mangled. realize there still dependency on libbar.so , baked static library. user of libfoo.a not have add -lbar link line when link in -lfoo ...

Traverse through an XML DOM in jQuery -

i new jquery , trying learn. stuck problem. i have following response wcf service. <s:envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:header /> <s:body> <getlabeldetailsresponse xmlns="http://tempuri.org/"> <getlabeldetailsresult xmlns:a="http://schemas.datacontract.org/2004/07/rework" xmlns:i="http://www.w3.org/2001/xmlschema-instance"> <a:containerdetails> <a:barcodestatus>4</a:barcodestatus> <a:barcodestatusdesc /> <a:labelgs1>011030310036099721336</a:labelgs1> <a:labeltype>ea</a:labeltype> <a:numberofchildren>0</a:numberofchildren> <a:parentgs1>012030310036099421511</a:parentgs1> <a:parentserial>012030310036099421511</a:parentserial> <a:parenttype>cse</a:parenttype> <a:productcode>r0010221130</a:productcode> <a:productdescription>r0010221130-h-688 monobutyl ether</a:productdescr...

perforce - git p4 submit from a bare repository? -

we have devs pushing remote bare repo on server, , automate push perforce nightly using git p4 central bare repo. running snag because seems can't run git p4 submit outside of working tree. what's recommended way deal this? i similar script runs every few minutes , 2-way sync between git , p4. git-p4 can't work without both checked-out git tree , p4 repo. in end 3 versions of source: the bare git repo checked-out git repo 'git p4' work in p4 checkout submit p4 from. developers push bare git repo (held on gitolite), using branch called 'dev'. every few minutes, there's script does: update checked-out git tree (git pull --rebase) pull down latest upstream p4 changes p4/master (git p4 sync) rebase git world against p4 world (git rebase p4/master) send git changes p4 (git p4 submit) rewrite 'dev' branch (git push origin +head:dev) gotchas merge conflicts. these occur infrequently can cause few problems. i had add locking around...

stored procedures - Why is mysql caching the column names of a temporay table that is deleted? -

i've reduced issue down simple sp. column names getting cached in select * @ end. have no idea why or how stop it. tried adding sql_no_cache makes no difference. drop table if exists foo; create table foo( col1 int, col2 int); insert foo values(1,2),(3,4),(5,6); drop procedure if exists mysp; delimiter ;; create definer=root@localhost procedure mysp(c int) begin drop table if exists mydata; set @mycol='col1'; if c > 0 set @mycol:='col2'; end if; set @s=concat('create temporary table mydata select ', @mycol, ' foo'); prepare stmt @s; execute stmt; deallocate prepare stmt; -- following select call fails on 2nd , subsequent executions of sp select sql_no_cache * mydata; select "please see new temp table mydata" result; end ;; delimiter ; version mysql> select version(); +------------+ | version() | +------------+ | 5.5.15-log | +------------+ 1 row in set (0.00 sec) first run works fine expected mysql> call mysp(0); +------+ | c...

Query about Intent.ACTION_VIEW in android -

in intent.action_view intent? class or method , here action_view ? variable , type of it's ? please explain in details. thank you. intent in android abstract public class . action_view action on intent. public static final string action_view since: api level 1 activity action: display data user. common action performed on data -- generic action can use on piece of data reasonable thing occur. example, when used on contacts entry view entry; when used on mailto: uri bring compose window filled information supplied uri; when used tel: uri invoke dialer. input: getdata() uri retrieve data. output: nothing. constant value: "android.intent.action.view" you need read developers guide android. better understanding here .

jquery - How can I echo a message and return a code to AJAX from PHP -

all, i have ajax function, calls php url through html data type. cannot use other datatypes ajax requests due server constraints. trying print message , handle scenarios based on return code. following code doesn't seem work. can advise? here's simple ajax call: $.ajax({ type: "post", url: "validateuser.php", datatype: html, success: function(msg, errorcode){ if(errorcode == 10) { callafunction(); } else if(errorcode == 20) { callsomething(); } else { dosomethingelse(); } } }); php code: --------- <?php function validateuser() { $username = 'xyz'; if (!empty($username) && strlen($username)>5) { echo 'user validated'; return 10; } else if (empty($username)) { echo 'improper username'; return 20; } else if (strlen($username)<5) { echo 'username length should atleast 5 characters'; return 30; } exit; } ?> thanks your php function. not being called. also, not sending data php file.

python - How do I compare one index to the previous index within the same list? -

i'm trying make program @ each previous number in list, , determine if number bigger it. if is, should record how many times bigger, , return @ end. i.e. count (i'm using num variable) starts @ 0. 10 bigger 7 num becomes 1. 7 isn't bigger 20 count stays same. 20 bigger 15 count (num) 2. , 15 bigger 4 (count 3). 4 not bigger 6 (count not change) , 6 not bigger next number because there no next number. have now. i'm thinking lst[i] , lst[i+1] need used reference index maybe? can walk me through this? thanks. def count(lst): num = 0 sort of division here? add num variable? #main prog ( count([10, 7, 20, 15, 4, 6]) ) import numpy np def count(lst): return sum(np.diff(lst)>0) diff gives difference between successive elements, sum returns number of positive differences.

wso2esb - How can I access HTTPServletRequest object in WSO2 ESB 4.0.3 -

i looking @ http://wso2.org/forum/thread/10508 explains how httpservletrequest. explains if have "org.wso2.carbon.core.transports.http.*" request can httpservletrequest object. described did change axis2.xml change transports , worked. since "org.apache.synapse.transport.nhttp." (nio) trnasport fast loosing performance if that. is there way of keeping nio transport handlers ("org.apache.synapse.transport.nhttp.") , httpservletrequest object? i thankful if can answer. authentication done through cookies in existing data services , company not want change that. thanks abhijit this not possible. nio transport not servlet , not support http sessions , all. new wso2 server version have upgraded tomcat version normal http transport uses nio underline. i think need performance comparison , see latest release.

php - server not sending custom header values -

i'm using php 5.2.17 remote page, http requests contains cookie values cookies not delivered destination page. $url = 'http://somesite.com/'; $opts = array( 'http' => array ( 'header' => array("cookie: field1=value1; field2=value2\r\n") ) ); $context = stream_context_create($opts); echo file_get_contents($url, false, $context); can me find problem? note: can't use curl. thanks. are sure receiving code working properly? i can example work receiving page echoing: <?php echo $_cookie['field1'] . '::' . $_cookie['field2']; // returns value1::value2 ?> alternatively, site requiring user agent (anything). had problem earlier in reaching wikipedia (not restricted mediawiki software; apparently wikimedia sites). set user_agent property inside 'http' array whatever value want. (however, if happen trying reach wikipedia, might instead try api.php: http://en.wikipedia.org/w/api.php ; if mediawiki site...

Android Jsoup login to get response -

i trying response failure or success login mobile website. here part of code. edit public string login(string user, string pass) throws exception{ // create new httpclient , post header httpclient httpclient = new defaulthttpclient(); httppost httppost = new httppost(amwayurl); string result = "nothing"; try { // add user name , password string username = user; string password = pass; list<namevaluepair> namevaluepairs = new arraylist<namevaluepair>(2); namevaluepairs.add(new basicnamevaluepair("userid", username)); namevaluepairs.add(new basicnamevaluepair("userpswd", password)); httppost.setentity(new urlencodedformentity(namevaluepairs)); cookiestore cookiestore = new basiccookiestore(); httpcontext localcontext = new basichttpcontext(); localcontext.setattribute(clientcontext.cookie_store, cookiestore); httpresponse response = httpclient.execute(httppost, localcontext); result = inputstreamtostring(response.getentity().getcontent()).tos...

java - Is there a command decompiling tool supports Windows/Linux/AIX like JAD does for JDK5 class? -

i using jad (no longer update?) decompiling .class file, on aix or linux, jdk 5 class not supported jad, (replied @thilo , in thread ). i know decompiling tools based on jad, there such tool both provides commandline interface(i know dj has gui don't want it) can call java , supports jdk5 .class? thanks. yes, there one, french project hosted on free.fr. luckily you, archive.org´s wayback machine has indexed,including download binaries. it decompiles java 1.5 , 1.6 too. here link http://web.archive.org/web/20110416091052/http://java.decompiler.free.fr/

Releasing resources of Java 7 WatchService -

i using java 7 watchservice watch directories. change directories watching. run exception: java.io.ioexception: network bios command limit has been reached. after 50 directories. call close() on each watchservice create before creating new one. does know proper way release watchservice not run limit? thanks, dave i think all need close() service. know said think already, suspect missing some. instance, failing close service instances in case of exception. should treat watchservice instance other io resources , close in block; e.g. watchservice ws = ... try { // use ... } { ws.close(); } or using java 7 "try resource" syntax. try (watchservice ws = ...) { // use ... } when watchservice closed, should free o/s level resources holds. the other possibility have run java bug in watchservice implementation.

Is it possible to add Queue Data to DataTable in C#? -

i adding items in queue"<"string">" asynchronously queue.instead of inserting row row each data of queue using insert query, want add these items datatableonly when if(evtlogqueue.count==1000) . datatable used further bulk insert using bulkcopy sqlserverdb. i know possible do? if yes how? or other suggestion? sample code: static queue<string> evtlogqueue = new queue<string>(); public static void additemstoqueue(string itm) { evtlogqueue.enqueue(itm); console.writeline("length of queue:" + evtlogqueue.count); } yes possible , can adding code additemstoqueue(string itm) method. public static void additemstoqueue(string itm) { evtlogqueue.enqueue(itm); // add following code if (evtlogqueue.count == 1000) { datatable datatable = new datatable(); datatable.columns.add("log"); foreach (var log in evtlogqueue) { datarow dr = datatable.newrow(); dr["log"] = log; datatable.rows.add(dr); } evtlogqueue.clear(); // ne...

silverlight - How to show Splash screen image after deploy? -

i have 'silverlight ria' app customized splash screen image. seems work fine on client side. problem starts after deploy on server. image not shown anymore! first of all, had problems showing splash screen. but, after changed property of 'splashscreen.xaml' "content" became ok! still doesn't show image after deploy! suggestions on what's wrong , how can corrected? you should start url of image ../

cocos2d-iphone SimpleAudioEngine preload strategy -

what best strategy simpleaudioengine effects preload ? preload sound effects @ game startup ? or in each screen's creation preload effects used in screen ? loaded effects released @ point ? you preload if playing sound effect first time causes noticeable lag. action games want preload gameplay effects. turn-based or otherwise "slower paced" games may ok not preload sound effects. when , preload depends on needs. typically @ start of gameplay scene (ie during init or onenter). a preloaded effect not released unless call unloadeffect on it. internally audio engine caches sound effects, not exclusive preloading. playing sound effect load , keep in memory well.

Playframework 1.2.5 custom module never hit -

steps: play new-module firstmodule updated play.plugins file of module include 10:play.modules.firstmodule.myplugin create myplugin class: package play.modules.firstmodule; import play.logger; import play.playplugin; public class myplugin extends playplugin { @override public void onload() { logger.info("hello"); } @override public void onapplicationstart() { logger.info("hello"); } @override public void onroutesloaded() { logger.info("hello"); } } play build-module add module main project dependencies require: - play 1.2.5 - custommodules -> firstmodule repositories: - playcustommodules: type: local artifact: c:\github\firstmodule\dist\firstmodule-0.1.zip contains: - custommodules -> * play deps resolves dependencies correctly play run server starts , hit page, log message "hello" never printed. gives? got worked? i had add same play.plugins files main proyect /conf directory make work.

sql - How to get column value into row header -

id amount date ------------------------------ 1 300 02-02-2010 00:00 2 400 02-02-2009 00:00 3 200 02-02-2011 00:00 4 300 22-02-2010 00:00 5 400 12-02-2009 00:00 6 500 22-02-2009 00:00 7 600 02-02-2006 00:00 8 700 02-07-2012 00:00 9 500 08-02-2012 00:00 10 800 09-02-2011 00:00 11 500 06-02-2010 00:00 12 600 01-02-2011 00:00 13 300 02-02-2019 00:00 desired output: y1 y2 y3 ........... sum(amount) sum(amount) sum(amount) what approach, y1 year part of date, such result column following? 2006 2009 2010 2011 2012 --------------------------------- 600 1300 800 1900 1200 database system: sql server 2008 you need use dynamic pivot table declare @years nvarchar(max) select @years = stuff( ( select distinct ',[' + cast(year([date]) nvarchar(4)) + ']' your_table_name_here xml path('') ), 1,1,'') declare @sql nvarchar(max) select @sql = n' select * ( select amount, year([date]) [y] your_table_name_here ) data pivot ( sum(amount) [y] in ( ' + @y...

Tableless model JSON serialization in Rails -

i have tableless model (like shown in #219 railscast): class mymodel include activemodel::conversion extend activemodel::naming attr_accessor :attr1, :attr2, :attr3, :attr4 private def initialize(attr1 = nil) self.attr1 = attr1 end def persisted? false end end then i'm trying render json in controller: @my_model = mymodel.new render json: @my_model.to_json(only: [:attr1, :attr2]) but renders json attributes of model. i've tried add include activemodel::serialization but didn't change rendered json. how can render json necessary attributes of tableless model? i'm using rails 3.2.3 update thanks, guys. seems you're right. combined solutions , got this: model: include activemodel::serialization ... def to_hash { attr1: self.attr1, attr2: self.attr2, ... } end controller: render json: @my_model.to_hash.to_json(only: [:attr1, :attr2]) i don't know answer accepted. update 2 suddenly new strangeness appeared. 1 of attributes array of hashes. this: a...

compilation - Compiling libpurple for Android -

i want implement libpurple in android integrate im chat support android application, i'm using following links work with: compiling libpurple on android following repository android [soc.2012.android repository android] ( http://hg.pidgin.im/soc/2012/michael/android/ ) but problem that, have downloaded full repository suggested in compilation steps, there no " android/workspace " folder downloaded server pc. to android code run: hg clone https://hg.pidgin.im/soc/2012/michael/android/ android this gets me copy of whole repository in folder android. switch android branch i'll run command: hg checkout soc.2012.android at point can see folder android workspace in.

curl - Unable to post the data to server, getting error java.io.IOException: Server returned HTTP response code: 415 -

iam unable post data server, getting error . working fine in curl script. error reading url java.io.ioexception: server returned http response code: 415 url: https://8.7.177.4/api/domains/amj.nms.mixnetworks.net/subscribers/9001?do_not_disturb=no @ sun.net.www.protocol.http.httpurlconnection.getinputstream(unknown source) @ sun.net.www.protocol.https.httpsurlconnectionimpl.getinputstream(unknown source) @ curlauthentication.authenticateposturl(curlauthentication.java:109) @ curlauthentication.main(curlauthentication.java:134) error reading url below code. import java.io.bufferedreader; import java.io.ioexception; import java.io.inputstream; import java.io.inputstreamreader; import java.io.printwriter; import java.io.stringwriter; import java.net.httpurlconnection; import java.net.malformedurlexception; import java.net.url; import java.net.urlconnection; import javax.net.ssl.hostnameverifier; import javax.net.ssl.httpsurlconnection; import javax.net.ssl.sslsession; public class curl...

.net - Under what context am I running in C#? -

i wondering... when have code this: lock (obj) { mycode.myagent(); } can myagent contain code recognizes running under lock block? what about: for (int i=0;i<5;i++) { mycode.myagent(); } can myagent contain code recognizes running under loop block ? the same question can asked using blocks, unsafe code , etc... - idea... is possible in c#? this theoretical question, i'm not trying achieve anything... knowledge. it isn't impossible, can use stacktrace class reference caller method , methodinfo.getmethodbody() il of method. but you'll never reliable, just-in-time compiler's optimizer give hard time figuring out call located. method body inlining make method disappear completely. loop unrolling make impossible idea loop index. optimizer uses cpu registers store local variables , method arguments, making impossible reliable variable value. not mention tin foil chewing effort involved in decompiling il. none of anywhere near simplicity , speed of p...

c# - One binding to user control works, second doesn't -

i've created user control, code property want bind is: public color value { { return (color)this.getvalue(this.valueproperty); } set { this.setvalue(this.valueproperty, value); } } public readonly dependencyproperty valueproperty = dependencyproperty.register("value", typeof(color), typeof(colorslider), new propertymetadata(colors.red)) i have 2 instances of control in page: <local:colorslider x:name="colorsslider1" /> <!--...--> <local:colorslider x:name="colorsslider3" /> and controls values, want bind (from colorslider canvas , textblock ): <canvas x:name="tilecanvas" grid.column="0" margin="30" width="173" height="173" background="{binding value, elementname=colorsslider1, converter={staticresource colortosolidbrushconverter}}"> <textblock x:name="tiletext" text="dsdfsdfsf" foreground="{binding value, elementname=colorsslider3, co...

Ruby.h no such file or directory parser.o Error -

using rails 3.1 , new app, when go run bundle install got following errors installing json<1.7.3> native extensions error: failed build gem native extension. creating makefile generating parser-i386-mingw32.def compiling parser.c in file included parser.rl:1:0:../fbuffer/fbuffer.h:6:18: fatal error: ruby.h: no such file or directory compilation terminated. make: *** [parser.o] error 1 i have installed devkit , change $path below: c:\users\peter\downloads\make-3.81-bin\bin; c:\users\peter\working\ruby-devkit\mingw\bin; c:\users\peter\working\ruby-devkit; c:\program files\imagemagick-6.7.8-q16; c:\ruby193\bin;c:\ruby\bin; you need install ruby development kit because windows looking source code ruby based on error missing ruby.h

php - syntax error, unexpected '}' - weird -

i'm using code down below delete old files, keeps saying: syntax error, unexpected '}' , can't spot where, please me fix it.. function destroy($dir) { $mydir = opendir($dir); while($file = readdir($dir)) { if($file != "." && $file != "..") { chmod($dir.$file, 0777); if(is_dir($dir.$file)) { chdir('.'); while($dir.$file) { if(date("u",filectime($file) >= time() - 3600) { unlink($dir.$file) } } } else unlink($dir.$file) or die("couldn't delete $dir$file<br />"); } } closedir($dir); } function destroy($dir) { $mydir = opendir($dir); while($file = readdir($dir)) { if($file != "." && $file != "..") { chmod($dir.$file, 0777); if(is_dir($dir.$file)) { chdir('.'); while($dir.$file) { if(date("u",filectime($file) >= time() - 3600)) // missing ) { unlink($dir.$file); // missing ; } } } else unlink($dir.$file) or die("couldn't delete $dir$file<br ...

Live555 compile for iOS build error -

i'm trying compile live555 ios. i have done following: ./genmakefiles iphoneos make i following build errors: /applications/xcode.app/contents/developer/platforms/iphoneos.platform/developer/usr/bin/g++ -c -i../usageenvironment/include -i../groupsock/include -i../livemedia/include -i../basicusageenvironment/include -i. -dbsd=1 -o2 -dsocklen_t=socklen_t -dhave_sockaddr_len=1 -d_largefile_source=1 -d_file_offset_bits=64 -fpic -arch armv7 --sysroot=/applications/xcode.app/contents/developer/platforms/iphoneos.platform/developer/sdks/iphoneos5.1.sdk -wall testmp3streamer.cpp /applications/xcode.app/contents/developer/platforms/iphoneos.platform/developer/usr/bin/g++ -o testmp3streamer -l. -arch armv7 --sysroot=/applications/xcode.app/contents/developer/platforms/iphoneos.platform/developer/sdks/iphoneos5.1.sdk testmp3streamer.o ../livemedia/liblivemedia.a ../groupsock/libgroupsock.a ../basicusageenvironment/libbasicusageenvironment.a ../usageenvironment/libusageenvironment.a ld: i...

how to set windows wallpaper in java -

this have found on stackoverflow. looking java class change windows wallpaper me in windows 7. public class changewallpaper { public static void main(string[] args) { //supply own path instead of using 1 string path = "c:\\users\\d1j5\\pictures\\asgardrealmofthegods.jpg"; spi.instance.systemparametersinfo( new uint_ptr(spi.spi_setdeskwallpaper), new uint_ptr(0), path, new uint_ptr(spi.spif_updateinifile | spi.spif_sendwininichange)); } public interface spi extends stdcalllibrary { //from msdn article long spi_setdeskwallpaper = 20; long spif_updateinifile = 0x01; long spif_sendwininichange = 0x02; spi instance = (spi) native.loadlibrary("user32", spi.class, new hashmap<object, object>() { { put(option_type_mapper, w32apitypemapper.unicode); put(option_function_mapper, w32apifunctionmapper.unicode); } }); boolean systemparametersinfo( uint_ptr uiaction, uint_ptr uiparam, string pvparam, uint_ptr fwinini ); } } source code stackoverflow assuming code you...

dialog (shell script program) but for C/C++ programs -

i'm looking library or usable c/c++ (cross-platform if possible) similar program "dialog", is/was available on linux systems. basically, simple menu similar dialog --menu , don't want have write code it. console-based fine; know of such library? by way, know google shortcut search program "dialog" opposed gui dialog boxes (e.g. "golang" go programming language)? can't "dialog" produce useful results. thanks! yad yet dialog. google this .

PHP: Download a file from web to local machine -

i have searched web 2 days , can not find answer. i trying create routine displays files on site control, , allows user download selected file local drive. i using code below. when uncomment echo statements, displays correct source , destination directories, correct file size , echo after fclose displays true. when echo source file ($data), displays correct content. the $filename variable contains correct filename, either .doc/.docx or .pdf. have tested both , neither saves destination directory, or anywhere else on machine. the source path ($path) behind login, logged in. any thoughts on why failing write file? thanks, hank code: $path = "https://.../reports/reportdetails/$filename"; /* echo "downloading: $path"; */ $data = file_get_contents($path); /* echo "$data"; */ $dest = "c:\myscans\\".$filename; /* echo "<br />$dest"; */ $fp = fopen($dest,'wb'); if ( $fp === false ) echo "<br />error in fopen...

node.js - Loop Mocha tests? -

i'm trying loop mocha test suite (i want test system against myriad of values expected results), can't work. example: spec/example_spec.coffee : test_values = ["one", "two", "three"] value in test_values describe "testsuite", -> "does test", -> console.log value true.should.be.ok the problem console log output looks this: three 3 three where want this: one 2 3 how can loop on these values mocha tests? the issue here you're closing on "value" variable, , evaluate whatever last value is. something work: test_values = ["one", "two", "three"] value in test_values (value) -> describe "testsuite", -> "does test", -> console.log value true.should.be.ok this works because when value passed anonymous function, copied new value parameter in outer function, , therefore not changed loop. edit: added coffeescript "do" niceness.

php - How add table rows dynamically and loading dynamic combobox with jQuery -

i'm building form need multiple entries optional, example dynamic combobox. have this: image: http://twitpic.com/a4ph8x every time user presses 'new row' button new row of form inputs dynamic combobox , other inputs should added form, how can in jquery? i'm sorry asking maybe such basic question i'm still green jquery, php i'm sure javascript / jquery plays more appropriate role here. thanks! code: http://www.4shared.com/file/bcafsfc9/code.html sure, jquery can well. just pass function on click say: addnewrow() on click of button , append new row in html. for example function addnewrow() { $('.form').append('<input type="text" />'); }

python - Update Lines in matplotlib -

i have graph multiple data sets on it. need continually redraw these lines, each separately, data updated. how can delete , reestablish repeatedly, preferably without having delete entire graph , redraw of lines on every time? #!/usr/bin/env python import time pylab import * ion() # turn interactive mode on # initial data x = arange(-8, 8, 0.1); y1 = sin(x) y2 = cos(x) # initial plot line1, line2, = plot(x, y1, 'r', x, y2, 'b') line1.axes.set_xlim(-10, 10) line1.axes.set_ylim(-2, 2) line1.set_label("line1") line2.set_label("line2") legend() grid() draw() # update line 1 in xrange(50): time.sleep(0.1) # update data y1 = sin(x + float(i) / 10) # update plot line1.set_ydata(y1) draw() # update line 2 in xrange(50): time.sleep(0.1) # update data y2 = cos(x + float(i) / 10) # update plot line2.set_ydata(y2) draw()

java - Efficiently finding all overlapping matches for a regular expression -

this followup all overlapping substrings matching java regex . is there way make code faster? public static void allmatches(string text, string regex) { (int = 0; < text.length(); ++i) { (int j = + 1; j <= text.length(); ++j) { string positionspecificpattern = "((?<=^.{"+i+"})("+regex+")(?=.{"+(text.length() - j)+"}$))"; matcher m = pattern.compile(positionspecificpattern).matcher(text); if (m.find()) { system.out.println("match found: \"" + (m.group()) + "\" @ position [" + + ", " + j + ")"); } } } } in other question mentioned matcher's region() method, weren't making full use of it. makes valuable anchors match @ region's bounds if bounds of standalone string. that's assuming you've got useanchoringbounds() option set, that's default setting. public static void allmatches(string text, string regex) { matcher m = pattern.compile(regex).matcher(text); in...

android - Image size for ActionBarSherlock background -

if art asset made intended use background of actionbar, size (in pixels) should request? have found referencing size of actionbar has been in dp, i'm unsure best absolute size go actual .png file. thanks! the action bar can 40, 48, or 56 dp in height depending on configuration. means because of how android scales things density there 9 different absolute pixel heights. width varies depending on device, of course. your best bet use 9-patch drawables or create drawable using shape xml can adapt infinite number of configurations of devices.

Using PHP move_uploaded_file function permission denied -

i've been stuck on code days hitting error when upload file server. windows server running on apache tried various solutions still receiving error. tried changing full permissions on server. i changed default php upload tmp file inside application yet still having error. warning: move_uploaded_file(c:\my_workspace\ojs2002) [function.move-uploaded-file]: failed open stream: permission denied in c:\my_workspace\ojs\admin\include\fileupload.php on line 78 warning: move_uploaded_file() [function.move-uploaded-file]: unable move 'c:\my_workspace\ojs\tmp\phpcb78.tmp' 'c:\my_workspace\ojs2002' in c:\my_workspace\ojs\admin\include\fileupload.php on line 78 // copy file, making destination directory if necessary $filedir = 'c:/my_workspace/ojs2002/'.basename($_files['articlefile']['name']); chmod($_files["articlefile"]["tmp_name"], 0777); chmod($filedir, 0777 ); move_uploaded_file($_files["articlefile"]["tmp_n...

How in Oracle kill user session silent or reproduce error 17410? -

i need test robustness of application problem network. don't have access network physically. have access oracle sys. possible may silent kill user session when application try data connection jdbc driver generate error 17410 ? oracle: no more data read socket when try kill session sid - oracle send alert killed session , not 17410 error. you can raise error code pragma exception_init. declare e_no_more_data exception pragma exception_init( e_no_more_data , -17410 ); begin raise e_no_more_data; end; / don't know if simulates error.

Jumping to-and fro between Kernel and user code in Linux -

i doing kernel hacking on linux running x86-64 research project. kernel routine need jump user mode code page , return kernel code. in other words, need trampoline on user code while executing in kernel. i wondering whether can @ possible or not. if possible, can give idea how can achieved? it unlikely possible "easily". without knowing application, , without suggesting rethink kernel<->app interface, possible hack work this: have application register piece of trampoline code kernel component passing address of code. trampoline code execute "real" user mode function, issue syscall or exception return kernel. while not user-mode subroutine, gets reasonably close: when application calls whatever kernel function needs callback, kernel function can save real return address, change registered trampoline address , return user mode. trampoline call function, syscall/exception following kick kernel , can continue whatever doing there. you don't need worry...

ajax - create html elements on the serverside VS get data as JSON and create tags with javascript -

i want create ajax search find , list topics in forum (just topic link , subject). question is: 1 of methods better , faster? get threads list json string , convert object, loop on items , create <li/> or <tr> , write data (link, subject) , append threads list. (jquery powered) get threads list wrapped in html tags , print (or use innerhtml , $(e).html() ) thanks... i prefer second method. i figure server-side have either convert data json or html format why not go directly 1 browser understands , avoid having reprocess client-side. can adapt second method degrade gracefully users have disabled javascript (such still see results via standard non-js links.)

Django -- Template tag in {% if %} block -

i have following dictionary passed render function, sources being list of strings , title being string potentially equal 1 of strings in sources: {'title':title, 'sources':sources}) in html template i'd accomplish among lines of following: {% source in sources %} <tr> <td>{{ source }}</td> <td> {% if title == {{ source }} %} now! {% endif %} </td> </tr> {% endfor %} however, following block of text results in error: templatesyntaxerror @ /admin/start/ not parse remainder: '{{' '{{' ...with {% if title == {{ source }} %} being highlighted in red. you shouldn't use double-bracket {{ }} syntax within if or ifequal statements, can access variable there in normal python: {% if title == source %} ... {% endif %}

cursor - How to draw caret in the scroll view on iOS using system API? -

Image
i working on edit app, view inherits scroll view, , draw things manually. need insertion indicator, may refer caret(as know windows use term) or cursor(not mouse cursor). not sure term apple use. googled before , know can draw line manually, or create clear background text view on it, don't these ways. hope there system apis this, more native. 1 can figure out? cursor - how draw caret in scroll view on ios using system api? - stack overflow stack overflow questions developer jobs documentation beta tags users current community help chat stack overflow meta stack overflow communities sign up or log in customize list. more stack exchange communities company blog tour start here quick overview of site center detailed answers questions might have meta discuss workings , policies of site learn more stack overflow company business learn more hiring developers or posting ads ...