Skip to content

Instantly share code, notes, and snippets.

View citizen428's full-sized avatar

Michael Kohl citizen428

View GitHub Profile
@citizen428
citizen428 / zip_with.rb
Created November 22, 2011 20:46
Haskell's zip_with in Ruby
def zip_with(other, op=nil)
return [] if self.empty? || other.empty?
clipped = self[0..other.length-1]
zipped = clipped.zip(other)
if op
zipped.map { |a, b| a.send(op, b) }
else
zipped.map { |a, b| yield(a,b) }
end
end
@citizen428
citizen428 / octopress_redirects.rb
Created September 26, 2011 07:13
Given a WP XML export, this script will generate the necessary 301 redirect rules for all posts for Apache or Nginx.
require 'date'
require 'rexml/document'
include REXML
doc = Document.new(File.new(ARGV[0]))
format = ARGV[1] || "apache"
formats = {
:apache => "RewriteRule ^%s$ /%s [R=301,L]",
@citizen428
citizen428 / wp-xml-import.rb
Created September 25, 2011 16:19 — forked from zanshin/wp-xml-import.rb
WordPress to Textile Ruby script (I used a Textile plugin for WP). Parses all existing WP categories and tags into discreet list of categories. Finally forces all content to be UTF-8.
require 'fileutils'
require 'date'
require 'yaml'
require 'rexml/document'
include REXML
doc = Document.new(File.new(ARGV[0]))
FileUtils.mkdir_p "_posts"

Help:

C-h t Tutorial
C-h m Help for active mode
C-h k Help for key sequence
C-h f Help for function
C-h v Help for variable
C-h a Search help
C-h i Info reader

(ns step1)
(defn fact
[n]
(if (< n 2) 1 (* n (fact (dec n)))))
;; (fact 5) => 120
(use '(incanter core charts io))
;;; Ruby/Rails development
;; RVM support
;; Ruby Version Manager
(require 'rvm)
(rvm-use-default)
;; automatically add 'end' after class, module, def etc.
;; automatically pair braces, single and double quotes
(require 'ruby-electric)
# Get the official Emacs repo:
git clone http://repo.or.cz/r/emacs.git/
# Get the fullscreen patch
git remote add typester git://github.com/typester/emacs.git
git fetch typester
# Create a patch and apply to HEAD
# I had merge conflicts when rebasing and
# build failures for origin/emacs-23