This file contains hidden or 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
| def test_p_word(self): | |
| e = Evaluator() | |
| # Add negative reviews | |
| e.add_review(False, {"horrible", "crappy", "boring"}) | |
| e.add_review(False, {"awfully", "mediocre"}) | |
| e.add_review(False, {"terrible", "boring"}) | |
| # Add positive reviews | |
| e.add_review(True, {"wonderful", "delightful", "awesome"}) |
This file contains hidden or 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
| class Container < Struct.new :val | |
| def inspect | |
| return "&<#{val.inspect}>" | |
| end | |
| end | |
| irb(main):010:0> a = Container.new(5) | |
| => &<5> | |
| irb(main):011:0> s = [a,a] | |
| => [&<5>, &<5>] |
This file contains hidden or 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
| meizu/%.meizu.avi : %.avi | |
| cd meizu && meizu-convert ../$< | |
| all: $(patsubst %,meizu/%,$(patsubst %.avi,%.meizu.avi,$(wildcard *.avi))) |
This file contains hidden or 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
| #!/bin/bash | |
| # A simple script to make sure I am running rtorrent in a screen | |
| if ! ps -o uname -C rtorrent | grep -q `whoami`; then | |
| screen -d -m rtorrent | |
| fi |
This file contains hidden or 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
| MAX_KEY_LENGTH = 20 | |
| PEAK_MIN_OFFSET = 4 | |
| NUM_LETTERS = 26 | |
| FIRST_LETTER = "A" | |
| KEY_LENGTH_GUESS = 6 | |
| def index_of_coincidence(s, shift): | |
| """Find the index of coincidence of s with itself shifted by shift""" |
This file contains hidden or 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
| Epsilon = 1e-10 | |
| def d_dx(&f) # :yields: x | |
| Proc.new do |x| | |
| (f[x + Epsilon] - f[x])/Epsilon | |
| end | |
| end | |