Skip to content

Instantly share code, notes, and snippets.

@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@sanxiyn
sanxiyn / lisp.c
Created August 14, 2010 04:16
Lisp
#include <assert.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
enum type {
NIL,
@faried
faried / maildirtocouch.py
Created February 1, 2011 22:02
Store messages in a Maildir into a couchdb database.
#!/usr/bin/env python
"""Store messages in a Maildir into a couchdb database."""
import couchdb
from mailbox import Maildir
from optparse import OptionParser
import os
from pprint import pprint
import sys
from uuid import uuid4
@aslakhellesoy
aslakhellesoy / Makefile
Created December 20, 2011 09:43
Fetch NPM modules with Make
node_modules: Makefile
@rm -rf $@
@mkdir -p $@
$(call get_src_module,$@,https://github.com/tastapod/node-imap/tarball/bruno-merge)
$(call get_npm_module,$@,log,1.2.0)
$(call get_npm_module,$@,connect,1.8.2)
# We have to manually fetch connect's dependencies
$(call get_npm_module,$@,qs,0.4.0)
$(call get_npm_module,$@,mime,1.2.4)
$(call get_npm_module,$@,formidable,1.0.8)
@aslakhellesoy
aslakhellesoy / Makefile
Created December 22, 2011 13:22
Publish NPM packages with Make
NAME := $(shell node -e "console.log(JSON.parse(require('fs').readFileSync('package.json', 'utf8')).name)")
VERSION := $(shell node -e "console.log(JSON.parse(require('fs').readFileSync('package.json', 'utf8')).version)")
TARBALL := $(NAME)-$(VERSION).tgz
npm-publish:
@rm -Rf package
@mkdir package
@cp -R lib package/lib
@cp package.json package
@tar czf $(TARBALL) package
@bryanjswift
bryanjswift / .rtorrent.rc
Created December 28, 2011 02:42
rtorrent configuration file with description
# This is an example resource file for rTorrent. Copy to
# ~/.rtorrent.rc and enable/modify the options as needed. Remember to
# uncomment the options you wish to enable.
# Maximum and minimum number of peers to connect to per torrent.
min_peers = 1
max_peers = 100
# Same as above but for seeding completed torrents (-1 = same as downloading)
@jedy
jedy / go_scp.go
Last active May 31, 2022 07:20
an example of scp in golang
// https://blogs.oracle.com/janp/entry/how_the_scp_protocol_works
package main
import (
"fmt"
"golang.org/x/crypto/ssh"
)
const privateKey = `content of id_rsa`
@unbracketed
unbracketed / export_repo_issues_to_csv.py
Last active August 3, 2023 18:13
Export Issues from Github repo to CSV (API v3)
"""
Exports Issues from a specified repository to a CSV file
Uses basic authentication (Github username + password) to retrieve Issues
from a repository that username has access to. Supports Github API v3.
"""
import csv
import requests
@willb
willb / backup-db.rb
Created August 29, 2012 21:00
Backup script for SQLite databases
#!/usr/lib/env ruby
# Acquires a shared lock on a SQLite database file and copies it to a backup
# usage: backup-db.rb DBFILE.db BACKUPFILE.db
# author: William Benton (willb@redhat.com)
# Public domain.
require 'sqlite3'
require 'fileutils'
@lakshminarayanan
lakshminarayanan / development.rb
Created October 4, 2012 07:45
Disable colors in rails console
# disappear the annoying ANSI codes for PowerShell and cmd
if RUBY_PLATFORM =~ /mswin|mingw/i
ActiveSupport::LogSubscriber.colorize_logging = false
end