Mindblown: a blog about philosophy.

  • Unix Epoch Programming Reference

    Below is a table indicating how to obtain a Unix Epoch Timestamp from various programming languages: |=Language|=Command| |Actionscript| (new Date()).time | |ASP| DateDiff(“s”, “01/01/1970 00:00:00”, Now()) | |C++| #include std::time(0); | |C#| epoch = (DateTime.Now.ToUniversalTime().Ticks – 621355968000000000) / 10000000; | |Erlang| calendar:datetime_to_gregorian_seconds( calendar:now_to_universal_time( now()) )-719528*24*3600 | |Java| long epoch = System.currentTimeMillis()/1000; | |JavaScript| Math.round(new Date().getTime()/1000.0) getTime()…

  • Couldn’t get lock on destination repos – SVNSync

    To fix this issue, remove the lock property on the remote repository via svn command line. The lock property is typically left after an incomplete synchronization, and can be removed with the below command: {{{ svn propdel –revprop -r0 svn:sync-lock file:///path/to/repository/mirror }}}

  • Convert Time String (HH:MM:SS) To Seconds

    Sometimes it is necessary to find the amount of seconds in a time string for use in equations. Below are PHP and Python functions to do this. These functions work by splitting the time string by ‘:’, then calculating 60 to the power of the split time count minus 1 (allowing for MM:SS format and…

  • SPAM Identification Techniques

    **Below are a set of rules to live by when trying to determine whether an email should be considered spam/fraudulent and disregarded:** * Commercial emails will always contain a header or footer indicating what company sent you the email * There will be a visible and operable unsubscribe mechanism present in all commercial emails *…

  • Trac Workflow

    This is my Trac Ticket Workflow. I will work on making a visualization to explain what is happening here (the complexity was too much for Trac’s workflow visualizer), but I will go ahead and post in the hopes that it is useful. {{{ awaiting_evidence = reviewing,reopened,new,failed_testing,in_dev -> awaiting_evidence awaiting_evidence.name = Awaiting Evidence awaiting_evidence.operations = leave_status…

  • Syncing a remote SVN repository with svnsync

    * Create a blank repository on the destination server {{{ mkdir /var/svn/my_project svnadmin create /var/svn/my_project }}} * Create (and make executable) the svn pre-revprop-change hook. You can do whatever you would like with this script, but that will not be covered here. {{{ echo ‘#!/bin/sh’ > /var/svn/my_project/hooks/pre-revprop-change chmod +x /var/svn/my_project/hooks/pre-revprop-change }}} * Initialize the source…

  • super() Raises `TypeError: must be type, not classobj`

    If you try to use Python’s super method, and receive {{{TypeError: must be type, not classobj}}}, your parent class is an old style class (and does not in some way inherit from object). The below code is an illustration of the issue: {{{ lang=python lines=1 class class_A: def __init__( self ): print ‘Class A’ class…

  • Adding number formatting to percentages in phpPowerPoint Charts

    Below is a patch to add number formatting to percentages in phpPowerPoint Pie Charts: {{{ lang=diff Index: Shape/Chart/Series.php =================================================================== — Shape/Chart/Series.php (revision 71171) +++ Shape/Chart/Series.php (working copy) @@ -101,6 +101,15 @@ * @var boolean */ private $_showPercentage = false; + + /** + * $_percentFormat + * Added to set the number format of series…

  • Enumerate Processes Programmatically In Linux

    Using `ps` is not necessarily the best way to enumerate running applications programmatically. This is because it will gather additional information that we do not actually need in most cases. The below examples illustrate how to enumerate running applications by reading the contents of `/proc`. **Python:** {{{ lang=python line=1 def get_procs(proc_name=None): ## Loop over /proc…

  • Start a script on boot – Ubuntu 12.04

    Use the below procedure to start a script on boot: {{{ lang=bash sudo mv /filename /etc/init.d/ sudo chmod +x /etc/init.d/filename sudo update-rc.d filename defaults }}}

Got any book recommendations?