Skip to content

Instantly share code, notes, and snippets.

View sukima's full-sized avatar

Devin Weaver sukima

View GitHub Profile
@darcyparker
darcyparker / vimModeStateDiagram.svg
Last active September 30, 2024 12:33
Vim Modes Transition Diagram in SVG https://rawgithub.com/darcyparker/1886716/raw/eab57dfe784f016085251771d65a75a471ca22d4/vimModeStateDiagram.svg Note, most of the nodes in this graph have clickable hyperlinks to documentation.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@andyhd
andyhd / maybe-monad.js
Created January 16, 2012 01:02
Maybe monad in Javascript
function maybe(value) {
var obj = null;
function isEmpty() { return value === undefined || value === null }
function nonEmpty() { return !isEmpty() }
obj = {
map: function (f) { return isEmpty() ? obj : maybe(f(value)) },
getOrElse: function (n) { return isEmpty() ? n : value },
isEmpty: isEmpty,
nonEmpty: nonEmpty
}
@nowelium
nowelium / latch.js
Created January 13, 2012 03:05
CountdownLatch
var CountdownLatch = function (limit){
this.limit = limit;
this.count = 0;
this.waitBlock = function (){};
};
CountdownLatch.prototype.countDown = function (){
this.count = this.count + 1;
if(this.limit <= this.count){
return this.waitBlock();
}
@almost
almost / models.coffee
Created November 26, 2011 20:02
The beginnings of a declarative model syntax for CoffeeScript.
# The beginnings of a declarative model syntax for CoffeeScript.
# SEE: http://almostobsolete.net/declarative-models-in-coffeescript.html
# Thomas Parslow
# Email: [email protected]
# Twitter: @almostobsolete
# The top part is the setup, see below that for the demo
# To see this run right away try copy pasting it into the 'Try
# CoffeeScript' box at http://jashkenas.github.com/coffee-script/
@sukima
sukima / Rakefile
Created August 14, 2011 15:42
Sample Rakefile for Jekyll
require "rake/clean"
DEVELOPMENT_URI = "$HOME/Sites/test_site"
PRODUCTION_URI = "[email protected]:path/to/public_html"
CLEAN.include "_site"
CLOBBER.include "_includes/*.html_frag"
def jekyll(opts = "", path = "")
sh "rm -rf _site"
@sukima
sukima / HowToReproduce.md
Created January 19, 2011 22:26
Rails test routing bug

Using RAILS 2.3.5

$ rails foobar
$ cd foobar
$ script/generate controller SpecialEvents

Add/edit the following files to those in this gist.

$ rake db:migrate

$ rake test

@guybrush
guybrush / pandoc.css
Created October 18, 2010 05:42
pandoc.css
body {
font: Arial;
/*
font: 18px/27px 'YanoneKaffeesatzRegular', Arial, sans-serif;
font-family:"Myriad Pro",georgia, helvetica, arial, sans serif;
*/
font-size:larger;
background:black; color:white; margin-left:300px; width:500px; padding:20px}
a {color:yellow; background:black;}
a:hover {color:black; background:yellow;}
@sukima
sukima / logged_in_as.rb
Created September 30, 2010 17:55
Using a custom shoulda macro for authlogic
# Sets the current person in the session from the person fixtures.
def logged_in_as(person, &block)
context "logged in as #{person}" do
setup do
@instructor = Factory(instructor) if instructor.is_a? Symbol
InstructorSession.create(instructor)
end
merge_block(&block)
end
#!/bin/bash
# SPDX-License-Identifier: MIT
## Copyright (C) 2009 Przemyslaw Pawelczyk <[email protected]>
##
## This script is licensed under the terms of the MIT license.
## https://opensource.org/licenses/MIT
#
# Lockable script boilerplate
@sukima
sukima / application.js
Created August 6, 2010 23:36
jQuery datepicker with formtastic and rails
/**
* Shamlessly copied from http://snipt.net/boriscy/datetime-jquery-formtastic/
*
* This did not function with formtastic version 0.9.10
* I had to move the live("change") event below the initializing part
* I also had to adjust the jQuery selections as formtastic uses <ol>'s to
* seperate every select box.
*/
$(document).ready(function() {