Skip to content

Instantly share code, notes, and snippets.

@fredrick
fredrick / couchdb.conf
Created November 28, 2011 01:43 — forked from kowsik/couchdb.conf
Upstart script for CouchDB
# Upstart file at /etc/init/couchdb.conf
# CouchDB
start on runlevel [2345]
stop on runlevel [06]
pre-start script
chown -R couchdb /usr/local/etc/couchdb
chown -R couchdb /usr/local/lib/couchdb
chown -R couchdb /usr/local/var/log/couchdb
@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 / FirstSteps.1.md
Created November 9, 2011 21:08
JavaScript In a "Gist" | Client-side web development

#First Steps

##Development environment JavaScript is most commonly added to HTML documents as either an embedded or external script.

<!DOCTYPE html>
<html>
<head>
 
@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
@fredrick
fredrick / screen.md
Created September 14, 2011 15:30
GNU Screen Cheat Sheet

#GNU Screen Cheat Sheet

##Basics

  • ctrl a c -> cre­ate new win­dow
  • ctrl a A -> set win­dow name
  • ctrl a w -> show all win­dow
  • ctrl a 1|2|3|… -> switch to win­dow n
  • ctrl a " -> choose win­dow
  • ctrl a ctrl a -> switch between win­dow
  • ctrl a d -> detach win­dow
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) {