Skip to content

Instantly share code, notes, and snippets.

{-# LANGUAGE OverloadedStrings #-}
module Text.Digestive.Larceny where
import Control.Monad.State (evalStateT, get)
import Control.Monad.Trans (liftIO)
import qualified Data.Map as M
import Data.Maybe (fromMaybe)
import Data.Monoid ((<>))
import Data.Text (Text)
@emhoracek
emhoracek / catdb.py
Created June 7, 2016 02:01
sqlite3 + json
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sqlite3 as lite
import sys
import json
from pprint import pprint
with open('cats.json') as data_file:
@emhoracek
emhoracek / metropolitan.pas
Created May 14, 2016 13:38
The murder at the Metropolitan Club
program METROPOLITANCLUB (output);
{ -- This programme examines the clues given for the murder at
-- the Metropolitan Club. The three arrays HAIR, ATTIRE, and
-- ROOM are used to establish the facts as they are determined.
-- The programme outputs the name of the murderer. }
const
UNKNOWN = 0;
RED = 1; BLACK = 2; GREY = 3; BROWN = 4;
-- Like nfa.py
-- E.g.: (lit 'a' . many (lit 'b' `alt` lit 'c') . lit 'd') `matches` "abbcd"
-- Thanks to Mike Vanier for some Haskelly tips.
import Data.Array (Array)
import qualified Data.Array as A
import Data.List (nub)
import Data.Monoid ((<>))
import Test.Hspec hiding (after)
var excerpts=document.getElementsByClassName('excerpt-container');
var ellipsisify = function() {
for (var i=0; i < excerpts.length; i++) {
var p=$(excerpts[i]).find('p');
var divh=$(excerpts[i]).height();
while ($(p).outerHeight()>divh) {
$(p).text(function (index, text) {
return text.replace(/\W*\s(\S)*$/, '...');
});
DROP TABLE users CASCADE;
CREATE TABLE users (
id serial primary key,
name text,
email text,
password text,
created_at timestamptz );
DROP TABLE signals CASCADE;
CREATE TABLE signals (
@emhoracek
emhoracek / viewer.html
Last active September 22, 2015 00:51
JS cel viewer!
<html>
<head><title>reading some cels and palettes!</title></head>
<body>
<div id="filepicker">
<p>Palette: <input type="file" id="pal-files" name="file" /> </p>
<p>Cel:<input type="file" id="cel-files" name="file" /> </p>
<span class="readBytesButtons">

Keybase proof

I hereby claim:

  • I am emhoracek on github.
  • I am horrorcheck (https://keybase.io/horrorcheck) on keybase.
  • I have a public key whose fingerprint is 019C 0A06 358E 6FE1 B5C8 9C8D 3FB2 8C79 9086 99A0

To claim this, I am signing this object:

import Control.Monad.Trans.Maybe
import Control.Monad.Trans.Either
safeHead :: [a] -> Maybe a
safeHead [] = Nothing
safeHead xs = Just $ head xs
maybeTHead :: MaybeT IO Char
maybeTHead = MaybeT $ do
str <- getUserInput
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* cel.c -- KISS CEL file format plug-in
* (copyright) 1997,1998 Nick Lamb ([email protected])
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.