Skip to content

Instantly share code, notes, and snippets.

View bitops's full-sized avatar

Sebastian Wittenkamp bitops

View GitHub Profile
@bitops
bitops / .rvmrc
Created April 4, 2014 19:12
An example of behavior where the correct ruby info appears not to be loaded.
rvm use --create 1.9.3@foo
which bundle > /dev/null || gem install bundler --no-ri --no-rdoc
bundle check || bundle install
notify () {
~/.rvm/gems/ruby-1.9.3-p484/bin/terminal-notifier -title "$1" -message "$2"
}
@bitops
bitops / active_buffer_colors.el
Created April 29, 2014 23:18
Colors I like to highlight which buffer is currently active.
;; Color configuration
(set-face-attribute 'mode-line
nil
:foreground "light green"
:background "firebrick1"
:box '(:line-width 1 :style released-button))
(set-face-attribute 'mode-line-inactive
nil
:foreground "maroon4"
@bitops
bitops / resque_web.el
Created June 30, 2014 00:17
launch resque-web from emacs
(defun resque-web ()
"Launch resque-web locally on the default port"
(interactive)
(shell-command "open http://0.0.0.0:5678/"))
extension Array {
func each(iterator: (T) -> Void) -> Array {
for item in self {
iterator(item)
}
return self
}
}
@bitops
bitops / array_partition.swift
Last active August 29, 2015 14:03
An example implementation of Ruby's 'partition' method in Swift.
extension Array {
func partition(iterator: (T) -> Bool) -> (Array<T>, Array<T>) {
var ifTrue = Array<T>()
var ifFalse = Array<T>()
self.each {
if iterator($0) == true {
ifTrue.append($0)
} else {
ifFalse.append($0)
}
@bitops
bitops / accumulator.swift
Created July 17, 2014 04:16
An accumulator function written in Swift.
// accumulator function
func accumulator(initial: Int, incrementBy: Int) -> () -> Int {
var value = initial
func accum() -> Int {
value += incrementBy
return value
}
return accum
}
@bitops
bitops / better_yaml.rb
Last active August 29, 2015 14:04
A yaml parser that behaves as you would expect.
require 'yaml'
module BetterYaml
def self.write_yaml_file(file, data)
self.with_syck_engine do
File.open(File.expand_path(file), "w", :encoding => "utf-8") {|f| YAML.dump(data, f) }
end
end
def self.load_yaml_file(file)
@bitops
bitops / Gemfile
Last active August 29, 2015 14:04
docs and stuff
source "http://rubygems.org/"
ruby "2.1.1"
gem 'docx', '~> 0.2.03'
#!/usr/bin/env escript
%% -*- erlang -*-
%%! -smp enable -sname convert_binary_ring -mnesia debug verbose
main([RingFile, OutFile]) ->
try
{ok, Binary} = file:read_file(RingFile),
Ring = binary_to_term(Binary),
try
file:write_file(OutFile, io_lib:format("~p.~n", [Ring])),