Via Winnie Cassiopeia.
Sometimes you want to exclude a directory and/or files from a search. This alias:
cfind=’find . \( -type d -name .svn -prune -o -path ./stock-data/tests/data -prune \) -o \( -type f \! -name “*.csv” -print0 \) | xargs -0 grep’
…means:
“Recursively loop through all of the files and directories in the current directory and below. If it’s a directory named .svn or it’s in the stock-data path, or it ends in .csv ignore it. Otherwise, search for your keyword in the file.”
GEEK: user admin cheat sheet
09-Feb-09
How to set various user properties via the command line on Mac OS X
(more…)
Type the following in the python interpreter:
help()
modules
[name of module]
You should see a list of the methods in the module with their descriptions.
Suppose you’re executing a python script in the debugger, and you want to find out where the script you’re executing is located. This should do the trick:
import os
os.path.dirname( os.path.realpath( __file__ ) )
Here’s how to add a user to the admin group using dscl:
dscl . append /Groups/admin GroupMembership crasch
Remove a user:
dscl . delete /Groups/admin GroupMembership crasch
Reading the membership of the admin group:
dscl . read /Groups/admin GroupMembership
GEEK: Running a ruby script via crontab
16-Jul-08
So, I’m trying to set up a ruby script that screenscrapes another website, writes the results to a local file, then rsyncs the file to another machine behind a firewall. This post details the problems I ran into while trying to get cron to run the ruby script and rsync to the remote host.
GEEK: shell script question
12-Dec-07
Suppose you want pass in a complex query to a command line sql interpreter from within a shell script. You can do so with a command like this:
sql92 < connect to db1 as LASTTRADES user eouser;
set format row;
select p.fundkey as fundkey,
max(t.closed) as last_trade
from mposition p, mtrade t
where p.primarykey=t.positionkey
and t.createdbycorporateaction=0
group by fundkey;
EOF
There’s a name for the syntax for the argument: <
But for the life of me, I can’t recall it, or find it on the web. Anyone know this off hand?
GEEK: editing groups, using sudo
12-Dec-07
GEEK: Notes on rubygem, pdb.set_trace()
27-Nov-07
If you want to use a newly installed rubygems, and you don’t want to require ‘rubygems’ for every program that uses a gem, you need to set the RUBYOPT environment variable. For example, if you’re using tcsh, you should put the following in your .tcshrc file:
setenv RUBYOPT rubygems
This will cause the rubygems module to be loaded every time your run a ruby script.
——
If you call an external python script from within ruby, make sure you have any pdb.set_trace() lines commented out. When the ruby script tries to run the program, it will just hang at the point you set the trace, without giving you any output. For example, if test.py script has a pdb.set_trace() set, and you run the following command from within irb, the line will never finish executing. You’ll have to interrupt it with a CTRL-C command.
dfi_result = `/Users/build/crasch/PythonScripts/test.py -positions -total -infile /MData/Data/vyslf.csv -MStderrLoggingThreshold 3`