Skip to content

Instantly share code, notes, and snippets.

View dagbrown's full-sized avatar

Dave Brown dagbrown

View GitHub Profile
#!/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 == '\\':
@dagbrown
dagbrown / how-to-be-an-asshole.py
Created July 10, 2013 04:45
If a computer knows what a person is trying to accomplish, it's not the computer's job to actually do what the person was asking to do. It's the computer's job to tell them the correct way to do what they're obviously trying to do.
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 == '\\':
@dagbrown
dagbrown / gist:7409062
Created November 11, 2013 07:01
lol python
Python 2.7.5 (default, Nov 6 2013, 17:10:18)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> a = 5
>>> a > 3
True
>>> a < 3
False
>>> True = 42
>>> True * 2