Skip to content

Instantly share code, notes, and snippets.

View anthonycrumley's full-sized avatar

Anthony Crumley anthonycrumley

View GitHub Profile
require 'haml'
def line_counter(node)
script_filters = %w{ javascript erb plain }
if node.type == :filter && script_filters.include?(node.value[:name])
lines_from_this_node = node.value[:text].split("\n").length
else
lines_from_this_node = 0
end
developers = %w{ arongray tmiller acsellers pho3nixf1re jzw benolee }
pairs = developers.sort.combination(2).to_a
sprint_assignments_without_double_duty = pairs.
combination(developers.length / 2).
to_a.
select{|assignments| assignments.flatten.uniq.length == developers.length}
sprint_assignments_with_unique_pairs =
execute pathogen#infect()
syntax on
filetype plugin indent on
augroup vimrc
set hlsearch
set tabstop=2
set shiftwidth=2
set expandtab
function parse_git_deleted {
[[ $(git status 2> /dev/null | grep deleted:) != "" ]] && echo "-"
}
function parse_git_added {
[[ $(git status 2> /dev/null | grep "Untracked files:") != "" ]] && echo '+'
}
function parse_git_modified {
[[ $(git status 2> /dev/null | grep modified:) != "" ]] && echo "*"
}
function parse_git_dirty {
// We are doing something like this in several places
$("#student_id").bind("keypress", function(e){
if (e.keyCode == 13){
jQuery("#student_submit").parent().parent('form')[0].submit();
return false;
}
});
// The following are a couple of approaches to encapsulate this.
execute pathogen#infect()
syntax on
filetype plugin indent on
augroup vimrc
set hlsearch
set tabstop=2
set shiftwidth=2
set expandtab
set ruler
######################################################################
# Task: Describe a Turing machine that shifts the input string one
# space to the right and places the symbol ($) in the first location
# on the tape.
######################################################################
# Enter values below for
# q_0 : the initial state (an int)
# q_a : the accept state (an int)
# q_r : the reject state (an int)
# delta : the transition function expressed as a dictionary
######################################################################
# Describe a Turing Machine that decides the language
# {w | w has an equal number of 0s and 1}
######################################################################
# Enter values below for
# q_0 : the initial state (an int)
# q_a : the accept state (an int)
# q_r : the reject state (an int)
# delta : the transition function expressed as a dictionary
# with keys (state, symbol) and values (state, symbol, 'L' or 'R')
######################################################################
# Task: Describe a two-tape Turing machine that decides the
# language {x#y | x is a substring of y and x,y in {0,1}^* }
######################################################################
# Enter values below for
# q_0 : the initial state (an int)
# q_a : the accept state (an int)
# q_r : the reject state (an int)
# delta : the transition function expressed as a dictionary
# with keys (state, symbol, symbol) and
@anthonycrumley
anthonycrumley / action_location.rb
Created January 18, 2016 20:25
Add location to actions based on the network event.
require('mongo')
def client
@client ||= Mongo::Client.new([ '127.0.0.1:27017' ], :database => 'network-dev')
end
def actions
client[:actions]
end