Posts

use doctest and logging in python program -

#!/usr/bin/python2.4 import logging import sys import doctest def foo(x): """ >>> foo (0) 0 """ print ("%d" %(x)) _logger.debug("%d" %(x)) def _test(): doctest.testmod() _logger = logging.getlogger() _logger.setlevel(logging.debug) _formatter = logging.formatter('%(message)s') _handler = logging.streamhandler(sys.stdout) _handler.setformatter(_formatter) _logger.addhandler(_handler) _test() i use logger module of print statements. have looked @ first 50 top google links this, , seem agree doctest uses it's own copy of stdout. if print used works if logger used logs root console. can please demonstrate working example code snippet allow me combine. note running nose test doctest append log output @ end of test, (assuming set switches) not treat them print statement. i'm not sure why want this, if need it, can define own subclass of doctestrunner , ,...

multithreading - c++ multithread -

i use c++ implement thread class. code shows in following. have problem how access thread data. in class thread, create thread use pthread_create() function. calls entrypoint() function start thread created. in run function, want access mask variable, shows segment fault. so, question whether new created thread copy data in original class? how access thread own data? class thread { public: int mask; pthread_t thread; thread( int ); void start(); static void * entrypoint (void *); void run(); }; thread::thread( int a) { mask =a; } void thread::run() { cout<<"thread begin run" <<endl; cout << mask <<endl; // show segmentfault here } void * thread::entrypoint(void * pthis) { cout << "entry" <<endl; thread *pt = (thread *) pthis; pt->run(); } void thread::start() { pthread_create(&thread, null, entrypoint, (void *)threadid ); pthread_join(thread, null); } int main() { int inp...

django admin - selecting a single model to publish to site -

hey, i'm making popup radio player attached shoutbox django , i'm having trouble getting admin functionality want. i have 2 models: 1) stream (which represents radio stream admin can publish play on frontpage - i.e. there multiple saved streams, 1 playing on frontpage @ time, @ discretion of admin) 2) shout (a shout has been entered shoutbox, , associated stream, i.e. every stream has multiple shouts entered users of site.) i want admin able log end, create multiple streams, select 1 published @ 1 time. presumabley each stream should have attribute (i.e is_published) , should create admin action perform check of every stream, , publish correct one? correct way go or missing something the potential problem forsee is, if has connected , listening stream before admin changes it. should person hear new stream or continue hear stream listening to? other that, way you've described it, see working. make url/view returns current stream, /stream/current/ . ...

computer vision - Tips for background subtraction in the face of noise -

background subtraction important primitive in computer vision. i'm looking @ different methods have been developed, , i've begun thinking how perform background subtraction in face of random, salt , pepper noise. in system such microsoft kinect, infrared camera give off random noise pretty consistently. if trying background subtract depth view, how can avoid issue random noise while reliably subtracting background? as said, noise , other unsteady parts of background might give problems in segmentation, mean lighting changes or other moving stuff in background. but if you're working on indoor-project shouldn't big of issue, except of course noise thing. besides substracing background image segment objects in try subtract 2 (or in methods three) following frames each other. if camera steady should leave parts have changed, objects have moved. easy method detecting moving objects. but in operations might use have noise described. easiest way rid of u...

Facebook Credits/Payment API in C# or VB .net? -

i can't seem find code examples anywhere online hint @ way use facebook api or facebook sdk c#.net (or vb.net) use facebook credits features. does know of .net examples show how use facebook credits features? most of calls required use credits api graph calls work fine c# sdk. other stuff the callbacks going have own own.

php - Automated URL checking from a MySQL table -

okay, have list of urls in mysql table. want script automatically check each link in table 404, , afterward want store whether url 404'd or not, store time last checked. is possible automatically, if no 1 runs script? ie, no 1 visits page few days, no 1 visiting page, automatically ran test. if possible, how go making button this? no need use curl, file_get_contents($url); return false if request fails (any other http code other 2xx), might more useful you're trying do, example: function urlexists($url) { return (bool) @file_get_contents($url); } will return true if url returns useful content, false otherwise. edit : here faster way (it requests headers) , the first byte instead of whole page: function urlexists($url) { return (bool) @file_get_contents($url, false, null, 0, 1); } urlexists('https://stackoverflow.com/idontexist'); // false however, in combination your other question may wiser use this: function url($url) { ...

Facebook sharer,share image -

i found lot of posts, none of them me. i want share image not visible. issue is, when click share, images page available sharing. how can fix images want share visible sharing? i have read facebook open graph protocol , didn't me. here function create share button : function wp_fb_sharer($post) { $link = js_escape(get_permalink($post->id)); $button = '<a name="fb_share" type="box_count" share_url="' . $link . '" href="http://www.facebook.com/sharer.php">share</a><script src="http://static.ak.fbcdn.net/connect.php/js/fb.share" type="text/javascript"></script>'; $button = ' <div style="float: left; margin-left: 10px; margin-bottom: 4px;"> ' . $button . ' </div>'; return $button; } is there image size limit facebook? have read of answer . facebook recommending use of like plugin instead of ...