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 / nginx_setup.sh
Created March 7, 2011 07:27
nginx setup stuff
#create sites-enabled directory to hold config symlinks
sudo mkdir -p /etc/nginx/sites-enabled
#symlink the webapps directory to /var/www/apps
sudo mkdir -p /var/www
sudo ln -ns /home/minhajuddin/webapps /var/www/apps
#symlink an nginx config file to a webapps config file
sudo ln -ns /var/www/apps/ramanujan/config/nginx.conf /etc/nginx/sites-enabled/ramanujan.conf
#hookup /etc/init.d/nginx to auto-start at startup
/usr/sbin/update-rc.d -f nginx defaults
@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
@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}
import XMonad
main = do
xmonad $ defaultConfig
{ terminal = myTerminal
, modMask = myModMask
, borderWidth = myBorderWidth
}
myTerminal = "urxvt"
@minhajuddin
minhajuddin / post-receive-hook.rb
Created December 10, 2010 09:48
Post receive hook for git syncing
#!/usr/bin/env ruby
class Sync
def initialize(gitpart)
@from, @to, @ref = gitpart.split
@branch = @ref.split('/').last
end
def exec
@minhajuddin
minhajuddin / curl-websocket.sh
Created March 2, 2018 06:22 — forked from htp/curl-websocket.sh
Test a WebSocket using curl.
curl --include \
--no-buffer \
--header "Connection: Upgrade" \
--header "Upgrade: websocket" \
--header "Host: example.com:80" \
--header "Origin: http://example.com:80" \
--header "Sec-WebSocket-Key: SGVsbG8sIHdvcmxkIQ==" \
--header "Sec-WebSocket-Version: 13" \
http://example.com:80/
@minhajuddin
minhajuddin / ticker.ex
Created November 29, 2016 13:32
A simple GenServer to do some work every few seconds
# Ticker
defmodule Ticker do
use GenServer
def start_link(%{module: module, function: function, interval: interval} = state)
when is_atom(module) and is_atom(function) and is_integer(interval) and interval > 0 do
GenServer.start_link(__MODULE__, state)
end
def init(state) do

Effective Engineer - Notes

What's an Effective Engineer?

  • They are the people who get things done. Effective Engineers produce results.

Adopt the Right Mindsets