Archive for the ‘Jigs’ Category
Ruby: Remove instances of a method
Here’s an “old school” style jig. I first attempted this in Haskell, but I needed Perl-compatible regular expressions (Posix can’t handle the negative lookahead needed for correctly identifying C-style comments), and installing the PCRE library for Haskell on Windows is painful, though I’ll get around to it one of these days.
require ‘find’
Find.find "Components\\CommComponents" do |p|
[...]
Haskell: Filter C++ Classes
I’ve needed a jig to separate a C++ class’s declaration and implementation for quite some time. Compile with “ghc -O2 –make classfilt.hs” and invoke with “classfilt –impl” or “classfilt –decl”, piping in the class source with inline methods. It certainly doesn’t handle all the corners of the C++ language, but it does most of [...]
Erlang: Remove #include directives from all cpp files
I’m certain this can be done better and with fewer lines of code, but it’s my first Erlang jig.
Python: Generate Test Case Stubs For All Classes In A Module
I had a module full of classes. I wanted to generate a unittest.TestCase stub for every class, such as this:
# TODO: Finish this
class Test_className(unittest.TestCase):
def setUp(self):
pass
So, I wrote the following Python script:
if __name__=="__main__":
file = "c:/dev/sourceFile.py"
f [...]
Scheme: Translate static data from C++ to XML
Warning: preg_replace_callback() [function.preg-replace-callback]: Unknown modifier 'c' in /usr/local/www/sites/jigcode.com/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3324
Warning: preg_replace_callback() [function.preg-replace-callback]: Unknown modifier 'c' in /usr/local/www/sites/jigcode.com/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3324
Warning: preg_replace_callback() [function.preg-replace-callback]: Unknown modifier 'c' in /usr/local/www/sites/jigcode.com/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3324
The C++ was extracted and munged with vim to make nice Scheme syntax elements before running this script.
"das.cpp""<isofield id=\"~a\" length=\"~a\" name=\"~a\" pad=\"true\" class=\"org.jpos.iso.~a\"/>~n"
Quick and Dirty Wordpress Backup Script (*NIX Shell)
Here’s a quick and dirty script to back up a wordpress blog. In fact, it’s the backup script we use to back up Jigcode. Of course, all of the hostnames, usernames and passwords have been removed.
This runs from a crontab which gets e-mailed to me, so I do an ‘ls’ at the end so I [...]
Scheme: Graph lines of code in Subversion
Warning: preg_replace_callback() [function.preg-replace-callback]: Unknown modifier 'c' in /usr/local/www/sites/jigcode.com/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3324
Warning: preg_replace_callback() [function.preg-replace-callback]: Unknown modifier 'c' in /usr/local/www/sites/jigcode.com/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3324
Warning: preg_replace_callback() [function.preg-replace-callback]: Unknown modifier 'c' in /usr/local/www/sites/jigcode.com/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3324
Warning: preg_replace_callback() [function.preg-replace-callback]: Unknown modifier 'c' in /usr/local/www/sites/jigcode.com/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3324
Warning: preg_replace_callback() [function.preg-replace-callback]: Unknown modifier 'c' in /usr/local/www/sites/jigcode.com/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3324
Warning: preg_replace_callback() [function.preg-replace-callback]: Unknown modifier 'c' in /usr/local/www/sites/jigcode.com/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3324
Warning: preg_replace_callback() [function.preg-replace-callback]: Unknown modifier 'c' in /usr/local/www/sites/jigcode.com/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3324
Warning: preg_replace_callback() [function.preg-replace-callback]: Unknown modifier 'c' in /usr/local/www/sites/jigcode.com/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3324
Warning: preg_replace_callback() [function.preg-replace-callback]: Unknown modifier 'c' in /usr/local/www/sites/jigcode.com/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3324
Warning: preg_replace_callback() [function.preg-replace-callback]: Unknown modifier 'c' in /usr/local/www/sites/jigcode.com/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3324
Warning: preg_replace_callback() [function.preg-replace-callback]: Unknown modifier 'c' in /usr/local/www/sites/jigcode.com/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3324
Warning: preg_replace_callback() [function.preg-replace-callback]: Unknown modifier 'c' in /usr/local/www/sites/jigcode.com/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3324
Warning: preg_replace_callback() [function.preg-replace-callback]: Unknown modifier 'c' in /usr/local/www/sites/jigcode.com/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3324
Warning: preg_replace_callback() [function.preg-replace-callback]: Unknown modifier 'c' in /usr/local/www/sites/jigcode.com/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3324
Warning: preg_replace_callback() [function.preg-replace-callback]: Unknown modifier 'c' in /usr/local/www/sites/jigcode.com/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3324
Warning: preg_replace_callback() [function.preg-replace-callback]: Unknown modifier 'c' in /usr/local/www/sites/jigcode.com/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3324
Warning: preg_replace_callback() [function.preg-replace-callback]: Unknown modifier 'c' in /usr/local/www/sites/jigcode.com/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3324
Warning: preg_replace_callback() [function.preg-replace-callback]: Unknown modifier 'c' in /usr/local/www/sites/jigcode.com/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3324
Warning: preg_replace_callback() [function.preg-replace-callback]: Unknown modifier 'c' in /usr/local/www/sites/jigcode.com/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3324
Warning: preg_replace_callback() [function.preg-replace-callback]: Unknown modifier 'c' in /usr/local/www/sites/jigcode.com/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3324
Warning: preg_replace_callback() [function.preg-replace-callback]: Unknown modifier 'c' in /usr/local/www/sites/jigcode.com/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3324
Warning: preg_replace_callback() [function.preg-replace-callback]: Unknown modifier 'c' in /usr/local/www/sites/jigcode.com/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3324
Warning: preg_replace_callback() [function.preg-replace-callback]: Unknown modifier 'c' in /usr/local/www/sites/jigcode.com/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3324
Warning: preg_replace_callback() [function.preg-replace-callback]: Unknown modifier 'c' in /usr/local/www/sites/jigcode.com/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3324
Warning: preg_replace_callback() [function.preg-replace-callback]: Unknown modifier 'c' in /usr/local/www/sites/jigcode.com/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3324
Warning: preg_replace_callback() [function.preg-replace-callback]: Unknown modifier 'c' in /usr/local/www/sites/jigcode.com/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3324
This checks out every tenth version from SVN and produces a data file which can easily be used as input to gnuplot. You can see the final graph.
"^[ \t][ \t]*void\\s+test[A-Za-z_0-9]*\\s*\\(\\s*\\)""h""Test_""cpp""h""hpp""cxx""hxx""report.txt""svn up -r ~a""."".svn""boost""WindowsSDK""XML""OPENSSL""Release""cxxtest""\\""\\""\\""\\""\\""\\""~a ~a ~a ~a"
Scheme: Save preprocessor output for all compiled files
Warning: preg_replace_callback() [function.preg-replace-callback]: Unknown modifier 'c' in /usr/local/www/sites/jigcode.com/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3324
Warning: preg_replace_callback() [function.preg-replace-callback]: Unknown modifier 'c' in /usr/local/www/sites/jigcode.com/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3324
Warning: preg_replace_callback() [function.preg-replace-callback]: Unknown modifier 'c' in /usr/local/www/sites/jigcode.com/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3324
Warning: preg_replace_callback() [function.preg-replace-callback]: Unknown modifier 'c' in /usr/local/www/sites/jigcode.com/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3324
Warning: preg_replace_callback() [function.preg-replace-callback]: Unknown modifier 'c' in /usr/local/www/sites/jigcode.com/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3324
Warning: preg_replace_callback() [function.preg-replace-callback]: Unknown modifier 'c' in /usr/local/www/sites/jigcode.com/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3324
Warning: preg_replace_callback() [function.preg-replace-callback]: Unknown modifier 'c' in /usr/local/www/sites/jigcode.com/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3324
Warning: preg_replace_callback() [function.preg-replace-callback]: Unknown modifier 'c' in /usr/local/www/sites/jigcode.com/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3324
Warning: preg_replace_callback() [function.preg-replace-callback]: Unknown modifier 'c' in /usr/local/www/sites/jigcode.com/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3324
Warning: preg_replace_callback() [function.preg-replace-callback]: Unknown modifier 'c' in /usr/local/www/sites/jigcode.com/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3324
Warning: preg_replace_callback() [function.preg-replace-callback]: Unknown modifier 'c' in /usr/local/www/sites/jigcode.com/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3324
Warning: preg_replace_callback() [function.preg-replace-callback]: Unknown modifier 'c' in /usr/local/www/sites/jigcode.com/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3324
Warning: preg_replace_callback() [function.preg-replace-callback]: Unknown modifier 'c' in /usr/local/www/sites/jigcode.com/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3324
Warning: preg_replace_callback() [function.preg-replace-callback]: Unknown modifier 'c' in /usr/local/www/sites/jigcode.com/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3324
Warning: preg_replace_callback() [function.preg-replace-callback]: Unknown modifier 'c' in /usr/local/www/sites/jigcode.com/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3324
Warning: preg_replace_callback() [function.preg-replace-callback]: Unknown modifier 'c' in /usr/local/www/sites/jigcode.com/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3324
Warning: preg_replace_callback() [function.preg-replace-callback]: Unknown modifier 'c' in /usr/local/www/sites/jigcode.com/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3324
This is a wrapper for the MSVC compiler (cl.exe) to generate a .i file as well as a .obj. Compiled with Bigloo.
""" \"""\""; Run cl.exe to compile
"cl"; Run cl.exe to produce preprocessed .i
"cl /P"; /P puts the file in the current directory, so we need to move it to the
; same directory the object [...]
Python: List files older than or newer than a specific date and time
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import os, sys
from datetime import date, timedelta, datetime
from time import localtime
import re
files = os.listdir(’c:/windows/system32/’)
files = [ f for f in files if re.search(’.dll$’, f, re.I)]
files.sort()
d = datetime.now() – timedelta(days=30)
d = d.timetuple()
oldfiles = 0
newfiles = 0
for file in files:
filetimesecs = os.path.getmtime(’c:/windows/system32/’ + file)
filetime = localtime(filetimesecs)
# print "*******************************"
# print [...]

