Skip to content

Instantly share code, notes, and snippets.

@ijt
ijt / tailf.hs
Created June 30, 2011 06:26
Haskell example of tailing a file
#!/usr/bin/env runhaskell
-- Example of tailing a file, using two communicating Haskell threads. It's not
-- really necessary to do this concurrently, but the approach here generalizes
-- nicely if we want to filter or transform the output.
import Control.Concurrent
import Control.Monad
import System.Environment
import System.Exit
@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
@todgru
todgru / starttmux.sh
Last active September 26, 2024 04:28
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"
@JalfResi
JalfResi / revprox.go
Last active October 25, 2024 15:41
Simple reverse proxy in Go
package main
import(
"log"
"net/url"
"net/http"
"net/http/httputil"
)
func main() {
@javiercantero
javiercantero / xreadkeys.c
Last active June 24, 2024 16:45
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;
@johnlane
johnlane / dockbar-gtk2.py
Last active August 6, 2024 14:52
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
@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
@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"
--
@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
@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: