Skip to content

Instantly share code, notes, and snippets.

View wjessop's full-sized avatar
🤖

Will Jessop wjessop

🤖
View GitHub Profile
func (r *repo_handle) get_tar_file() (string, error) {
target_dir, tmpdir_err := ioutil.TempDir("", "captain_app_tar")
log.Println("Got temp directory for app tar", target_dir)
if tmpdir_err != nil {
return "", tmpdir_err
}
archive_path := target_dir + "/" + "app.tar"
log.Println("Going to create the tar archive at path", archive_path)
[sc-chi] root@proxy-02:~# docker insert slsdhf app.tar /tmp/app.tar
[sc-chi] root@proxy-02:~# echo $?
0
require 'minitest/autorun'
class TestWords < Minitest::Test
def test_that_similar_words_are_found
assert_equal one_off_words("moor", ["door", "moot", "boot", "boots"]), ["door", "moot"]
end
def test_fake_failure
assert_equal one_off_words("moor", ["door", "moot", "boot", "boots"]), ["door", "moot", "fuckers"]
end
class Array
def xor(key)
a = dup
a.length.times { |n| a[n] ^= key[n % key.size] }
a
end
end
stra = "123abc"
strb = "123adc"
package main
import (
"github.com/wjessop/go-piglow"
"log"
)
func main() {
var p *piglow.Piglow
var err error
require 'thread'
LAST_VAL = 8
q = Queue.new
(0..LAST_VAL).to_a.shuffle.each {|i| q << i}
vals = []
next_val = 0
loop do
puts "popping the stack"
@wjessop
wjessop / api.rb
Last active December 20, 2015 04:39
I need a "rolling timeout" for some code. If something doesn't happen for x seconds, timeout, but if it does, reset the timer. The Ruby Timeout module doesn't help with this, it provides only a static timeout.
# The API I thought up, This example will
# sleep for 16 seconds (4 * 4 seconds + 5 seconds)
begin
RollingTimeout.new(5) {|timer|
sleep(4)
timer.reset
sleep(4)
timer.reset
sleep(4)
package backup_downloader
import (
"bytes"
"io"
"log"
"os"
"os/exec"
"sync"
)
@wjessop
wjessop / gist:4996860
Created February 20, 2013 16:33
sendcat output
[1.9.3] ~ $ cd Desktop/Funny\ pictures/
[1.9.3] ~/Desktop/Funny pictures $ sendcat *
https://sendc.at/dl/3kqUAI5QGty5uCzqHVbIiCJGZDoULqrSsINOJTAgIEfJBnEHsr62Pel
105.gif was already uploaded, skipping
1265713754_fl: 100% |========================| 469.1KB 108.8KB/s ETA: 00:00:00
1324316240_ca: 100% |========================| 3.4MB 121.8KB/s ETA: 00:00:00
1RyYE.gif was already uploaded, skipping
1rSzCqgzWn8kh: 100% |========================| 1.9MB 117.7KB/s ETA: 00:00:00
1vlzxNk.jpeg: 100% |========================| 226.0KB 101.5KB/s ETA: 00:00:00
292920_10150689018263944_156425228943_9541657_455613102_n.jpg was already uploaded, skipping
@wjessop
wjessop / gist:4747914
Created February 10, 2013 01:30
BERT decoded
magic| tuple | atom | bert | | dict | list 1 elem | list | atom | key | atom | | val | nil | nil
131, 104, 3, 100, 0, 4, 98, 101, 114, 116, 100, 0, 4, 100, 105, 99, 116, 108, 0, 0, 0, 1, 108, 0, 0, 0, 2, 100, 0, 3, 107, 101, 121, 100, 0, 3, 118, 97, 108, 106, 106