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
| #project_euler problem_56 | |
| #A googol (10**100) is a massive number: one followed by one-hundred zeros; 100**100 is almost unimaginably large: one followed by two-hundred zeros. Despite their size, the sum of the digits in each number is only 1. | |
| #Considering natural numbers of the form, ab, where a, b 100, what is the maximum digital sum? | |
| sum_of_digits =->(a,b){ (a**b).to_s.split('').collect(&:to_i).inject(&:+) } | |
| max_of =->(y, z){ y > z ? y : z} | |
| for a in (1..99) | |
| for b in (1..99) | |
| @max = max_of.(sum_of_digits.(a,b), @max ||= 0) | |
| end |
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
| # This sketch demonstrates how to use | |
| # Ruby-Processing. | |
| def setup | |
| size 450, 450 | |
| smooth | |
| background 255 | |
| end | |
| def draw |
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
| module GeneralInit | |
| def initialize(*h) | |
| puts h == 1 && h.first.kind_of?(Hash) | |
| if h.length == 1 && h.first.kind_of?(Hash) | |
| h.first.each { |k,v| instance_variable_set("@#{k}",v) } | |
| end | |
| end | |
| end |
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
| module GeneralInit | |
| def initialize(*h) | |
| if h.length == 1 && h.first.kind_of?(Hash) | |
| h.first.each { |k,v| instance_variable_set("@#{k}",v) } | |
| end | |
| end | |
| end | |
| class Me | |
| include GeneralInit |
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
| parent = Process.pid | |
| puts parent.to_s + ": the parent process id" | |
| forked_id = fork{ exec('ls | grep back')} | |
| #^from that carrot in the line above, a child process is forked from the current (which is then parent) process. | |
| #because there are two processes running, forked_id will be assigned in each process--e.g. two forked_id varaibles are created. | |
| #in the child it is nil, but in the parent it is the child's pid. If a block is provided to fork, the child executes the block contents and | |
| #ends. It may seem that the child process returns after the parent, but if the parent's task is long, the child may return in the middle | |
| #of the parents job. | |
| puts "fork returns #{forked_id.nil? ? 'nil' : forked_id} to " + Process.pid.to_s |
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
| 1. go to http://www.genenames.org/cgi-bin/hgnc_downloads.cgi and create a text | |
| output of the currated hgnc files. | |
| % head hgnc.cleaned.txt | |
| A12M1~withdrawn | |
| A12M2~withdrawn | |
| A12M3~withdrawn | |
| A12M4~withdrawn | |
| A1BG ENSG00000121410 | |
| A1S9T~withdrawn | |
| A2M ENSG00000175899 |
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
| 1. Created a script for stripping out the urls for genbank files. | |
| #IRES_PLASMID_SCRAPER.rb | |
| pwd = "/Users/timrand/Dropbox/NAT1/" | |
| file = pwd + "IRES_plasmids.txt" | |
| website_url = "http://iresite.org/IRESite_web.php?page=gb_download&file=" | |
| out_file = pwd + "ires_plasmid_urls.txt" | |
| f = File.read(file) |
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
| #command-line usage: | |
| #% ruby /Users/timrand/Dropbox/NAT1/peptide_mapper3.rb peptide_file target_file | |
| # 1 M 0 | |
| # 2 S 0 | |
| # 3 P 8 [][][][][][][][] | |
| # 4 A 8 [][][][][][][][] | |
| # 5 G 8 [][][][][][][][] | |
| # 6 S 8 [][][][][][][][] | |
| # 7 C 8 [][][][][][][][] | |
| # 8 D 8 [][][][][][][][] |
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
| #command-line usage: | |
| #% ruby /Users/timrand/Dropbox/NAT1/peptide_mapper3.rb peptide_file target_file | |
| # 1 M 0 | |
| # 2 S 0 | |
| # 3 P 8 [][][][][][][][] | |
| # 4 A 8 [][][][][][][][] | |
| # 5 G 8 [][][][][][][][] | |
| # 6 S 8 [][][][][][][][] | |
| # 7 C 8 [][][][][][][][] | |
| # 8 D 8 [][][][][][][][] |
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
| #command-line usage: | |
| #% ruby /Users/timrand/Dropbox/NAT1/peptide_mapper3.rb peptide_file target_file | |
| # 1 M 0 | |
| # 2 S 0 | |
| # 3 P 8 [][][][][][][][] | |
| # 4 A 8 [][][][][][][][] | |
| # 5 G 8 [][][][][][][][] | |
| # 6 S 8 [][][][][][][][] | |
| # 7 C 8 [][][][][][][][] | |
| # 8 D 8 [][][][][][][][] |