This file contains 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
var dataURL = this.canvas.toDataURL(this.getImageType()); // grab the snapshot as base64 | |
var imgData = atob(dataURL.substring(13 + this.getImageType().length)); // convert to binary | |
var filenameTimestamp = (new Date().getTime()); | |
var separator = "----------12345-multipart-boundary-" + filenameTimestamp; | |
// Javascript munges binary data when it undergoes string operations (such as concatenation), so we need | |
// to jump through a bunch of hoops with streams to make sure that doesn't happen | |
// create a string input stream with the form preamble |
This file contains 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
#!/bin/bash | |
# "@Pad" | |
# An easy commandline time-stamped log/notepad | |
# Derived from https://web.archive.org/web/20120118122636/http://blog.rubybestpractices.com/posts/jamesbritt/James_will_be_right_back_after_these_interruptions.html | |
# | |
# Usage: | |
# @ something or other - log the timestamped message "something or other" | |
# @ . - open the @ scratchpad with a new timestamp and | |
# no message with your default editor |
This file contains 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
Show hidden characters
{ "keys": ["super+f4"], "command": "public_gist_from_selection" } |
This file contains 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
val ranges = List((2,3), (1,2), (5,11), (4,10), (3,3), (6,7), (15,16)) | |
ranges.sorted.foldLeft(List[(Int, Int)]()) { (acc, t) => | |
acc match { | |
case x :: xs if x._2 >= t._1 => (x._1, math.max(x._2, t._2)) :: xs | |
case x :: xs => t +: acc | |
case _ => List(t) | |
} | |
}.reverse |
This file contains 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
# logtail from logcheck (http://logcheck.org/) | |
*/15 * * * * /usr/sbin/logtail /path/to/some/log/file.log | egrep "WARN|ERROR|Exception" | head |
This file contains 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
# sieve of eratosthenes | |
def sieve(s: Stream[Int]): Stream[Int] = s.head #:: sieve(s.tail filter (_ % s.head != 0)) | |
def from(n: Int): Stream[Int] = n #:: from(n + 1) | |
def primes = sieve(from(2)) |
This file contains 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
#!/bin/bash | |
# <udf name="hostname" label="Hostname"> | |
# <udf name="ssh_key" label="SSH Key"> | |
# <udf name="ubuntu_mirror" label="Ubuntu Mirror URL" default="http://us.archive.ubuntu.com/ubuntu"> | |
# <udf name="distro" label="Ubuntu Distro" default="maverick"> | |
# <udf name="default_ruby_interpreter" label="Default Ruby Interpreter" | |
# oneOf="ruby-1.8.6,ruby-1.8.7,ruby-1.9.1,ruby-1.9.2,ruby-head" | |
# default="ruby-1.9.2"> |
This file contains 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
/* Put this in ~/Library/KeyBindings/DefaultKeyBinding.dict */ | |
/* Based on a file from @eventualbuddha */ | |
{ | |
/* Modifier keys: start with C-m */ | |
"^m" = { | |
"^ " = ("insertText:", "\U2423"); /* C-space space */ | |
"^e" = ("insertText:", "\U21A9"); /* C-e return */ | |
"e" = ("insertText:", "\U2305"); /* e enter */ |
This file contains 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
$ egrep -i "[bcdfghjklmnpqrstvwxz]{6,}" /usr/share/dict/words | |
archchronicler | |
bergschrund | |
Eschscholtzia | |
fruchtschiefer | |
latchstring | |
lengthsman | |
Nachschlag | |
postphthisic | |
veldtschoen |
This file contains 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
class VersionString < String | |
def <=>(other) | |
my_parts = self.split('.').map(&:to_i) | |
other_parts = other.split('.').map(&:to_i) | |
my_parts.each_with_index do |part, i| | |
break if i >= other_parts.length | |
next if part == other_parts[i] | |
return part <=> other_parts[i] | |
end | |
if my_parts.length > other_parts.length |