Skip to content

Instantly share code, notes, and snippets.

View dagbrown's full-sized avatar

Dave Brown dagbrown

View GitHub Profile
Python 2.7.7 (default, Jul 19 2014, 21:44:39)
[GCC 4.8.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> [ 1, 2, 3 ] + "hi there"
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: can only concatenate list (not "str") to list
>>> x = [ 1,2,3 ];x += "hi there"; x
[1, 2, 3, 'h', 'i', ' ', 't', 'h', 'e', 'r', 'e']
>>>
### Keybase proof
I hereby claim:
* I am dagbrown on github.
* I am dagbrown (https://keybase.io/dagbrown) on keybase.
* I have a public key whose fingerprint is 95F0 71A2 AF40 FB7A 0377 EC5B 3E00 3B56 5A8C 22A6
To claim this, I am signing this object:
#!/usr/bin/ruby
#
# tvrss - a BitTorrent torrent-RSS puller
#
# Make a directory called ~/.tvrss
# Make another called ~/.tvrss/torrents
# Put URLs of RSS feeds in ~/.tvrss/feeds
# Bob's your uncle!
require 'rubygems'
class AnagramDict
begin
@@anagramdict = Marshal.load "anagramdict.marshal"
rescue
@@anagramdict ||= Hash.new
File.read("/usr/share/dict/word.list").split(/\n/).each do |word|
sortedword=word.split('').sort.join
@@anagramdict[sortedword] ||= []
@@anagramdict[sortedword] << word
end
# A nice demonstration of how much faster Ruby 1.9 is than Ruby 1.8
require "complex"
class Complex
def m
z=self
1024.times { |i| z=z*z+self; return i+1 if z.abs > 2 }
return 1024
end
require "complex"; class Complex; def m; z=self; 1024.times {|i|z=z*z+self;
return i+1 if z.abs>2};return 1024 end end;(1.0).step(-1,-0.05) do |y|
(-2.0).step(0.5,0.0315) do |x| print " .,:;~=/$@#"[(Math.log(Complex(x,y).m)/
Math.log(2)).to_i].chr end; puts end
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/shibuyagi-root
ext4 40G 13G 26G 33% /
/dev/mapper/shibuyagi-boot
ext4 97M 86M 6.3M 94% /boot
/dev/mapper/shibuyagi-dagbrown
ext4 99G 28G 66G 30% /home/dagbrown
tmpfs tmpfs 4.0M 0 4.0M 0% /var/lock
tmpfs tmpfs 4.0M 64K 4.0M 2% /var/run
tmpfs tmpfs 3.0G 0 3.0G 0% /dev/shm
# robots.txt for http://www.whitehouse.gov/
User-agent: *
Disallow: /cgi-bin
Disallow: /search
Disallow: /query.html
Disallow: /help
Disallow: /360pics/iraq
Disallow: /360pics/text
Disallow: /911/911day/iraq
#!/usr/bin/zsh
DELETE_WAV=true
while true
do
case "$1" in
-r)
shift;
RATE=$1
def setquit():
"""Define new builtins 'quit' and 'exit'.
These are objects which make the interpreter exit when called.
The repr of each object contains a hint at how it works.
"""
if os.sep == ':':
eof = 'Cmd-Q'
elif os.sep == '\\':