Skip to content

Instantly share code, notes, and snippets.

View opyate's full-sized avatar
🐠
Fishing.

Juan M Uys opyate

🐠
Fishing.
View GitHub Profile
for D in $(curl https://www.gov.uk/bank-holidays.json | \
jq '.["england-and-wales"].events[] | .date') ;do \
echo "new DateTime($D)," ; done
# Renders this:
new DateTime("2012-01-02"),
new DateTime("2012-04-06"),
// ... snip
new DateTime("2015-12-28"),
def command(note) do
"play -qn synth 2 pluck #{note}"
end
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
public class CallbackB {
/**
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
(def open-for-business? (atom true))
(def haircut-count (agent 0))
(def waiting-room (ref []))
(def waiting-room-size 3)
(defn open-shop [duration]
(do (Thread/sleep duration) (swap! open-for-business? not)))
(defn add-customers []
(future
@opyate
opyate / hack.js
Last active September 13, 2017 19:33
var contents = '<form action="https://httpbin.org/post" method="POST">';
contents += '<input name="secret" placeholder="Secret stuff here">';
contents += '<input type="submit" onclick="return hack()">';
contents += '<script type="text/javascript">';
contents += 'function hack() { alert("h4x0rz"); }';
contents += '</script>';
contents += '</form>';
document.getElementById('frame1').src = "data:text/html;charset=utf-8," + escape(contents);
@opyate
opyate / Cake.java
Last active December 2, 2015 14:01
model and maximizer
package app;
public class Cake {
private Integer weight;
private Integer value;
public Cake(Integer weight, Integer value) {
this.weight = weight;
this.value = value;
}

Keybase proof

I hereby claim:

  • I am opyate on github.
  • I am uys (https://keybase.io/uys) on keybase.
  • I have a public key whose fingerprint is A1D6 F8E9 BD50 3556 1583 44A4 4F35 6D93 9D11 EBF2

To claim this, I am signing this object:

@opyate
opyate / Makefile
Created September 9, 2017 21:36
Quickly create a new Jekyll site, preview it, and publish it to your chosen cloud.
.PHONY: new pub run
new:
docker run --rm --label=jekyll --volume=$(shell pwd):/srv/jekyll -it -p 127.0.0.1:80:80 jekyll/jekyll:3.5.2 jekyll new thenewshiny
run:
docker run --rm --label=jekyll --volume=$(shell pwd)/thenewshiny:/srv/jekyll -it -p 127.0.0.1:80:4000 jekyll/jekyll:3.5.2 jekyll serve
_pub:
gsutil defacl ch -u AllUsers:R gs://my.website
@opyate
opyate / commit-msg
Created October 10, 2017 09:33
JIRA code commit msg hook; presumes merges happen on remote (via PR mechanism, etc)
#!/bin/sh
# .git/hooks/commit-msg
test "" != "$(egrep '[A-Z]{3,}-\d+' "$1")" || {
echo >&2 Commit message requires JIRA code.
exit 1
}