Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
# Packaged as a gem, too.
# gem install fizx-remind
system *ARGV
status = $?
system "growlnotify", "-m", "#{ARGV.first} is finished", "remind"
exit status.to_i
@fizx
fizx / gist:4617660
Created January 24, 2013 04:34
Lamport talk
Who builds a house without drawing blueprints?
Leslie Lamport, Yammer, Jan 23 2013
Architects plan--programmers don't. Maybe this is why programs crash and houses don't.
A blueprint for software is a spec. Not a formal Coq-provable one, but real-world one.
Why don't programmers write specs?
You can't code-gen from spec (retort--can't building-gen from blueprints)
#!/bin/sh
# clear old pipe and lock
rmdir worklock 2>/dev/null
rm work
if [[ ! -p work ]]; then
mkfifo work
else
dd if=work of=/dev/null
@fizx
fizx / foo.txt
Last active December 31, 2015 13:39
We couldn’t find that file to show.
@fizx
fizx / redis.go
Last active December 17, 2015 13:29
package main
/**
* This is a little too permissive (and hacked together), but it illustrates
* the point of encoding a bufio.Scanner that is stateful, so that it can
* parse the redis protocol.
*/
import (
"bufio"
@fizx
fizx / leaktest2.go
Last active December 16, 2015 00:29
package main
func main() {
buf := make([]int, 0)
buf = append(buf, 0, 1, 2, 3)
sub := buf[0:2] //hang on to a reference of the beginning of the vector
for {
for i := 0; i < 1000; i++ {
buf = append(buf, i)
}
package main
func main() {
buf := make([]int, 0)
for {
for i := 0; i < 1000; i++ {
buf = append(buf, i)
}
buf = buf[999:1000]
}
require 'socket'
server = TCPServer.new ENV["PORT"]
loop do
client = server.accept
client.puts "Hello !"
client.puts "Time is #{Time.now}"
client.close
end
@fizx
fizx / next_task.rb
Last active December 12, 2015 07:28
#!/usr/bin/env ruby
require "open-uri"
require "rubygems"
require "json"
unless ENV["ASANA_API_KEY"]
puts "please set ASANA_API_KEY in the env"
exit 1
end
module Kernel
def eventually(timeout = 1.0, start = Time.now, exception = nil, &block)
throw exception || Timeout::Error if Time.now > (start + timeout)
begin
return true if block.call
rescue RSpec::Expectations::ExpectationNotMetError => exception
EM.next_tick {
eventually(timeout, start, exception, &block)
}
end