Skip to content

Instantly share code, notes, and snippets.

@AlexNisnevich
AlexNisnevich / score_subreddit.rb
Created November 9, 2012 11:32
score_subreddit: Computes the Flesch-Kincaid grade level of the last 25 comments of the given subreddits.
#
# Usage: ruby score_subreddit.rb <list of subreddits>
#
# Computes the Flesch-Kincaid grade level of the last 25 comments of the given subreddits.
#
# For example:
# > ruby score_subreddit.rb science worldnews funny
# science: 8.33
# worldnews: 9.71
# funny: 5.32
#!/bin/sh
export DISPLAY=:0.0
sudo killall chrome
google-chrome $1 &
sleep 2
xdotool key F11
@AlexNisnevich
AlexNisnevich / deep_sort.rb
Created July 19, 2012 19:51
Playing with Ruby hashes
class Hash
def deep_sort
Hash[sort.map {|k, v| [k, v.is_a?(Hash) ? v.deep_sort : v]}]
end
end
@AlexNisnevich
AlexNisnevich / gist:3140977
Created July 19, 2012 05:33
Github Pages for generated HTML

Assuming this directory structure:

project
|-- src
|   +-- (source files)
+-- html
    +-- (generated html)
@AlexNisnevich
AlexNisnevich / .zshrc
Created July 8, 2012 02:54
zshrc stuff
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
import sys
def negVector(lst):
return [-x for x in lst]
def addVectors(l1, l2):
return [l1[i] + l2[i] for i in range(len(l1))]
def multVectors(l1, l2):
return [l1[i] * l2[i] for i in range(len(l1))]