Skip to content

Instantly share code, notes, and snippets.

@maxjacobson
maxjacobson / .vimrc
Last active August 29, 2015 13:56
simple vim configuration file. put this in your home folder
" use syntax highlighting
syntax on
" treat .md files as markdown
filetype on
au BufNewFile,BufRead *.md set filetype=markdown
" smart backspacing and indenting
set backspace=indent,eol,start
filetype plugin indent on
@maxjacobson
maxjacobson / pstore.rb
Last active August 29, 2015 13:57
so PStore (http://ruby-doc.org/stdlib-2.0.0/libdoc/pstore/rdoc/PStore.html) is pretty cool. it comes with ruby. you can run this program repeatedly and it just keeps remembering.
require 'pstore'
store = PStore.new("inputs.pstore")
store.transaction do
inputs = store[:inputs] ||= []
while true do
print "> "
input = gets.chomp
inputs.clear and next if input == "start over"
break if ["exit", "quit", "break"].include? input.strip.downcase
for filename in $(ls app/assets/images); do
echo $filename used `grep -r $filename app | wc -l` times
done

my literate program

This code is going to output hello

console.log "hello world"
var object = {
attributes: {},
get: function(attr) { return this.attributes[attr] },
set: function(attr, value) { this.attributes[attr] = value} }
}
require 'minitest/autorun'
class Array
def my_map
end
end
class Homework < Minitest::Test
def setup
@numbers = [1,2,3]
require 'benchmark'
without_results = Benchmark.measure do
10.times do
sleep 1
end
end
puts "without threads: #{without_results}"
results = Benchmark.measure do
class NoButtonError < Exception; end
class Controller
attr_reader :buttons
def initialize(buttons)
@buttons = {}
buttons.each do |label, bit_number|
@buttons[label] = Button.new(label, bit_number)
end
end
@maxjacobson
maxjacobson / index.html
Created May 29, 2014 02:51
jon gallery exmpl
<!-- 1. Link to jQuery (1.8 or later), -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <!-- 33 KB -->
<!-- fotorama.css & fotorama.js. -->
<link href="http://cdnjs.cloudflare.com/ajax/libs/fotorama/4.5.1/fotorama.css" rel="stylesheet"> <!-- 3 KB -->
<script src="http://cdnjs.cloudflare.com/ajax/libs/fotorama/4.5.1/fotorama.js"></script> <!-- 16 KB -->
<!-- 2. Add images to <div class="fotorama"></div>. -->
<div class="fotorama" data-width="533" data-height="400" data-keyboard="true">
<img src="http://www.jonbleiweis.com/photos2/IMG_4947.JPG" data-caption="Mound visit">
~~Ruby Trivia
~~Question:
What is the highest level in the object model?
~Answer:
`BasicObject`
~~Question:
Is everything in Ruby an object?