Skip to content

Instantly share code, notes, and snippets.

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 (
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)*$/, '...');
});
-- 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)
@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;
@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:
{-# 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)

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 8453 9205 8D53 6218 B02B C890 946A 8DC3 D3D7 A323

To claim this, I am signing this object:

@emhoracek
emhoracek / percept.hs
Created May 8, 2017 20:32
perceptrons
module Perceptron where
import Prelude hiding (and)
data Perceptron =
Perceptron { inputs :: [Input]
, bias :: Int } deriving (Eq, Show)
data Input = Input { value :: Bool
, weight :: Int } deriving (Eq, Show)
@emhoracek
emhoracek / setdata.json
Created August 18, 2017 13:29
Magical Girl Pretty Sammy set data (formatted JSON)
{
"objs": [
{
"cells": [
{
"palette": 0,
"offset": {
"x": 0,
"y": 0
},
@emhoracek
emhoracek / cart_app.rb
Created October 21, 2017 16:35
discounts
class Order < Struct.new(:line_items, :discount_name)
def discount
DiscountDatabase.find_by_name(discount_name)
end
def discounted_line_item_prices
line_items.map do |li|
li.discounted_total(discount)
end
end