Posts

c++ - How to treat std::pair as two separate variables? -

there few functions in standard library, such std::map::insert , return std::pair . @ times convenient have populate 2 different variables corresponding halves of pair. there easy way that? std::map<int,int>::iterator it; bool b; magic(it, b) = mymap.insert(std::make_pair(42, 1)); i'm looking magic here. std::tie <tuple> header want. std::tie(it, b) = mymap.insert(std::make_pair(42, 1)); " magic " :) note: c++11 feature.

linux - Use grep to search for words beginning with letter "s" -

i'm trying use grep through file, , find words starting lowercase letter "s". snippet of file: sjpope pts/2 161.133.12.95 10:21am 43.00s 0.13s 0.01s man bc rmschalk pts/3 161.133.9.147 10:22am 1.00s 0.10s 0.02s vi testb jntrudel pts/4 161.133.9.11 10:23am 2.00s 0.09s 0.00s vi testb tjbanks pts/5 161.133.9.70 10:41am 8.00s 0.06s 0.04s -ksh i want output have line stating "s". for these want search words starting given letter not lines one-liner do: grep -e '\bs' file.txt # words starting s grep -e 's\b' file.txt # words ending s i know non standard grep behavior ( \b regex anchor means word break not in extended regular expressions standard) works on modern systems.

system calls - socket syscall on linux x86_32 -

i trying hook socket system call on linux x86_32. system call not exist gated through socketcall. man socketcall: socketcall() common kernel entry point socket system calls. call determines socket function invoke. args points block containing actual arguments, passed through appropriate call. i hooked syscall (__nr_socketcall 102 on system stated on http://docs.cs.up.ac.za/programming/asm/derick_tut/syscalls.html ) own function prints , calls original function afterwards. however, function never called. furthermore, strace shows socket() syscall called. the basic question: how can hook socket syscalls on linux x86_32? subquestion: why strace show socket() syscall , not socketcall()? everything works expected on x86_64 socket syscall exists.

php - Format column number to currency -

i'm pulling number mysql database column , i want format number currency. instance, column value '85000000' , want formatted '$85,000,000' . i've tried few methods can't seem work. help. <?php $value = 85000000; echo "$".number_format($value, 2, '.', ','); ?> if don't want decimal places, change 2 0.

c# - Why can't MonoDroid find my assemblies? -

i made simple android helloworld app using xamarin studio 4.2.3 doesn't except prints out message if random number greater 0.5. works great on nexus 4 , nexus 5. the next thing i'm doing extract .dll code app's apk (from assemblies folder) using 7zip. using .net reflector , reflexil i'm modifying single instruction, brfalse.s gets generated if statement in "if(rand.nextdouble()>0.5){dostuff()}" such branches instruction right in front of call dostuff(), thereby making if statement useless , ensuring method gets called. next i'm saving patched .dll, replacing original 1 in .apk patched one, sign , zipalign .apk , i'm installing using adb. when i'm launching app on phones crashes directly , logcat shows following: 03-20 10:12:08.709: i/activitymanager(764): start proc hellomonolvl.hellomonolvl activity hellomonolvl.hellomonolvl/hellomonolvl.hellomonolvl.trialsplashscreen: pid=23099 uid=10128 gids={50128} 03-20 10:12:08.729: d/dalvikvm...

aptana - Github error when pulling and pushing -

i have been working on github while now, had problem msys-1.0.dll file, fixed problem , working fine have problem statement "received disconnect 192.33.232.526: 11: bye bye" appears everytime gitpull makes pc take more time pull. how can solve problem :received disconnect 192.34.252.665: 11: bye bye thank you i found best solution use terminal easier, , faster pull , push or git commands there or generate new ssh key doing take out received disconnect 192.34.252.665: 11: bye bye message , refreshing current repository

php - pagination in custom post type issue -

i faced weird issue. make post type "insight" , want pagination (no plugin). when click on next post shows me 404 error here code <?php if ( get_query_var('paged') ){ $paged = get_query_var('paged'); } else { $paged = 1; } query_posts(array('post_type'=>'insight','posts_per_page'=>'1','order'=>'desc', 'paged' => $paged)); ?> <?php while (have_posts()) : the_post(); ?> <?php endwhile; ?> <div class="navigation"> <div class="alignleft"><?php next_posts_link('&laquo; new entries') ?></div> <div class="alignright"><?php previous_posts_link('&laquo; older entries') ?></div> </div> i don't no why happen because think code right. foy blog use this: functions.php: if ( ! function...