This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn my-count [coll] | |
(reduce (fn [n x] (inc n)) 0 coll)) | |
(my-count [1 2 3 3]) ;; produces 4 | |
(defn my-reverse [coll] | |
(reduce (fn [xs x] (into [x] xs)) [] coll)) | |
(my-reverse [1 2 3]) ;; => [3 2 1] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Tom Crayford adapted this from clojure-test-mode.el | |
(require 'clojure-mode) | |
(require 'cl) | |
(require 'slime) | |
(require 'swank-clojure) | |
(require 'which-func) | |
;; Faces |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun untabify-buffer () | |
(interactive) | |
(untabify (point-min) (point-max))) | |
(defun indent-buffer () | |
(interactive) | |
(indent-region (point-min) (point-max))) | |
(defun cleanup-buffer () | |
"Perform a bunch of operations on the whitespace content of a buffer." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn some-name [f] ;; Takes a function that | |
(fn [& fns] ;; Returns a function that takes a list of functions that returns | |
(fn [& args] ;; A function that calls the original function with identity over applying each function to the args of this anonymous function #ohgod | |
(f identity (map apply fns (repeat args)))))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Vim compiler file | |
" Language: RSpec | |
" Maintainer: Tim Pope <[email protected]> | |
" Last Change: 2009 Dec 22 | |
" URL: http://vim-ruby.rubyforge.org | |
" Anon CVS: See above site | |
" Release Coordinator: Doug Kearns <[email protected]> | |
if exists("current_compiler") | |
finish |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Vim compiler file | |
" Language: Lua assertions | |
if exists("current_compiler") | |
finish | |
endif | |
let current_compiler = "lua_assert" | |
if exists(":CompilerSet") != 2 | |
command -nargs=* CompilerSet setlocal <args> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Thu Dec 9 22:15 2010 Time and Allocation Profiling Report (Final) | |
Main +RTS -p -RTS | |
total time = 1312.56 secs (65628 ticks @ 20 ms) | |
total alloc = 563,371,406,784 bytes (excludes profiling overheads) | |
COST CENTRE MODULE %time %alloc | |
findOffsetIn Cipher 26.9 21.6 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
freqs = Hash.new(0) | |
files = `find . -name "*.java" -print` | |
results = files.split("\n").map do |filename| | |
`git blame #{filename}` | |
end.map do |blame_result| | |
blame_result.split("\n") | |
end.each do |blame_result_array| | |
blame_result_array.map do |blame_line| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
freqs = Hash.new(0) | |
commits = `git log --pretty=oneline --abbrev-commit`.split("\n").map do |line| | |
line.split(" ")[0] | |
end | |
commits.map do |sha| | |
`git show --pretty="format:" --name-only #{sha}` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Any live cell with fewer than two live neighbours dies, as if caused by under-population. | |
#Any live cell with two or three live neighbours lives on to the next generation. | |
#Any live cell with more than three live neighbours dies, as if by overcrowding. | |
#Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction. | |
class Cell | |
attr_accessor :x, :y | |
def initialize(x,y) | |
@x = x | |
@y = y | |
end |