Skip to content

Instantly share code, notes, and snippets.

View bjin's full-sized avatar

bjin

  • Naples, Italy
View GitHub Profile
@bjin
bjin / .bashrc
Created May 20, 2011 14:03
Code Jam runner
export DOWNLOAD_PATH=$HOME/Desktop
gcj () {
[ -e $DOWNLOAD_PATH/*.in ] || return
file=`ls $DOWNLOAD_PATH/*.in | head -n1`
echo "Filename $file"
problem=`basename $file | sed 's/^\([A-Z]\)-.*\.in/\1/g'`
@bjin
bjin / LinearRecursive.hs
Created September 23, 2011 10:05
a proof of concept monadic linear recursive sequence solver
import Data.IntMap (IntMap)
import qualified Data.IntMap as IntMap
import Data.List (transpose)
import Control.Monad (zipWithM_)
newtype Vector a = Vector { unVector :: IntMap a }
vector :: Num a => IntMap a -> Vector a
vector = Vector
@bjin
bjin / ModP.hs
Created November 2, 2011 10:10
demo: modular arithmetic with modulus parameterized in type system
{-# LANGUAGE RankNTypes, MultiParamTypeClasses, FlexibleInstances, FlexibleContexts, ScopedTypeVariables #-}
module ModP
( modP
) where
import Data.Ratio
newtype Dep a b = Dep { unDep :: b }
@bjin
bjin / slides.css
Created March 31, 2012 13:36
modified pandoc dzslides CSS, forked from https://github.com/aski/html5-slides
@font-face {
font-family: 'PT Mono';
font-style: normal;
font-weight: normal;
src: local("☺"), url('fonts/PT_Mono-Regular.ttf') format('truetype');
}
@font-face {
font-family: 'PT Sans';
font-style: normal;
font-weight: bold;
@bjin
bjin / .gitignore
Created May 29, 2012 11:51
wenquanyi bitmap song 9pt
bdfmerge
#!/usr/bin/env bash
while true; do
find "`dirname $0`" -type f \( -name '*.jpg' -o -name '*.png' \) -print0 | shuf -z | shuf -z | shuf -z -n5 | xargs -0 feh --bg-max
sleep 1m
done
@bjin
bjin / memorize.hs
Created June 19, 2012 12:54
memorization via ST hashtable
{-# LANGUAGE RankNTypes #-}
import Data.Int
import Control.Monad.ST
import Control.Monad
import Data.Function
import Data.Hashable
import qualified Data.HashTable.ST.Cuckoo as H
type Func a b = (a -> b) -> (a -> b)
@bjin
bjin / hemming.hs
Last active December 10, 2015 01:48
import Criterion.Main
merge2 :: Ord a => [a] -> [a] -> [a]
merge2 (x:xs) (y:ys) = case compare x y of
EQ -> x : merge2 xs ys
LT -> x : merge2 xs (y:ys)
GT -> y : merge2 (x:xs) ys
hemming :: [Integer]
hemming = 1 : (map (*2) hemming `merge2` map (*3) hemming `merge2` map (*5) hemming)
@bjin
bjin / .gitignore
Last active December 13, 2023 16:20 — forked from quark-zju/ipv4_inv.cc
/ipv4_inv
<!--
Lookup musicbrainz and freedb by EAC log.
Copyright 2010, kolen
Released under the MIT License
-->
<html>
<head>
<title>Look up musicbrainz disc id and freedb id from EAC/XLD log</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>