Skip to content

Instantly share code, notes, and snippets.

@JFFail
JFFail / parse_dna.rb
Last active August 29, 2015 14:17
Solution To Reddit Daily Programmer #207
#!/usr/env/ruby
#Reddit Daily Programmer 207
#Includes bonus.
#Function for parsing a protein sequence.
def proteins(dna)
#Create hash for the codons.
codons = {"TTT"=>"Phe","TTC"=>"Phe","TTA"=>"Leu","TTG"=>"Leu","TCT"=>"Ser","TCC"=>"Ser","TCA"=>"Ser","TCG"=>"Ser","TAT"=>"Tyr","TAC"=>"Tyr","TAA"=>"STOP","TAG"=>"STOP","TGT"=>"Cys","TGC"=>"Cys","TGA"=>"STOP","TGG"=>"Trp","CTT"=>"Leu","CTC"=>"Leu","CTA"=>"Leu","CTG"=>"Leu","CCT"=>"Pro","CCC"=>"Pro","CCA"=>"Pro","CCG"=>"Pro","CAT"=>"His","CAC"=>"His","CAA"=>"Gln","CAG"=>"Gln","CGT"=>"Arg","CGC"=>"Arg","CGA"=>"Arg","CGG"=>"Arg","ATT"=>"Ile","ATC"=>"Ile","ATA"=>"Ile","ATG"=>"Met","ACT"=>"Thr","ACC"=>"Thr","ACA"=>"Thr","ACG"=>"Thr","AAT"=>"Asn","AAC"=>"Asn","AAA"=>"Lys","AAG"=>"Lys","AGT"=>"Ser","AGC"=>"Ser","AGA"=>"Arg","AGG"=>"Arg","GTT"=>"Val","GTC"=>"Val","GTA"=>"Val","GTG"=>"Val","GCT"=>"Ala","GCC"=>"Ala","GCA"=>"Ala","GCG"=>"Ala","GAT"=>"Asp","GAC"=>"Asp","GAA"=>"Glu","GAG"=>"Glu","GGT"=>"Gly","GGC"=>"Gly","GGA"=>"Gly","GGG"=>"Gly"}
#Now loop through.
@JFFail
JFFail / kill-psping.ps1
Last active August 29, 2015 14:18
Script to kill psping instances when they crash due to too many connectivity failures.
$failCounter = 0
$phrases = ("Process Kill!", "Double Process!", "Triple Process!", "Processtacular!", "Process Frenzy!", "Proctrocity!", "Procemanjaro!")
while($true)
{
#Query all processes.
$processes = Get-Process
$counter = 0
@JFFail
JFFail / cull_nums.rb
Created April 3, 2015 14:47
Solution To Reddit Daily Programmer #208 - Culling Duplicate Numbers
#!/usr/bin/ruby
#Reddit Daily Programmer 208
#http://www.reddit.com/r/dailyprogrammer/comments/30ubcl/20150330_challenge_208_easy_culling_numbers/
puts "Enter your numbers."
print "> "
input = $stdin.gets.chomp
input_array = input.split(" ")
#Get the unique values.
uniques = input_array.uniq
@JFFail
JFFail / int-harmony.ps1
Created April 16, 2015 20:20
Reddit Daily Programmer #210 - Integer Harmony
#Reddit Daily Programmer #210 - http://www.reddit.com/r/dailyprogrammer/comments/32goj8/20150413_challenge_210_easy_intharmonycom/
#Function to append zeros.
function ConvertToBinary
{
param($integer)
return [Convert]::ToString($integer, 2)
}
@JFFail
JFFail / deviation.rb
Last active August 29, 2015 14:21
Solution to Reddit Daily Programmer #214
#!/usr/env/ruby
#http://www.reddit.com/r/dailyprogrammer/comments/35l5eo/20150511_challenge_214_easy_calculating_the/
#values = [5, 6, 11, 13, 19, 20, 25, 26, 28, 37]
values = [37, 81, 86, 91, 97, 108, 109, 112, 112, 114, 115, 117, 121, 123, 141]
sum = 0
mid_sum = 0
#Calculate the mean.
values.each do |x|
sum += x
@JFFail
JFFail / stack-lumber.ps1
Created June 3, 2015 21:12
Solution To Reddit Daily Programmer #217
#Reddit Daily Programmer #217 - http://www.reddit.com/r/dailyprogrammer/comments/3840rp/20150601_challenge_217_easy_lumberjack_pile/
#Define the parameters of the piles.
<#
$grid = 3
$logs = 7
$stacks = @(@(1, 1, 1), @(2, 1, 3), @(1, 4, 1))
#>
<#
$grid = 4
@JFFail
JFFail / find-palindrome.ps1
Created June 8, 2015 19:58
Solution to Reddit Daily Programmer #218
#http://www.reddit.com/r/dailyprogrammer/comments/38yy9s/20150608_challenge_218_easy_making_numbers/
#Function to see if the number is already a palindrome or not.
function IsPalindrome
{
param($num)
#Find the length.
$len = ([string]$num).Length
#Check it.
@JFFail
JFFail / num_palindrome.rb
Created June 11, 2015 21:48
Ruby Solution To Reddit Daily Programmer #218
#!/usr/env/ruby
#Function to test if the current value is a palindrome!
def is_palindrome(num)
len = num.to_s.length
numArr = num.to_s.split("")
is_pal = true
#Loop through the array, comparing the beginning to the end.
for i in 0...len/2
@JFFail
JFFail / todo_list.rb
Created June 19, 2015 01:49
Solution to Reddit Daily Programmer #218
#!/usr/env/ruby
#Defining the object for my list.
class Todo
#Just create an empty array off the bat.
def initialize
@list = Array.new
end
#Function to add new items.
@JFFail
JFFail / test-reference.ps1
Created June 25, 2015 19:15
PowerShell Reference Example
function Lulz
{
param([REF]$Stuff)
$Stuff.Value *= 5
}
$nonsense = 5
Lulz -Stuff ([REF]$nonsense)
Write-Host $nonsense