Skip to content

Instantly share code, notes, and snippets.

@jakemcgraw
jakemcgraw / pear.rb
Created February 16, 2010 18:40
Puppet PHP Pear provider
We couldn’t find that file to show.
#!/usr/bin/env python
# Four men want to cross a bridge. The bridge is of a width such that a
# maximum of 2 people may cross at a time.
#
# One man takes 10 minutes to cross, another takes 5 minutes to cross,
# another takes 2 minutes to cross, and the last takes 1 minute to
# cross.
# I will call these men A, B, C, and D, respectively.
@pete
pete / 0-README
Last active February 10, 2024 07:12
Various implementations of the 'cat' command, for comparison.
I turned this gist into a "real" repository. It is here: http://github.com/pete/cats .
Here, placed side-by-side for comparison, are GNU's implementation of
cat, Plan 9's implementation, Busybox's implementation, and NetBSD's
implementation, Seventh Edition Unix (1979), and 4.3BSD.
For good measure (and because I suppose I am now committed to collecting
cats) also included are Second Edition Unix (in assembly) and Inferno's
implementation (in Limbo) for good measure.
@jdp
jdp / refactor.py
Created December 7, 2010 04:59
A toy tail-recursive concatenative language implementation
#!/usr/bin/env python
import sys
import types
import operator
class Runtime:
def __init__(self, env={}, stack=[]):
self.env = {
# Primitive words, not an impressive base but it works
@miku
miku / mysqldump2sqlite3.sh
Created December 14, 2010 20:28
Convert a mysql database dump into something sqlite3 understands.
#!/bin/sh
# ================================================================
#
# Convert a mysql database dump into something sqlite3 understands.
#
# Adapted from
# http://stackoverflow.com/questions/489277/script-to-convert-mysql-dump-sql-file-into-format-that-can-be-imported-into-sqlit
#
# (c) 2010 Martin Czygan <martin.czygan@gmail.com>
@miku
miku / maximize.py
Last active September 16, 2016 08:06
Find the maximal difference between items u, v (where index(u) < index(v)) of a given sequence ``a``. Think stockmarket prices. Dynamic programming.
#!/usr/bin/env python
def maximize(a):
""" Find the maximal difference between items u, v
(where index(u) < index(v)) of a given sequence ``a``.
Think stockmarket prices.
Returns the actual difference, start and end position in ``a`` and
the sublist yielding the best result.
@reagent
reagent / inspect.js
Created January 21, 2011 04:13
Inspect JavaScript objects -- useful for debugging.
var Inspector = function(target) {
var inspector = this,
target = target;
function padding(indentationLevel) {
paddingText = '';
for (var i = 0; i < indentationLevel; i++) {
paddingText += ' ';
}
@adulau
adulau / hn2bookmarks.pl
Created April 24, 2011 15:32
Perl script to dump the urls submitted by an HN user (news.ycombinator.com)
#!/usr/bin/perl
#
#
# This perl script is dumping the urls submitted
# by an HN user. Sometime it's better than any
# del.icio.us stream when the HN user has some
# special interests.
#
# Usage:
#
@karmi
karmi / elastic_search_ngram_analyzer_for_urls.sh
Created May 24, 2011 15:32
NGram Analyzer in ElasticSearch
# ========================================
# Testing n-gram analysis in ElasticSearch
# ========================================
curl -X DELETE localhost:9200/ngram_test
curl -X PUT localhost:9200/ngram_test -d '
{
"settings" : {
"index" : {
"analysis" : {
@masnick
masnick / gitolite_hn.bash
Created June 20, 2011 15:36
Setting up gitolite (hn)
# Assuming Ubuntu 10.04 with git already installed.
#
# Make sure to secure your server: http://www.andrewault.net/2010/05/17/securing-an-ubuntu-server/
# These instructions are based on:
# http://sitaramc.github.com/gitolite/doc/1-INSTALL.html:
# First, get you id_rsa.pub onto the server as /tmp/YourName.pub
scp ~/ssh/id_rsa.pub you@git.you.com:/tmp/