Skip to content

Instantly share code, notes, and snippets.

View fhalde's full-sized avatar
💭
¯\_(ツ)_/¯

Faiz Halde fhalde

💭
¯\_(ツ)_/¯
View GitHub Profile
@fhalde
fhalde / simpy.py
Created September 30, 2025 08:31
simpy store
import simpy
env = simpy.Environment()
store = simpy.Store(env)
def consumer():
for i in range(10):
job = store.get()
timer = env.timeout(1, i)
<?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>
@fhalde
fhalde / ideal-stage-time.clj
Last active October 5, 2022 08:09
Longest-processing-time-first scheduling
;; 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))))
@fhalde
fhalde / conway.clj
Last active January 11, 2021 10:48
Conway game of life implementation in clojure
(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))))
// 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);
});
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
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'
@fhalde
fhalde / happy_typing.js
Created August 25, 2015 05:50
When input fields have lost focus, whatever you type is a waste. This simple javascript helps you overcome the problem.
var BACK_SPACE = 8;
var input_buffer = [];
$(window).load(function() {
start();
});
function start() {
$(document).keypress(function(e) {
inputs_focus_free = $(":input:focus").length == 0;