Skip to content

Instantly share code, notes, and snippets.

@fredrick
fredrick / SOTU.tsv
Created January 25, 2012 06:24
Top 1000 words of President Obama's 2012 State of the Union Address
Word Occurrences Frequency Rank
our 84 2.1% 1
you 37 0.9% 2
american 35 0.9% 2
jobs 34 0.8% 3
america 30 0.7% 4
we\ 30 0.7% 4
right 27 0.7% 4
new 27 0.7% 4
now 26 0.6% 5
@fredrick
fredrick / getscala.sh
Created December 22, 2011 22:06
Install scala
wget http://www.scala-lang.org/downloads/distrib/files/scala-2.9.1.final.tgz
tar -xzvf scala-2.9.1.final.tgz
@fredrick
fredrick / README.md
Created November 22, 2011 18:17
Graylog2 Upstart Jobs

#Graylog2 Upstart

A basic set of Upstart jobs to get Graylog2 up and running quickly. Assumes MongoDB and Graylog2 installed in /opt/. Tested on Ubuntu Server 10.04 LTS, MongoDB 2.0.0, graylog2-server-0.9.5p1, and graylog2-web-interface-0.9.5p2.

#Usage

Place job definitions in /etc/init/ and then use service [job] [command] to start/stop/restart/status the services manually. On boot, the services flow into each other, only starting if dependent services have started. For more on controlling jobs or Upstart in general (a replacement for System-V init), see the cookbook.

#Author

@fredrick
fredrick / index.html
Created October 31, 2011 18:54
Bare necessities of an HTML(5) document
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Title</title>
</head>
<body>
<!--Content goes here!-->
</body>
</html>
@fredrick
fredrick / install_django.sh
Created October 6, 2011 16:58
Installing Django (virgin) in OS X Leopard
#!/bin/sh
# In Terminal
cd
curl -O http://pypi.python.org/packages/2.5/s/setuptools/setuptools-0.6c11-py2.5.egg
sh ~/setuptools-0.6c11-py2.5.egg
sudo easy_install django
@fredrick
fredrick / optional.py
Created September 28, 2011 15:23
Optional function arguments in Python
def hello(f, k=None):
"""
@param f is required
@param k is optional
"""
if (k == None): return '%s, hello world!' % f
else: return 'Hello %s!, said %s' % (f, k)
print(hello('Tony'))
print(hello('Tony', 'Fred'))
@fredrick
fredrick / feed.html
Created September 23, 2011 14:54
RSS Widget
<div class="feed">
<script type="text/javascript">
(function(url, callback) {
jQuery.ajax({
url: document.location.protocol + '//ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=10&callback=?&q=' + encodeURIComponent(url),
dataType: 'json',
success: function(data) {
callback(data.responseData.feed);
}
});
# the rest of this snippet assumes installation of libxml 2.7.8. YMMV.
brew install libxml2
brew link libxml2
# install libxslt from source
wget ftp://xmlsoft.org/libxml2/libxslt-1.1.26.tar.gz
tar -zxvf libxslt-1.1.26.tar.gz
cd libxslt-1.1.26
./configure --prefix=/usr/local/Cellar/libxslt/1.1.26 \
--with-libxml-prefix=/usr/local/Cellar/libxml2/2.7.8
var gistPrefix = 'https://gist.github.com/',
cachedWrite = document.write,
body = $('body'),
gists = $('p.gist').map(function(n, p) {
p = $(p);
var a = $('a', p),
href = a.attr('href');
if (a.length && href.indexOf(gistPrefix) == 0) {
var data = [[1294816638788, 560], [1294816703445, 850]];
var dates = data.map(function(data){
return data[0];
});
var values = data.map(function(data){
return data[1];
});
console.log(dates);
console.log(values);