Popular recipes by Rutger Saalmink http://code.activestate.com/recipes/users/4187940/2013-10-02T12:52:23-07:00ActiveState Code RecipesSort images from different sources by picture taken date (Exif) (Python) 2013-09-24T12:43:31-07:00Rutger Saalminkhttp://code.activestate.com/recipes/users/4187940/http://code.activestate.com/recipes/578672-sort-images-from-different-sources-by-picture-take/ <p style="color: grey"> Python recipe 578672 by <a href="/recipes/users/4187940/">Rutger Saalmink</a> (<a href="/recipes/tags/chronological/">chronological</a>, <a href="/recipes/tags/exif/">exif</a>, <a href="/recipes/tags/image/">image</a>, <a href="/recipes/tags/order/">order</a>, <a href="/recipes/tags/photo/">photo</a>, <a href="/recipes/tags/picture/">picture</a>). Revision 3. </p> <p>On some occasions/events, pictures will be taken by different camera's, mobile phones, etc. In order to sort these photos chronologically, it does not suffice using the file's date modified/created set by the OS. The following script obtains, from multiple sources, the pictures' taken date stored in the accompanying Exif data and outputs them all chronologically in a single directory.</p> Shortest Common Supersequence algorithms (Python) 2013-10-02T12:52:23-07:00Rutger Saalminkhttp://code.activestate.com/recipes/users/4187940/http://code.activestate.com/recipes/578678-shortest-common-supersequence-algorithms/ <p style="color: grey"> Python recipe 578678 by <a href="/recipes/users/4187940/">Rutger Saalmink</a> (<a href="/recipes/tags/approximation/">approximation</a>, <a href="/recipes/tags/bound/">bound</a>, <a href="/recipes/tags/breadth_first_search/">breadth_first_search</a>, <a href="/recipes/tags/common/">common</a>, <a href="/recipes/tags/depth_first_search/">depth_first_search</a>, <a href="/recipes/tags/sequence/">sequence</a>, <a href="/recipes/tags/shortest/">shortest</a>, <a href="/recipes/tags/super/">super</a>). </p> <p>The Shortest Common Supersequence (SCS) problem is an NP-hard problem (<a href="https://en.wikipedia.org/wiki/Shortest_common_supersequence" rel="nofollow">https://en.wikipedia.org/wiki/Shortest_common_supersequence</a>), which occurs in problems originating from various domains, e.g. Bio Genetics. Given a set of strings, the common supersequence of minimal length is sought after. Below a set of algorithms is given, which I used in approximating and/or backtracking the optimal solution(s). </p> Run some command every x seconds (Python) 2013-09-24T13:26:19-07:00Rutger Saalminkhttp://code.activestate.com/recipes/users/4187940/http://code.activestate.com/recipes/578673-run-some-command-every-x-seconds/ <p style="color: grey"> Python recipe 578673 by <a href="/recipes/users/4187940/">Rutger Saalmink</a> (<a href="/recipes/tags/command/">command</a>, <a href="/recipes/tags/iterative/">iterative</a>, <a href="/recipes/tags/os/">os</a>, <a href="/recipes/tags/run/">run</a>). </p> <p>Sometimes it comes in handy to run some command every minute or hour. For example, have some process check your ip address every minute with 'ifconfig' or run some purgescript at midnight through 'sqlplus.exe @purge_aux_table'.</p> Generator with lookahead (Python) 2013-09-24T10:44:56-07:00Rutger Saalminkhttp://code.activestate.com/recipes/users/4187940/http://code.activestate.com/recipes/578671-generator-with-lookahead/ <p style="color: grey"> Python recipe 578671 by <a href="/recipes/users/4187940/">Rutger Saalmink</a> (<a href="/recipes/tags/background/">background</a>, <a href="/recipes/tags/generator/">generator</a>, <a href="/recipes/tags/generators/">generators</a>, <a href="/recipes/tags/lookahead/">lookahead</a>, <a href="/recipes/tags/performance/">performance</a>, <a href="/recipes/tags/python/">python</a>). </p> <p>Python generators are a great way of reducing memory usage due to the lazy (on demand) generation of values. However, when the process-time of generating such a value is relatively high, we can improve performance even more by obtaining the next n values of the generator in a separate thread in the background. Hence, the BackgroundGenerator.</p>