This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import simpy | |
env = simpy.Environment() | |
store = simpy.Store(env) | |
def consumer(): | |
for i in range(10): | |
job = store.get() | |
timer = env.timeout(1, i) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<allocations> | |
<pool name="1"> | |
<schedulingMode>FAIR</schedulingMode> | |
<weight>0</weight> | |
<minShare>1</minShare> | |
</pool> | |
<pool name="2"> | |
<schedulingMode>FAIR</schedulingMode> | |
<weight>0</weight> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; https://en.wikipedia.org/wiki/Greedy_number_partitioning | |
(defn ideal-stage-time | |
[task-exec-times cores] | |
(let [m-heap (java.util.PriorityQueue. (repeat cores 0))] | |
(doseq [t (sort > task-exec-times)] | |
(->> (.poll m-heap) | |
(+ t) | |
(.add m-heap))) | |
(apply max (.toArray m-heap)))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns convoy.core | |
(:require [clojure.set :as cset])) | |
(def ^:dynamic *universe* nil) | |
(def addv #(map + %1 %2)) | |
(def deltas [[-1 -1] [-1 0] [-1 1] [0 -1] [0 1] [1 -1] [1 0] [1 1]]) | |
(defn neighbours | |
[cell] | |
(set (map addv deltas (repeat cell)))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// frustrated with too many requires when I perform shell> top index.js | |
shawarma_require("http", "fs", "path", function(http, fs, path) { | |
http.createServer(function(req, res) { | |
res.writeHeader(200, {"Content-Type": "text/html"}); | |
res.write("Hello world"); | |
res.end(); | |
}).listen(8080); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "Killing process with name $1" | |
kill -9 `ps | sed -n -e "/$1/{p;q}" | awk '{print $1}'` | |
# now you can kill a process using its name. e.g. cat &; nkill cat |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sed -n -e 's/$*public \(.*\) \(.*\)(.*).*{/\2/p' < source | sed -e 's/^[ \t]*//g' | sed -n -e 's/\(.*\)/@Test\npublic void test\1\(\) \{\n\n\}\n/p' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var BACK_SPACE = 8; | |
var input_buffer = []; | |
$(window).load(function() { | |
start(); | |
}); | |
function start() { | |
$(document).keypress(function(e) { | |
inputs_focus_free = $(":input:focus").length == 0; |