View dedupe-nested-lists.hs
-- [[1,2],[2,3],[4,5]] becomes [[1,2],[3],[4,5]]
-- this file can be run using: `stack runghc dedupe-nested-lists.hs`
dedupe_against_self =
(\member memo ->
if (any (== member) memo)
then memo
else member : memo)
View rewind-string-pointer.c
// run with: `gcc main.c -include stdio.h && ./a.out`
int main() {
char *foo = "foo";
char *bar = foo;
char *begin = bar;
while (*bar++) {}
bar = begin;
printf("%s\n", bar); // foo
return 0;




I stayed in Bondi Junction (where Eddie was living at the time), which is a ways out from the hustle-and-bustle downtown. There are great views of the opera house, Sydney Harbor Bridge and Bondi Beach is within walking distance.

Bondi Beach is a renowned surf spot and, in addition to beach activities, there are lots of nice cliffs to hike around on on the far-side of the beach.

View haml-inline-partial-helper.rb
- delete_button = haml_tag :a,
class: "close story-item-image-delete",
href: "javascript: void(0);",
tabindex: "-1",
title: "delete image" do
View code-world-example.hs
{-# LANGUAGE OverloadedStrings #-}
import CodeWorld
main = do
let animFunc = (\x -> rotated x $ rectangle (x * x) (x * 3))
expand = (\x y -> x + y)
contract = (\x y -> x - y)
step = (\x y -> if y > 4 then (contract x y) else (expand x y))
View print_words.c
void print_words(char **words) {
for (; *words; words++) {
char *word = *words;
while (*word) {
View demo.c
#include <stdio.h>
typedef void (*thing_sayer)(char *person);
void say_hello(char *person) {
printf("Hello, %s!\n", person);
void say_goodbye(char *person) {
printf("Goodbye, %s!\n", person);

Every so often I have to restore my gpg keys and I'm never sure how best to do it. So, I've spent some time playing around with the various ways to export/import (backup/restore) keys.

Method 1

Backup the public and secret keyrings and trust database

cp ~/.gnupg/pubring.gpg /path/to/backups/
cp ~/.gnupg/secring.gpg /path/to/backups/
cp ~/.gnupg/trustdb.gpg /path/to/backups/
# or, instead of backing up trustdb...
View devise_random_password_generator.rb
module Devise
def self.generate_password
SecureRandom.hex(1).upcase << SecureRandom.hex(DEVISE_PASSWORD_MIN)
View gist:c01fb211a03e35121f908183eccbc071
ls *1600x900_scrot.png | xargs -P 5 -I img pngcrush -brute img 1600x900/img