This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# run this in the directory with mysql5 commands (mysql5, mysqlimport5, etc.) | |
# for MacPorts, I ran it as root in /opt/local/bin | |
# it creates symlinks like so: mysql -> mysql5, mysqlimport -> mysqlimport5, etc. | |
import os | |
for f in [(f, f[:-1]) for f in os.listdir('.') if f.startswith('mysql') and f.endswith('5')]: | |
os.symlink(*f) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
How I installed and ran node.js on Ubuntu Karmic Koala Desktop 64-bit: | |
1. $ sudo aptitude install scons | |
2. $ sudo aptitude install build-essential | |
3. Downloaded the node.js tarball from here (also tried the git repo - both worked!) | |
http://nodejs.org/#download | |
4. untar'ed it | |
5. changed to the directory | |
6. $ ./configure --prefix=/usr/local | |
7. $ make |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-b, --ignore-space-change | |
Ignore changes in amount of whitespace. This ignores whitespace at | |
line end, and considers all other sequences of one or more | |
whitespace characters to be equivalent. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Returns the different values of a field in a django model. | |
# Because I didn't want to check the docs and needed a way that didn't retrieve lots of records from the database. | |
# It was fun to code and uses a couple of Python tricks. | |
def field_values(cls, field): | |
values = [] | |
exclude_args = {field + '__in': values} | |
while True: | |
try: | |
obj = cls.objects.exclude(**exclude_args)[0] | |
values.append(getattr(obj, field)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby -rubygems | |
# frenzy - a script for adding/removing /etc/hosts site-blocking entries | |
require 'main' | |
require 'yaml' | |
SITES_TEMPLATE = <<EOF.strip | |
blocked_sites: | |
- *.reddit.com | |
- www.reddit.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'appscript' | |
puts Appscript.app('Finder').desktop.window.bounds.get()[2..-1].join('x') # prints 1440x900 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(setq kitfiles-dir "~/github/walter/aquamacs-emacs-starter-kit") | |
(add-to-list 'load-path kitfiles-dir) | |
(require 'init) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This makes a call to an API, through JSON. In a single place I could change the url design, whether it's https or not, the authentication method, the serialization format, and more. Additionally, since initialization and sending happen outside of this method, the request can be touched up before or after sending it. | |
- (void) prepareRequest:(ASIHTTPRequest *)request withController:(NSString *)controller andAction:(NSString *)action andParams:(NSDictionary *)params; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defaults write com.apple.dock persistent-apps -array-add '{tile-data={}; tile-type="spacer-tile";}' | |
defaults write com.apple.dock persistent-apps -array-add '{tile-data={}; tile-type="spacer-tile";}' | |
defaults write com.apple.dock persistent-apps -array-add '{tile-data={}; tile-type="spacer-tile";}' | |
defaults write com.apple.dock persistent-apps -array-add '{tile-data={}; tile-type="spacer-tile";}' | |
defaults write com.apple.dock persistent-apps -array-add '{tile-data={}; tile-type="spacer-tile";}' | |
defaults write com.apple.dock persistent-apps -array-add '{tile-data={}; tile-type="spacer-tile";}' | |
defaults write com.apple.dock persistent-apps -array-add '{tile-data={}; tile-type="spacer-tile";}' | |
defaults write com.apple.dock persistent-apps -array-add '{tile-data={}; tile-type="spacer-tile";}' | |
defaults write com.apple.dock persistent-apps -array-add '{tile-data={}; tile-type="spacer-tile";}' | |
defaults write com.apple.dock persistent-apps -array-add '{tile-data={}; tile-type="spacer-tile";}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I noticed that github's 404 page splits words, for example http://github.com/bitternessflavoraroma | |
# I wondered how I might do it myself. This is slow, but it works with my simple example on my machine. | |
$words = File.new('/usr/share/dict/words').readlines.map { |s| s.strip }.reject { |s| s.length < 2 } | |
$answers = [] | |
def split_words(str, words=[]) | |
$answers << words if str == '' | |
$words.each do |word| | |
split_words(str.sub(word, ''), words.clone << word) if str.start_with?(word) | |
end |