Skip to content

Instantly share code, notes, and snippets.

View minhajuddin's full-sized avatar
⌨️
Beep boop, beep boop

Khaja Minhajuddin minhajuddin

⌨️
Beep boop, beep boop
View GitHub Profile
@minhajuddin
minhajuddin / alacritty.yml
Created September 11, 2023 02:53
alacritty.yml
# Configuration for Alacritty, the GPU enhanced terminal emulator.
# Any items in the `env` entry below will be added as
# environment variables. Some entries may override variables
# set by alacritty itself.
env:
TERM: xterm-256color
# # TERM variable
# #
# # This value is used to set the `$TERM` environment variable for
@minhajuddin
minhajuddin / remove_video_controls_on_netflix.js
Created December 8, 2022 20:35
grease monkey script to remove the video controls from netflix
// ==UserScript==
// @name remove the video controls from netflix
// @version 1
// @grant GM_addStyle
// ==/UserScript==
function addGlobalStyle(css) {
var head, style;
head = document.getElementsByTagName('head')[0];
if (!head) { return; }
@minhajuddin
minhajuddin / .curlrc
Created May 20, 2021 12:13
Curl Performance Metrics
--silent
--write-out "@/home/minhajuddin/r/dot3/curl-meta-fmt"
@minhajuddin
minhajuddin / ping_pong.exs
Created March 31, 2021 11:47
A game of ping pong between two Elixir processes
defmodule Player do
def start(p1, p2) do
# start their game p1 sends a ping to p2
send(p2, {:ping, p1})
end
def play do
receive do
{input_message, _from = opponent_pid} ->
respond(opponent_pid, input_message)
@minhajuddin
minhajuddin / README.md
Last active October 28, 2020 19:53
HTTP Connection pooling benchmark

Performance comparison

For a 100 requests.

$ ruby ~/s/bench_connection_pool.rb
       user     system      total        real
without  1.329350   0.059367   1.388717 (  7.018174)
with     0.222370   0.000000   0.222370 (  1.659621)
@minhajuddin
minhajuddin / config_compiler.exs
Last active August 23, 2018 13:47
Compiled configuration
# This is the target module which will be overwritten after dynamic compilation
# You'll be using this to read configuration in your code. For instance, if you
# have a configuration key called `:redis_timeout`, you could read it using
# `MM.Config.get(:redis_timeout)`
defmodule MM.Config do
# we use a default implementation which raises an error when our code tries
# to read configuration before it is compiled.
def get(_key), do: raise("Config has not been compiled yet!")
end
defmodule SearchWorker do
use GenServer
@idle_timeout_ms 10 * 60 * 1000
# client api
def touch(pid) do
GenServer.cast(pid, :touch)
end
defmodule SearchWorker do
use GenServer
@idle_timeout_ms 10 * 60 * 1000
# client api
def touch(pid) do
GenServer.cast(pid, :touch)
end
defmodule SearchWorker do
use GenServer
@idle_timeout_ms 10 * 60 * 1000
@impl GenServer
def init(state) do
# send ourselves a message after 10 seconds and cleanup the proc tree when we get this
Process.send_after(self(), :idle_timeout, @idle_timeout_ms)
{:ok, state}
@minhajuddin
minhajuddin / search_worker1.exs
Created July 18, 2018 12:51
Rolling/Sliding timeouts for Elixir GenServers
defmodule SearchWorker do
use GenServer
@idle_timeout_ms 10 * 60 * 1000
@impl GenServer
def init(state) do
# send ourselves a message after 10 seconds and cleanup the proc tree when we get this
Process.send_after(self(), :idle_timeout, @idle_timeout_ms)
{:ok, state}