Skip to content

Instantly share code, notes, and snippets.

@max630
max630 / main.rb
Created February 1, 2012 14:27
ruby "instance" WTF
def showA0()
puts self.class
puts @a
end
class B
def showA(t)
@a = t
showA0()
end
@max630
max630 / AccessorTemplateExpr.hs
Created February 9, 2012 22:32
AccessorTemplateExpr
{-# LANGUAGE TemplateHaskell, ViewPatterns #-}
module AccessorTemplateExpr where
import Language.Haskell.TH (reify, runIO, Info(TyConI), Dec(DataD), ppr, Con(NormalC, RecC), newName,
tupE, appE, lamE, varE, conE,
conP, varP, wildP)
import Data.Accessor.Basic (fromSetGet)
makeAccessors typeName = do
info <- reify typeName
@max630
max630 / gist:1900568
Created February 24, 2012 12:04
test md

hello

@max630
max630 / a.hs
Created February 28, 2012 21:14
parser for a toy programming language
parseExprControl =
do {
label <- try (do { l <- p_name; p_eq [Spec ":"]; return l})
; e <- parseExprControl
; return (Label label e)
}
<|> do {
try (p_eq [Spec "def"])
; name <- p_name
; p_eq [Spec "="]
@max630
max630 / IOFrontend.hs
Created May 26, 2012 07:05
Enumerator-based IO Frontend for JSON-RPC
module IOFrontend where
import qualified Control.Monad.IO.Class as MIO
import qualified Data.Aeson as A
import qualified Data.Attoparsec as AP
import qualified Data.ByteString.Lazy as BSL
import qualified Data.Enumerator as E
import qualified Data.Enumerator.Binary as EB
import qualified Data.Enumerator.List as EL
import qualified GHC.IO.Handle as GIO
From cd696bc74d369ac5c3a61a93afd327cddd57adf3 Mon Sep 17 00:00:00 2001
From: Max Kirillov <max@max630.net>
Date: Sat, 20 Apr 2013 18:26:31 +0300
Subject: [PATCH 1/3] gitk refactor: split getblobdiffline into IO and text
handling
I would like to hack into diffs which gitk gets from commands.
To ease it, let's divide the read handler, getblobdiffline,
into reading and subsequent handling.
@-moz-document domain("juick.com") {
html, input {
font-size: 100% !important;
}
#topwrapper {
width: auto !important;
}
#content {
@max630
max630 / wm-notes.txt
Created November 10, 2013 11:32
WM notes
A kind of specs for window manager I need now. A bit overspecified in some places, but is a good start.
Layout:
Windows are floating, should snap each other. Would be interesting to play with tiling features, but only sometimes (auto resize snapped window).
service area is along side, which is ignored by window layouting (initial placement, maximize).
Focusing:
Either click to focus or sloppy focus (depends on having TrackPoint). No autoraise
Decorations:
@max630
max630 / Foo.hs
Last active January 10, 2016 23:16
attempt to use DataKinds
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE ExplicitNamespaces #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE OverlappingInstances #-}
{-# LANGUAGE UndecidableInstances #-}
@max630
max630 / MonadStateIO.hs
Created February 8, 2016 09:49
Monad.Trans.State replacement which uses IORef and keeps state across exceptions
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE UndecidableInstances #-}
module MonadStateIO (evalStateT,execStateT) where
import Data.Tuple (swap)
import qualified Control.Applicative as App
import qualified Control.Monad.Catch as MC
import qualified Control.Monad.Trans as MT