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.”

Original: craschworks - comments

How to set various user properties via the command line on Mac OS X

Read the rest of this entry » )

Original: craschworks - comments

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.

Original: craschworks - comments

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__ ) )

Original: craschworks - comments

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

Original: craschworks - comments

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.

Read the rest of this entry » )

Original: craschworks - comments

[EDIT: it's called a "here document"] Thanks variax!

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 <<EOF 
    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 of the argument: <<EOF...EOF

But for the life of me, I can’t recall it, or find it on the web. Anyone know this off hand?

Original: craschworks - comments

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`

Original: craschworks - comments

If you want a list of all a ruby object’s methods, try this:

puts object.public_methods.sort

Original: craschworks - comments

I’m using Thunderbird (version 2.0.0.0) on a 2.16 GHz Intel Core 2 Duo (1 GB Ram) running Mac OS X 10.4.9. When I connect to my account at fastmail.fm via IMAP, it frequently takes several minutes for each folder to open, and when I send mail, it often takes several minutes to copy the sent mail to the Sent folder (and sometimes it fails altogether.) Has anyone else experienced this problem? Any suggestions for what I might do to debug it?

[Edit: This has been going on for a couple of weeks, and happened when I was running the previous release of Thunderbird. If I stop and restart Thunderbird, it goes away for a while. ]

Thanks!

Original: craschworks - comments

Via [livejournal.com profile] ernunnos

Microsoft Announces New Vulnerability Affecting Cursors and Icons


A new vulnerability affecting animated cursor and icons in Windows that has been announced. No patch exists for the vulnerability and exploit code has been released and there are reports of some malware exploiting this problem. Furthermore, Microsoft has acknowledged the issue raising the potential for an increase in exploitation.

According to McAfee, IE version 6 and version 7 running on fully patched versions of Windows XP SP2 are vulnerable. Windows version 2000 SP4 and Server 2003 (non & SP1) are also reportedly vulnerable. Vista is also reported to be vulnerable but only witnessed as a denial-of-service at this point.

Computers can be infected by simply visiting a website containing a malicious .ANI file or HTML email message with one placed on it. In the past, malicious websites have used this type of vulnerability to silently install malware onto an unsuspecting visitor. These are also known as "drive-by" installs.



Man, I'm glad I'm on a Mac. With Apple's move to an Intel platform, there's no reason to stay with Windows any more. Many Windows apps are native to Macs already. But if not, now you can run most of them at near-native speeds using Boot Camp or Parallels.

If you must use Windows, at least switch to Firefox and Thunderbird.
Suppose you want to write a Python program that solicits input from a the user, but goes ahead anyway with a default value if they don't respond in say, 5 seconds. The following snippet of code implements such a thing:

Read more... )

Syndicate

RSS Atom