Skip to content

Instantly share code, notes, and snippets.

@aaronlevin
aaronlevin / minimal-http.hs
Last active June 27, 2017 16:37
Minimal Haskell HTTP server written on top of warp via the Web Application Interface (no frameworks)
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Network.Wai (pathInfo, Request, requestMethod, Response, responseLBS, ResponseReceived)
import Network.Wai.Handler.Warp (run)
import Network.HTTP.Types (status200, status401)
-- note: type Application = Request -> (Response -> IO ResponseReceived) -> IO ResponseReceived
application :: Request -> (Response -> IO ResponseReceived) -> IO ResponseReceived
@mgmeier
mgmeier / RingBuffer.hs
Created April 28, 2016 15:09
Ring buffer in Haskell
{-# LANGUAGE BangPatterns #-}
{-
Scenario / preconditions for the usefulness of this ring buffer:
- mutable data structure
- elements of the same size (here: ByteString, extending to values of class Storable should be trivial)
- each element is denoted by a continuous Int id
- main benefit, esp. for a large number of elements:
@VovanR
VovanR / .Xresources
Created October 29, 2015 14:17
Atom One Light color theme for xterm and urxvt
! Atom One Light theme
xterm*background: #f9f9f9
xterm*foreground: #383a42
xterm*cursorColor: #d0d0d0
xterm*color0: #000000
xterm*color1: #E45649
xterm*color2: #50A14F
xterm*color3: #986801
xterm*color4: #4078F2
xterm*color5: #A626A4
@chrisdone
chrisdone / HoleyMonoid.hs
Last active November 7, 2015 10:51
HoleyMonoid monoid!
{-# LANGUAGE FlexibleInstances #-}
-- | Monoids with holes. The 'HoleyMonoid' allows building monoidal values of which certain components are to be filled in later. For example:
--
-- > > let holey = now "x = "
-- > . later show
-- > . now ", y = "
-- > . later show
-- > > run holey 3 5
-- > "x = 3, y = 5"
--
@gmas
gmas / gist:b5fd3d038905d1265485
Created December 25, 2014 22:38
switch gcc versions in debian
#install new versions of gcc and g++
sudo apt-get install gcc-4.8 g++-4.8
#remove existing alternatives
sudo update-alternatives --remove-all gcc
sudo update-alternatives --remove-all g++
#add new and old version to update-alternatives db
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.6
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 40 --slave /usr/bin/g++ g++ /usr/bin/g++-4.8
@johnlane
johnlane / dockbar-gtk2.py
Last active October 24, 2023 21:43
Example GTK to create a dock-like bar and strut
#!/usr/bin/env python2
#
# dockbar.py
#
# Example program places a coloured bar across the top of the
# current monitor
#
# demonstrates
#
# (a) creating the bar as an undecorated "dock" window
@javiercantero
javiercantero / xreadkeys.c
Last active December 4, 2023 19:04
A X11/Xlib program that reads the KeyPress and KeyRelease events from the window and prints them to the standard output. Used to debug the keyboard within X.
#include <X11/Xlib.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
Display *display;
Window window;
XEvent event;
int s;
@JalfResi
JalfResi / revprox.go
Last active May 18, 2024 00:23
Simple reverse proxy in Go
package main
import(
"log"
"net/url"
"net/http"
"net/http/httputil"
)
func main() {
@todgru
todgru / starttmux.sh
Last active April 27, 2024 18:17
Start up tmux with custom windows, panes and applications running
#!/bin/sh
#
# Setup a work space called `work` with two windows
# first window has 3 panes.
# The first pane set at 65%, split horizontally, set to api root and running vim
# pane 2 is split at 25% and running redis-server
# pane 3 is set to api root and bash prompt.
# note: `api` aliased to `cd ~/path/to/work`
#
session="work"
@areina
areina / emacs-email-setup.md
Created October 12, 2012 15:00
Manage your email in emacs with mu4e

Manage your gmail account in emacs with mu4e

There're a lot of combinations to manage your email with emacs, but this works for me. I've a backup and I can manage my daily email.

The stack:

  • emacs
  • offlineimap
  • mu
  • mu4e