Skip to content

Instantly share code, notes, and snippets.

View karimamer's full-sized avatar

karim amer karimamer

View GitHub Profile
{{ range $host, $containers := groupBy $ "Env.VIRTUAL_HOST" }}
upstream {{ $host }} {
{{ range $index, $value := $containers }}
{{ with $address := index $value.Addresses 0 }}
server {{ .Network.IP }}:{{.Address.Port}};
{{ end }}
{{ end }}
}
@karimamer
karimamer / configuration.nix
Created October 25, 2017 18:47 — forked from RobBlackwell/configuration.nix
NixOS on Dell XPS 13
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).
{ config, pkgs, ... }:
{
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix

Keybase proof

I hereby claim:

  • I am karimamer on github.
  • I am karimamer (https://keybase.io/karimamer) on keybase.
  • I have a public key whose fingerprint is C9D0 1D37 FB79 368A BC4D 33A0 D3DE 4A05 D1EA 750B

To claim this, I am signing this object:

from heapq import heappush, heappop, heapify
from collections import defaultdict
def encode(symb2freq):
heap = [[wt, [sym, ""]] for sym, wt in symb2freq.items()]
heapify(heap)
while len(heap) > 1:
lo = heappop(heap)
hi = heappop(heap)
@karimamer
karimamer / cv.py
Last active December 30, 2015 19:29
#!/usr/bin/env python2
#-*- coding: utf-8 -*-
import cv
import datetime
import optparse
import os
import os.path
import time
def MSort(k:List[Int]): List[Int]={
val x = k.length / 2
if (x == 0) k
else {
def merge( k:List[Int], o:List[Int]):List[Int] = (k ,o) match {
case (Nil , o ) => o
case(k , Nil) => k
case(n ::ks , y :: os) => if (x > y) n :: merge(k ,os) else y :: merge(o,ks)
}
val (mka , kka) = k splitAt x
@karimamer
karimamer / gist:5518198
Created May 4, 2013 17:43
insertion sort
def Isort(x:List[Int]):List[Int]= x match {
case List() => List()
case y :: ys => insert (y , Isort(ys))
}
def insert(x:Int , xs:List[Int]):List[Int] = xs match {
case List() => List(x)
case y :: ys => if (x >= y) x :: xs else y :: insert(x , ys )
}