Skip to content

Instantly share code, notes, and snippets.

View euank's full-sized avatar

Euan Kemp euank

View GitHub Profile
var fs = require('fs');
try {
fs.readFile('/tmp/kek.not-json', function(err, data) {
JSON.parse(data);/* exception, uncaught */
})
} catch(ex) {
console.log("I don't print. It instead errors out with an exception");
}
@euank
euank / GameTime.rb
Last active August 29, 2015 14:01
Ruby code found in the wild by a friend (distributed by facebook no less. wow). I made it slightly better, but it's still, with no offense to the author, pretty bad code
#Basic Game Time + Night/Day v1.6.2
#----------#
#Features: Provides a series of functions to set and recall current game time
# as well customizable tints based on current game time to give the
# appearance of night and day.
#
#Usage: Script calls:
# GameTime::minute? - returns the current minute
# GameTime::hour? - returns the current hour
# GameTime::set(time) - sets the game time to time, in frames (max:1440)
@euank
euank / RandNum.java
Created June 4, 2014 20:42
Yes it's a joke. Random number generator in java.
import java.net.*;
import java.io.*;
import java.util.*;
class RandNum {
public static void main(String[] args) {
for(int i=0;i<100;i++) {
System.out.println("Your random number is: " + GetRandomNumber(1,2));
}
}
@euank
euank / gist:e80269ed5d5c2eee9c1f
Created December 24, 2014 20:52
keybase proof....
### Keybase proof
I hereby claim:
* I am euank on github.
* I am euank (https://keybase.io/euank) on keybase.
* I have a public key whose fingerprint is B21D B279 98F1 8351 633B 0A07 173E 1948 65D4 40F2
To claim this, I am signing this object:
require 'aws-sdk'
require 'base64'
COREOS_AMI="ami-4b1c763c"
ec2 = Aws::EC2::Client.new(region: 'eu-west-1')
ecs = Aws::ECS::Client.new(region: 'eu-west-1')
NUM_INSTANCES=10
@euank
euank / Dockerfile
Last active March 14, 2023 23:40
ECS / EC2 Metadata entrypoint example
FROM golang:1.4
COPY entrypoint.sh /entrypoint.sh
COPY main.go main.go
RUN go build -o main main.go
RUN chmod +x /entrypoint.sh
EXPOSE 8080
ENTRYPOINT ["/entrypoint.sh"]
CMD ["./main"]
@euank
euank / docker_pull.bt
Created August 24, 2015 16:47
Docker pull deadlock backtrace; v1.6.2
goroutine 0 [idle]:
runtime.futex(0x134f1b8, 0x0, 0x0, 0x0, 0x0, 0x134e400, 0x1, 0x41a0ef, 0x41a30e, 0x134f1b8, ...)
/usr/local/go/src/runtime/sys_linux_amd64.s:277 +0x21
runtime.futexsleep(0x134f1b8, 0xc200000000, 0xffffffffffffffff)
/usr/local/go/src/runtime/os_linux.c:49 +0x47
runtime.notesleep(0x134f1b8)
/usr/local/go/src/runtime/lock_futex.go:145 +0xae
stopm()
/usr/local/go/src/runtime/proc.c:1178 +0x119
exitsyscall0(0xc20837e480)
@euank
euank / docker_pull_v2.bt
Created August 24, 2015 17:07
Docker 1.8.0-dev deadlock in v2 pull / error handling
Containers: 173
Images: 493
Storage Driver: aufs
Root Dir: /var/lib/docker/aufs
Backing Filesystem: extfs
Dirs: 881
Dirperm1 Supported: false
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 3.13.0-48-generic
@euank
euank / docker_create.go
Created August 24, 2015 22:27
A program that calls `docker create` at the given frequency
package main
import (
"flag"
"time"
"github.com/Sirupsen/logrus"
"github.com/fsouza/go-dockerclient"
)
@euank
euank / docker_create_fd.bt
Created August 24, 2015 22:38
Go stackdump of the Docker daemon after getting into a broken state related to FDs
time="2015-08-24T22:34:31.891960861Z" level=info msg="=== BEGIN goroutine stack dump ===
goroutine 10 [running]:
github.com/docker/docker/pkg/signal.DumpStacks()
/root/rpmbuild/BUILD/docker-engine/.gopath/src/github.com/docker/docker/pkg/signal/trap.go:60 +0x7a
github.com/docker/docker/daemon.func·021()
/root/rpmbuild/BUILD/docker-engine/.gopath/src/github.com/docker/docker/daemon/debugtrap.go:18 +0x6d
created by github.com/docker/docker/daemon.setupSigusr1Trap
/root/rpmbuild/BUILD/docker-engine/.gopath/src/github.com/docker/docker/daemon/debugtrap.go:20 +0x18e
goroutine 1 [chan receive, 6017 minutes]: