Skip to content

Instantly share code, notes, and snippets.

@atiw003
atiw003 / wp-xml-octopress-import.rb
Created May 20, 2012 07:04 — forked from tnmt/wp-xml-octopress-import.rb
Import XML of Wordpress to Octopress
# -*- coding: utf-8 -*-
require 'fileutils'
require 'date'
require 'yaml'
require 'uri'
require 'rexml/document'
include REXML
doc = Document.new File.new(ARGV[0])
@atiw003
atiw003 / wordpress_importer.rb
Created May 20, 2012 06:59 — forked from Oneiroi/wordpress_importer.rb
Import a WordPress database and generate markdown files for Jekyll
# based on the import script by icebreaker, which is based on mojombo's
# https://github.com/mojombo/jekyll/blob/master/lib/jekyll/migrators/wordpress.rb
# https://gist.github.com/303570
# edited to rewrite image URLs to use my CloudFront URL
require 'rubygems'
require 'sequel'
require 'fileutils'
require 'yaml'
@atiw003
atiw003 / tree.md
Created April 24, 2012 10:56 — forked from hrldcpr/tree.md
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

@atiw003
atiw003 / virtualenv-auto-activate.sh
Created April 23, 2012 10:40 — forked from robbles/virtualenv-auto-activate.sh
virtualenv-auto-activate with support for zsh and virtualenvwrapper
#!/bin/bash
# virtualenv-auto-activate.sh
#
# Installation:
# Add this line to your .bashrc or .bash-profile:
#
# source /path/to/virtualenv-auto-activate.sh
#
# Go to your project folder, run "virtualenv .venv", so your project folder
# has a .venv folder at the top level, next to your version control directory.
#!/bin/bash
# virtualenv-auto-activate.sh
#
# Installation:
# Add this line to your .bashrc or .bash-profile:
#
# source /path/to/virtualenv-auto-activate.sh
#
# Go to your project folder, run "virtualenv .venv", so your project folder
# has a .venv folder at the top level, next to your version control directory.
@atiw003
atiw003 / hack.sh
Created March 31, 2012 10:53 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@atiw003
atiw003 / deps.pp
Created March 21, 2012 11:11 — forked from rcrowley/deps.pp
Deploying Django with Puppet
stage { "pre": before => Stage["main"] }
class python {
package {
"build-essential": ensure => latest;
"python": ensure => "2.6.6-2ubuntu1";
"python-dev": ensure => "2.6.6-2ubuntu1";
"python-setuptools": ensure => "latest";
}
exec { "easy_install pip":
path => "/usr/local/bin:/usr/bin:/bin",
@atiw003
atiw003 / mapreduce.scala
Created March 10, 2012 22:07 — forked from paulmillr/mapreduce.scala
Why functional programming matters (aka MapReduce for humans)
import com.cloudera.crunch._
import com.cloudera.scrunch._
class ScrunchWordCount {
def wordCount(inputFile: String, outputFile: String) = {
val pipeline = new Pipeline[ScrunchWordCount]
pipeline.read(from.textFile(inputFile))
.flatMap(_.toLowerCase.split("\\W+"))
.filter(!_.isEmpty())
.count
@atiw003
atiw003 / pre-commit
Created January 16, 2012 09:50 — forked from spulec/pre-commit
Yipit Pre-commit Hook
#!/usr/bin/env python
import os
import re
import subprocess
import sys
modified = re.compile('^(?:M|A)(\s+)(?P<name>.*)')
CHECKS = [
@atiw003
atiw003 / gist:1619917
Created January 16, 2012 09:11 — forked from lentil/gist:810399
PEP8 pre-commit hook in Python
#!/usr/bin/env python
from __future__ import with_statement
import os
import re
import shutil
import subprocess
import sys
import tempfile