Skip to content

Instantly share code, notes, and snippets.

require 'digest/md5'
def gfm(text)
# Extract pre blocks
extractions = {}
text.gsub!(%r{<pre>.*?</pre>}m) do |match|
md5 = Digest::MD5.hexdigest(match)
extractions[md5] = match
"{gfm-extraction-#{md5}}"
end
@vangberg
vangberg / DWM-ON-OS-X.md
Created February 22, 2010 19:24
dwm on os x [work in progress!]

Installing and configuring dwm on OS X

  1. Install XQuartz (http://xquartz.macosforge.org) which is the development version of the X11.app that ships with OS X, which means it is way more up to date. I have had some weird issues with X11.app v. 2.3-something. XQuartz 2.5.0 fixed that.

  2. Install dwm from Homebrew, brew install dwm. This makes a bunch of necessary tweaks to the DWM configuration.

  3. Add the following script to $PATH, name it dwm-launch and chmod 755:

    cd ~
    

while true

@isaacs
isaacs / comma-first-var.js
Created April 6, 2010 19:24
A better coding convention for lists and object literals in JavaScript
// See comments below.
// This code sample and justification brought to you by
// Isaac Z. Schlueter, aka isaacs
// standard style
var a = "ape",
b = "bat",
c = "cat",
d = "dog",
@kiko
kiko / sync
Created August 21, 2010 17:00 — forked from manveru/sync
#!/usr/bin/env ruby
require 'open-uri'
require 'cgi'
require 'pp'
require 'yaml'
require 'rake'
module GitHub
module Connectivity
@isaacs
isaacs / node-and-npm-in-30-seconds.sh
Last active July 21, 2024 01:20
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
@evnm
evnm / file-browser-with-dropbox-node-0.2.0.js
Created January 11, 2011 08:44
Updated version of file browser demo using dropbox-node v0.2.0.
var sys = require('sys')
, DropboxClient = require('dropbox').DropboxClient
, express = require('express')
, app = express.createServer()
, consumer_key = '85m56oj9a6ekr1k'
, consumer_secret = 'kirag26pr0pbf3z'
app.configure(function () {
app.use(express.logger())
app.use(express.bodyDecoder())
@snuggs
snuggs / .tmux.conf
Last active February 7, 2023 13:51
IDE & TMUX Configuration
############################################################################
# _
# | |_ _ __ ___ _ ___ __
# | __| '_ ` _ \| | | \ \/ /
# | |_| | | | | | |_| |> <
# \__|_| |_| |_|\__,_/_/\_\
#
# Cheatsheets:
# https://devhints.io/tmux
# `property not found` issue:
@undecided
undecided / ruby_and_mirah.rb
Created March 9, 2011 22:32
Shows a simple class implemented in Ruby and Mirah
# Ruby
class Rubyish
def a_method(some_string, some_hash)
@message = some_string
@transform = some_hash
puts @message
end
def another_method
@transform.each_pair do |key, val|
@emk
emk / mkpdfs.rb
Created May 9, 2011 01:12
Turn Inkscape SVG layers into PDF presentation slides
#!/usr/bin/env ruby
require 'rubygems'
require 'bundler'
Bundler.require(:default)
require 'fileutils'
include FileUtils
# Delete any
@criminy
criminy / example.js
Created June 3, 2011 01:56
Form validation example for expressjs
server.all('/admin/content/add_article',function(req,res)
{
server.form('post',req,res,function(form) {
form.required('title')
form.optional('tags')
form.required('slug')
form.required('body')
form.valid(function(form) {
res.send('Creating blog post titled : ' + form.values.title)