Skip to content

Instantly share code, notes, and snippets.

View DanielleSucher's full-sized avatar

Danielle Sucher DanielleSucher

View GitHub Profile
@DanielleSucher
DanielleSucher / one_liners
Last active December 18, 2015 15:49
One-liners
Replace all instances of old_string with new_string recursively within the current directory and its sub-directories:
grep -rl old_string * | xargs sed -i '' 's/old_string/new_string/g'
Sum all numbers in your file (assuming that the numbers are the first column, one per line):
awk '{s+=$1} END {print s}' $filename
@DanielleSucher
DanielleSucher / authors.rb
Created June 5, 2013 18:12
List all committers to a git repository, along with a count of their commits.
`git log --raw > authors.txt`
authors = Hash.new(0)
IO.readlines('authors.txt').each do |line|
if line.match /^Author:/
authors[line.gsub('Author: ', '').chomp] += 1
end
end
@DanielleSucher
DanielleSucher / one_char.sh
Last active December 17, 2015 22:59 — forked from aprescott/gist:5683945
Bash script to find all single-character commits in a git repository
first_commit=$(git log --pretty=format:%H | tail -1)
git rev-list --all --no-merges |
while read commit; do
if [ $commit == $first_commit ]; then break; fi;
IFS_backup=$IFS
IFS=$'\n'
diff_lines=( $(git diff --numstat --minimal -U0 --word-diff=porcelain $commit^ $commit | grep -E '^(\+[^+]|-[^-]).*$') )
IFS=$IFS_backup
@DanielleSucher
DanielleSucher / README
Created June 6, 2012 14:03
Jira Link Colorizer (chrome extension)
Those links in Jira are really hard to see! Not differentiated by color or underline, yeesh.
This Chrome extension solves that problem by simply adding !important background css to make
all links on your Jira site bright orange and underlined.
To use, just clone this gist and change the links in manifest.json line 11 to match the URL(s)
for your Jira installation. Then go your extension manager and click "Load unpacked extension"
to select the directory and get it running. (If you don't see the link near the top left, check
"developer mode" and it will show up.) Problem solved.
@DanielleSucher
DanielleSucher / gist:2715847
Created May 17, 2012 02:50
Huffman encoding for blog post
def insert_branch(branch)
@encoded.each_with_index do |node, i|
if branch[-1] <= node[-1]
@encoded.insert i, branch
return @encoded
end
end
@encoded.push(branch)
end
@DanielleSucher
DanielleSucher / kosaraju.rb
Created April 23, 2012 20:41
Kosaraju's algorithm
# Kosaraju's algorithm for detecting strongly connected components
# (iterative version because the Ruby stack is sad)
$:.unshift File.expand_path('.')
require 'pp'
require 'set'
@t = 0 #finishing time
@explored = Set.new []
@DanielleSucher
DanielleSucher / ssl_client.py
Created April 13, 2012 20:15
gevent (py3) test ssl server and client
# import gevent
# import gevent.socket as socket
# import gevent.ssl as ssl
# from gevent import spawn
import socket
import ssl
import pprint
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)