Skip to content

Instantly share code, notes, and snippets.

@semperos
semperos / eotw-may-28.clj
Created May 28, 2013 16:13
Favorite error output so far this week.
((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
@semperos
semperos / cowthink-bashrc.bash
Created January 31, 2013 01:51
Cowthink for ~/.bashrc
###
# Because it's fun
###
RANGE=54
number=$RANDOM
let "number %= $RANGE"
case $number in
0)
cow="apt"
@semperos
semperos / jquery-timepicker-patched.js
Created January 2, 2013 19:41
jQuery Timepicker defensive tweak
tp_inst.amNames = $.map(tp_inst._defaults.amNames, function(val) { if ($.type(val) === "string") { return val.toUpperCase(); } });
tp_inst.pmNames = $.map(tp_inst._defaults.pmNames, function(val) { if ($.type(val) === "string") { return val.toUpperCase(); } });
@semperos
semperos / string-util.js
Created December 28, 2012 14:21
TypeScript with "--module amd"
define(["require", "exports"], function(require, exports) {
var StringUtil = (function () {
function StringUtil() { }
StringUtil.truncate = function truncate(str, limit) {
if(str.length > limit) {
var r;
var ret;
r = new RegExp("^.{0," + limit + "}\\b");
ret = r.exec(str)[0];
@semperos
semperos / ristretto-modified.js
Created December 27, 2012 21:51
Ristretto.js - modified with more detailed error messages and a few other tweaks
/*
Copyright 2012 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@semperos
semperos / mimosa-git-rebase-stack.txt
Created December 14, 2012 15:21
Mimosa stacktrace when doing "git rebase"
/Users/semperos/opt/nvm/v0.8.7/lib/node_modules/mimosa/lib/util/file.coffee:82
if (stats1.mtime > stats2.mtime) {
^
TypeError: Cannot read property 'mtime' of undefined
at FileUtils.isFirstFileNewer (/Users/semperos/opt/nvm/v0.8.7/lib/node_modules/mimosa/lib/util/file.coffee:82:23)
at Object.oncomplete (fs.js:297:15)
npm ERR! package-name@0.0.1 start: `mimosa watch --server`
npm ERR! `sh "-c" "mimosa watch --server"` failed with 1
npm ERR!
npm ERR! Failed at the package-name@0.0.1 start script.
@semperos
semperos / optional-types.coffee
Created December 11, 2012 22:19
Optional type checking (runtime contracts) in CoffeeScript via Ristretto (modified)
# Define your class
class Foo
add: (a, b) ->
a + b
@upper: (s) ->
s.toUpperCase()
class Bar
multiply: (a, b) ->
a * b
@semperos
semperos / button.txt
Created November 29, 2012 18:14
Lynx button
............. .... .. .. ...... .... ... ........ ..
...... .............
. .... ..... .
.. ......... .. . ... ..
. . . ... .. .. ....
. .. .. .. .. ..
. . . .. .. .
. . .. .. . ..
. . .. .. .. .
.. .. . ........ .
@semperos
semperos / create-on-auto.coffee
Created October 31, 2012 01:43
Create on autocomplete click
@model.get('fooCollection').create({
unit:
title: ui.item.label
url: ui.item.url
})
@semperos
semperos / temp.clj
Created October 10, 2012 21:37
Temp
;; Functional programming
(is (= "Item 'Foo' deleted successfully"
(text "div.message")))
(is (some #{"Item 'Foo' deleted successfully"}
(apply text (elements "div.message"))))
(is (= (count (elements "div.message")) 1))
;; Logic programming
(s (run* [q]