Posts

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.