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
| #!/usr/bin/env ruby | |
| results = [] | |
| (1..1000000).each do |value| | |
| if((value.to_s == value.to_s.reverse) && (value.to_s(2) == value.to_s(2).reverse)) | |
| results << value | |
| end | |
| end | |
| p results.inject(&:+) |
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
| #!/usr/bin/env ruby | |
| START=2 | |
| STOP=100 | |
| pairs_without_repeats = [] | |
| (START..STOP).each { |outer| | |
| (START..outer).each{ |inner| | |
| pairs_without_repeats << [outer,inner] | |
| } | |
| } |
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
| #!/usr/bin/env Rscript | |
| triangle <- read.table("padded_triangle.txt") | |
| size <- 100 | |
| for(r in (size-1):1){ | |
| for(c in r:1){ | |
| max_value = max(triangle[r+1,c],triangle[r+1,c+1]) | |
| triangle[r,c] <- triangle[r,c] + max_value | |
| } | |
| } | |
| print(triangle[1,1]) |
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
| schema () | |
| { | |
| sed -n "/table \"$1\"/,/^ *end/ p" db/schema.rb | |
| } |
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
| count=0; for i in $(find . -name \*.rb); do count=`expr $count + $(git blame $i | grep "Anthony Broad" | wc -l)`; done; echo "ABC wrote $count lines of code"; |
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
| function kk { | |
| echo "" | |
| echo "The epubs on your desktop are:" | |
| cd ~/Desktop; | |
| index=0 | |
| FILES=() | |
| for i in $(find . -name \*epub); do |
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
| vi -o $(git status | grep modified | awk '{print $3}') |
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 MakeUserToInvite | |
| def self.make(community_id=55,first_name=nil,last_name=nil,email=nil) | |
| p = Person.new | |
| p.first_name = first_name || random_string | |
| p.last_name = last_name || random_string | |
| e = EmailAddress.create(:person => p, | |
| :email_address => (email || "#{random_string}@aoeuaoue.com"), | |
| :confirmed_status => "confirmed", | |
| :is_primary => true) | |
| e.save |
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
| function prr { | |
| bundle exec rake routes | fgrep :action | \ | |
| \ | |
| awk '{ | |
| method=""; | |
| for(i=1;i<=NF;i++){ | |
| if ($i ~ /^\//){ | |
| example_url=$i; | |
| } | |
| else if($i ~ /[GET|PUT|POST|DELETE]/){ |
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
| syntax enable | |
| syntax on | |
| set cursorline | |
| set expandtab | |
| set ts=2 | |
| set shiftwidth=2 | |
| set autoindent | |
| set number | |
| set background=dark | |
| set nobackup |