Skip to content

Instantly share code, notes, and snippets.

View qrilka's full-sized avatar
🖥️
as always

Kirill Zaborsky qrilka

🖥️
as always
  • FP Complete
  • Arkhangelsk, Russia
View GitHub Profile
@qrilka
qrilka / gist:5921567
Created July 3, 2013 18:44
Endo difflists
λ> import Data.Monoid
λ> let s = take 20000000 $ repeat 'a'
λ> :set +s
λ> length $ appEndo(Endo (s ++) `mappend` Endo (s ++) ) []
40000000
(0.86 secs, 2242175512 bytes)
λ> length $ appEndo(Endo (++ s) `mappend` Endo (++ s) ) []
40000000
(0.26 secs, 1121875736 bytes)
λ> length $ appEndo(Endo (++ s) `mappend` Endo (++ s)`mappend` Endo (++ s) ) []
@qrilka
qrilka / Test.hs
Created December 25, 2012 13:49
Example from aeson docs - fails in GHC 7.4.1
{-# LANGUAGE TemplateHaskell #-}
module Test where
import Data.Aeson
import Data.Aeson.TH
data D a = Nullary
| Unary Int
| Product String Char a
| Record { testOne :: Double
, testTwo :: Bool
@qrilka
qrilka / gist:4026464
Created November 6, 2012 18:10
ResumableSource example
import Control.Monad.IO.Class
import Data.Conduit
import Data.Conduit.Binary as B
import Data.Conduit.List as L
import Data.Char
import Data.Word
{-
% cat input.txt
upload
@qrilka
qrilka / gist:3842033
Created October 5, 2012 20:02
fay-tests results from master 4dde976d43307306ff9f5d1e46b0cd57b37f99c8
Test.Api:
imports: [OK]
Test.CommandLine:
executable: [OK]
compile: [OK]
Tests:
tests/Bool.hs: [Failed]
tests/Bool.hs
expected: "true\n"
but got: "\"\""
/usr/bin/ghc --make -o dist/build/image-tests/image-tests -hide-all-packages -fbuilding-cabal-package -no-user-package-conf -package-conf /home/qrilka/ws/h/imagemagick/cabal-dev/packages-7.4.2.conf -package-conf dist/package.conf.inplace -i -idist/build/image-tests/image-tests-tmp -itest -idist/build/autogen -Idist/build/autogen -Idist/build/image-tests/image-tests-tmp -I/usr/include/ImageMagick -optP-include -optPdist/build/autogen/cabal_macros.h -odir dist/build/image-tests/image-tests-tmp -hidir dist/build/image-tests/image-tests-tmp -stubdir dist/build/image-tests/image-tests-tmp -package-id base-4.5.1.0-6e4c9bdc36eeb9121f27ccbbcb62e3f3 -package-id bytestring-0.9.2.1-503e91bb155301fdb1956cb5c26ce6e9 -package-id resourcet-0.3.3.1-182a1ca09ebcb9fc1bcb2ce57788ad87 -package-id system-filepath-0.4.6-7429ac4af37fea8041e561e843fbebab -package-id text-0.11.2.2-cfa666ca84ce29f62e4ae7a77a6a12b0 -package-id transformers-0.3.0.0-8e66ecc7d4dae2b07b2b5406908c70e4 -package-id vector-0.9.1-a53ef929a177848238ea99fa7fe6688
@qrilka
qrilka / gist:2775077
Created May 23, 2012 12:50 — forked from rblaze/gist:2775009
Recursive descent parser for grammar S -> baSab ∣ baS ∣ b
module Main where
import Control.Monad (when)
import Control.Applicative ((<|>))
import Data.List
import Data.Maybe
import Debug.Trace
pS :: String -> Maybe String
@qrilka
qrilka / gist:2731874
Created May 19, 2012 18:33
xml cursor
test3 = c $// element "row" >=> parseRow
where
doc = case X.parseLBS def xml2 of
Right d -> d
Left _ -> error "invalid xml"
c = fromDocument doc
parseRow c = do
h <- c $| attribute "height"
return [(h, c $/ element "cell" >=> attribute "t")]
@qrilka
qrilka / gist:2252767
Created March 30, 2012 16:47
Could not get m/b working
\documentclass[9pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[english,russian]{babel}
\usepackage{PTSerif}
\usepackage{array}
\begin{document}
\begin{tabular}{| m{1cm} | p{5cm} | b{1cm} |}
\hline
boo &
@qrilka
qrilka / gist:1900703
Created February 24, 2012 12:41
random pair
instance (Random a, Bounded a) => Random (a,a) where randomR = randomPairR; random = randomPair
randomPairR :: (RandomGen g, Random a) => ((a,a), (a,a)) -> g -> ((a,a), g)
randomPairR ((l1,h1),(l2,h2)) g = ((v1, v2), g'')
where
(v1, g') = randomR (l1,h1) g
(v2, g'') = randomR (l2,h2) g'
randomPair :: (RandomGen g, Random a, Bounded a) => g -> ((a,a), g)
randomPair = randomPairR ((minBound, maxBound), (minBound, maxBound))
import XMonad
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Util.EZConfig (additionalKeys)
import XMonad.Layout.NoBorders (smartBorders)
import System.IO
import DBus.Client.Simple
import System.Taffybar.XMonadLog (dbusLog)
main = do