Skip to content

Instantly share code, notes, and snippets.

@leroux
leroux / kiyoura.c
Created August 16, 2012 20:57
Kiyoura's Reverse String Challenge Solution
#include <stdio.h>
int main (void) {
char str[] = "password";
int i = 0;
/* for pointer arithmetic */
char *ptr = str;
while (*ptr && (*ptr += (i++)))
ptr++;
printf("%s\n", str);
@leroux
leroux / reverseme.c
Created August 18, 2012 01:59
Reverse str back to 'password'.
#include <stdio.h>
int main (void) {
char str[] = "password";
int i = 0;
/* for pointer arithmetic */
char *ptr = str;
while (*ptr && (*ptr += (i++)))
ptr++;
printf("%s\n", str);
@leroux
leroux / Chain.hs
Last active December 19, 2015 17:08
Haskell Chain
module Chain where
infixl 2 .>
infixr 1 .>>
{-| Chain operator.
Chain functions in a do-like (monadic bind)-like style.
`f .> g` will return a function that will apply f, then apply g.
It can be alternatively be defined as: `f .> g = g . f` which is just
`flip (.)`.
module Queue where
data Queue a = Queue [a] [a]
deriving (Show, Eq)
emptyQueue :: Queue a
emptyQueue = Queue [] []
push :: a -> Queue a -> Queue a
push x (Queue d e) = Queue d (x:e)

Mailman Chaos

Injection Fix

./inject-newer-mail.sh <bin/inject> <old-mbox> <new-mbox> <listname> # (new-mbox) // (old-mbox) is injected into archive queue.
bin/qrunner -v -r ARch # start Archive queue runner (Processes the archive queue).
  • Logs: error, smtp, fail, and vette.
@leroux
leroux / ADTAlgebra.hs
Last active December 28, 2015 09:29
ADT Algebra
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE TypeOperators #-}
module ADTAlgebra where
type Algebra f a = f a -> a
type Coalgebra f a = a -> f a
type Bialgebra f a = (Algebra f a, Coalgebra f a)
#!/bin/bash -xe
SYSTEM=$(uname)
case $SYSTEM in
Darwin)
export PUBLIC=/data/Home/Dropbox/ghc
;;
Linux)
export PUBLIC=/srv/dropbox/ghc
;;
{
"add_to_PATH":
[
"/usr/local/bin/",
"~/.cabal/bin"
],
"auto_build_mode": "normal",
"enable_auto_build": false,
"enable_auto_lint": true,
"enable_ghc_mod": true,
@leroux
leroux / scrape-worm-separate.py
Last active January 1, 2016 02:29
Hacky Worm Scraper
# Worm Scraper by Arc
# Use pandoc to convert into something nicer.
import re
from bs4 import BeautifulSoup
from urllib2 import urlopen
url = "http://parahumans.wordpress.com/category/stories-arcs-1-10/arc-1-gestation/1-01/"