Skip to content

Instantly share code, notes, and snippets.

@jackwillis
jackwillis / concurrent-mini-rake.rb
Last active June 2, 2017 05:34
Concurrent mini-Rake
require 'concurrent'
TASKS = Concurrent::Map.new
class Task
def initialize(ref, dep_refs = [], &action)
@ref = ref
@dep_refs = dep_refs
@promise = Concurrent::Promise.new(&action)
end

Keybase proof

I hereby claim:

  • I am jackwillis on github.
  • I am jackie (https://keybase.io/jackie) on keybase.
  • I have a public key whose fingerprint is 21BA 259F D30B 002B BABD 1195 57A5 8973 A025 781C

To claim this, I am signing this object:

@jackwillis
jackwillis / redirect.html
Last active August 29, 2015 14:23
redirect.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Time-based Redirect</title>
<script>
var pageTimes = [
{ begin: "7:30 AM", end: "8:00 AM", href: "http://dfgsdfs" },
{ begin: "8:00 AM", end: "12:00 PM", href: "http://tdddfgdfgdfgs" },
# Better Kernel::system in Ruby
def sys(cmd)
*resp, status = `#{cmd}; echo -n "\n$?"`.lines
[resp.join.chomp, status.to_i]
end
sys("echo foo") #=> ["foo\n", 0]
sys("echo -n foo") #=> ["foo", 0]
sys("false") #=> ["", 1]
@jackwillis
jackwillis / list_compr.rb
Last active August 29, 2015 14:22
List comprehension look-alike in Ruby
class Hash
# http://stackoverflow.com/a/14881438/3551701
def product
product = values[0].product(*values[1..-1])
product.map {|p| Hash[keys.zip(p)] }
end
end
class Proc
@jackwillis
jackwillis / play_radio
Created July 16, 2014 00:32
Streaming RTL-SDR over a network
#!/bin/sh
play -r 32k -t raw -e s -b 16 -c 1 -V1 -