A few days ago, I found a handy script online that colorized the output of SVN status. It worked pretty well, but needed a little polish and a couple of tweaks to make it use more common Python idioms. Also, I fixed ANSI word-wrapping issues, created a configurable tab expansion feature (for better code alignment), added the 'colorizedSubcommands' sequence so that only applicable commands get colorized, and fixed subprocess calls so that piping through less will work (for example, try svn-color diff | less -r to see colorized diff output).
I hope you find my modifications useful. You can modify the colors used by looking up the ANSI color codes for your preferred color scheme and editing the 'statusColors' dictionary. Here's a useful reference for ANSI color values:
http://www.ibm.com/developerworks/linux/library/l-tip-prompt/colortable.gif
i've posted the code on snipplr, and it's also posted below after the break.
After two years of continual development, documentation, and production use, I've arbitrarily decided to tag modu with a version 1.0, as well as make a formal release.
modu is released under the MIT license. For installation instructions, see Installation or the included INSTALL file.
As my DBA skills have progressed over the years, I'm always impressed and upset to see the extent to which MySQL has allowed me to use terrible syntax generally not accepted by standards-compliant SQL servers.
A recent one really blew me away, because it exposed a lack of understanding on my part about how to understand the syntax of JOIN commands.
This is how I always built nested JOIN queries. The premise is that semantically you are always selecting from a single table; the use of the INNER JOIN statement is treated like a function that returns a compound table.
$Z=sub{for($Z=0;$Z<@_;$Z++){$z=oct("$_[$Z++]")."$_[$Z++]".$_[$Z];for($W=0;
$W<length($z);$W++){($n,$N)=split(m--,substr($z,$W,2));$W++;$X=int($n);
push(@V,split(m++,${N}x${X}));}}for($W=0;$W<@V/3;$W++){$_=chr(int($V[$W].
$V[$W+055].$V[$W+0x5A]));$_=~tr,a-zA-Z,n-za-mN-ZA-M,;print $_;}};$Z->(10016,0x460,
4120,6046,0x1810,3110,15706,0x83e,1130,2437,0xb5e,2110,2447,0x456,1213,6050,0x456,
3411,2613,0x840,1321,1763,0x7db,1910,2151,0x584,1312,1771,0x715,1714,2130,0x77a,
2112,3256,0x4ba,1411,7032,0x5ef,1718,2142,0x6af,1812,2442,0x6b0,1417);
I was attempting to install DBD::mysql today, and I ran into a fiendishly difficult problem.
I've installed the mysql drivers for Perl countless times, but this time for some reason, I was getting the following error:
ool-4577f347:~/.cpan/build/DBD-mysql-4.004 root# make
cc -c -I/Library/Perl/5.8.6/darwin-thread-multi-2level/auto/DBI -I/usr/local/mysql/include -Os -arch ppc64 -fno-common -DDBD_MYSQL_INSERT_ID_IS_GOOD -g -g -pipe -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -I/usr/local/include -Os -DVERSION=\"4.004\" -DXS_VERSION=\"4.004\" "-I/System/Library/Perl/5.8.6/darwin-thread-multi-2level/CORE" dbdimp.c
dbdimp.c: In function 'mysql_dr_connect':
dbdimp.c:1565: error: 'ulong' undeclared (first use in this function)
dbdimp.c:1565: error: (Each undeclared identifier is reported only once
dbdimp.c:1565: error: for each function it appears in.)
dbdimp.c:1565: error: parse error before numeric constant
dbdimp.c:1567: error: parse error before numeric constant
dbdimp.c:1681: error: parse error before numeric constant
make: *** [dbdimp.o] Error 1
This is something I wrote over at DocForge, but I'm keeping it here for posterity. You never know what those crazy wiki-ers might do with it over there ;-)
I've got a directory full of eBooks in the godawful Microsoft .lit format. I had marked with the Finder labels the ones I've already read, and wanted to convert all the ones I hadn't read yet into a readable format.
After using the Spotlight UNIX tools and applying liberal amounts of command-line trickery, the end result was a rather beautiful pipeline, if I do say so myself.
I'm hoping to get away from PHP in favor of mod_python, but the first thing I needed to do was get mod_python successfully working on Mac OS X. I tried once before, using the built-in Apache and Python binaries that ship with Mac OS X. At the time (I think this was still 10.4, but it could have been 10.3), the built-in Python wasn't multithreaded (or something like that) and the mod_python developers were starting to move away from Apache 1.3 altogether.
I had success recently compiling mod_python on Mac OS X Server, against the distributed (but inactive) Apache 2 installation in /opt. However, I found OS X Server to be basically garbage, so I did a fresh install of the client version of Mac OS X, and set about getting Apache 2 to compile, and then mod_python.
It was not easy.
#!/usr/bin/perl
@x=(0x50,-82,0xd,-3,-12,0x5,0x1,0xd,0x41,-84,0x1,
-2,0x2b,0x4a);$Z=sub{for($z=@_;$z;$z--){unshift(
@z,chr($_[$z]+$z{z}));$z{z}+=$_[$z];}while($z=pop
(@z)){print($z);}};$z=$Z;@Z=(0xd,-6,0x8,0x2);$Z->
((0,0,0,-68,@Z,-7,0x48,-76,-6,0xd,-11,@x));
mark got me thinking about this, and then i was messing around with one of my own projects that needed the same feature, and i realized the easy way to do it.
i would always get the year/month/day out of a timestamp using the date() function, and then create a new timestamp with mktime().
i just realized the best way is:
$now = time();
$beginning_of_day = $now - ($now % 86400);
this works for me because i definitely remember that number for seconds in a day, and avoids any locale-dependent variations. plus, end of day becomes just as easy.
I got a message from someone who was interested in pooking around InnerSpace today, and spent enough time providing some starter instructions that I figured I'd post them here.
thanks a lot for writing. i'm glad some people are checking this out...
right now the codebase isn't really meant for public consumption. i do this primarily as a personal exercise, and although there are many parts of it that are very functional, other parts aren't so refined...
i've attached a tarball, which contains some sparse documentation. i don't know what your level of familiarity is with Python and the Twisted library (http://www.twistedmatrix.com), but some basic concepts from those areas can get you up and running.