Skip to content

Instantly share code, notes, and snippets.

@AaronCRobinson
AaronCRobinson / Count lines in Git repo
Created September 7, 2018 20:19 — forked from mandiwise/Count lines in Git repo
A command to calculate lines of code in all tracked files in a Git repo
// Reference: http://stackoverflow.com/questions/4822471/count-number-of-lines-in-a-git-repository
$ git ls-files | xargs wc -l
@AaronCRobinson
AaronCRobinson / keybase.md
Created August 26, 2017 18:06
Keybase public key

Keybase proof

I hereby claim:

  • I am aaroncrobinson on github.
  • I am aaroncrobinson (https://keybase.io/aaroncrobinson) on keybase.
  • I have a public key ASCGmnIqwwx1AkTAQzb1y50-qB7jvsrYOXR7aqfYTeCURAo

To claim this, I am signing this object:

module Test
@@options = nil
end
module TestIncludedA
include Test
def set_options
@@options = "something"
end
@AaronCRobinson
AaronCRobinson / meta_def.rb
Created February 26, 2014 23:46
Meta Programming example for taking two classes and including their singleton methods in a new parent class. This is a form of multiple inheritance.
# http://whytheluckystiff.net/articles/seeingMetaclassesClearly.html
# NOTE: originally used above meta_def method but extended for arguements
class Object
def meta_def name, method
# add class variable method with arguement passthrough
(class << self; self; end).instance_eval { define_method(name) { |*args| method.call(*args)} }
end
end
require 'date'
@AaronCRobinson
AaronCRobinson / classify.rb
Created February 26, 2014 23:35
Saw this on SO somewhere. This is helpful for adding classify function to string type. (simular to camelize)
class String
def classify
self.split('_').collect!{ |w| w.capitalize }.join
end
end
@AaronCRobinson
AaronCRobinson / mixins.rb
Created February 21, 2014 23:17
Example of using a module with a class for mixin-ish behavior
#!/usr/bin/ruby
# Example of using a module with a class for mixin-ish behavior
module ModA
class ClassB
attr_accessor :var
def initialize
puts "Initializing ClassB"
@var = nil
end
@AaronCRobinson
AaronCRobinson / homopolymers.py
Created February 19, 2014 23:38
Quick write up of counting of homopolymers using regular expressions in python.
import argparse, regex, csv
from Bio import SeqIO
def countHomopolymers(seq):
""" Given a string sequence, return a dictionary counting its homopolymers """
# split the string into homopolymers
# NOTE: regex will produce empty strings, filter them
segments = filter(None, regex.findall('[A]*|[T]*|[C]*|[G]*',seq.upper()))
mersDict = {'A':[0]*7,'T':[0]*7,'C':[0]*7,'G':[0]*7}
for seq in segments:
@AaronCRobinson
AaronCRobinson / pydecorator.rb
Created February 19, 2014 23:36
Python Decorator-ish Implementation in Ruby using Refinement
#!/usr/bin/ruby2.0
# NOTE: only works with Ruby 2.0
# CONTEXT: One of my favorite features to python is decorators.
# This is the most elegant and clean solution for
# decorator-like functionality in Ruby.
# RELATED: originally posted as anon - https://gist.github.com/anonymous/9103635
class A
def initialize(msg=nil)
@msg = msg