Skip to content

Instantly share code, notes, and snippets.

View adept's full-sized avatar

Dmitry Astapov adept

View GitHub Profile
@adept
adept / gist:3181299
Created July 26, 2012 09:57
Bit parsing speed
module Main where
import Control.Applicative
import System.Environment
import Control.Monad
import qualified Data.ByteString.Lazy as BSL
import Data.Bits
import Data.Binary.Get
import Data.Binary.Bits.Get as Bits
@adept
adept / bf.c
Last active December 11, 2015 11:38 — forked from rblaze/bf.c
Вот это работает 2.5 минуты, из которых 40 секунд - зачитывание файла.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
const int infinity = 2147483647;
struct edge_t {
int v1;
int v2;
int cost;
@adept
adept / gist:7b532328bdd4aef930a99a63cf53f68b
Created November 24, 2017 23:09
parsePeriodExpr accepts lowercased input only, which is not ok for period transactions
First transaction will parse, second will not:
```
cat every-month.journal ~/devel/haskell/darcs-get/hledger/examples
~ aug to sep
assets
expenses $1
~ Aug to Sep
assets
@adept
adept / gist:0c0e932d789adc803e93d219f7e168c9
Created November 24, 2017 21:13
splitSpan issues demo
year-test.journal:
```
2015/02/01 first half
expenses $1
assets
2015/07/01 second half
expenses $2
assets
@adept
adept / Decimal.hs
Last active November 28, 2017 00:04
Data.Decimal is slow in common cases
{-# LANGUAGE DeriveDataTypeable #-}
-- | Decimal numbers are represented as @m*10^(-e)@ where
-- @m@ and @e@ are integers. The exponent @e@ is an unsigned Word8. Hence
-- the smallest value that can be represented is @10^-255@.
--
-- Unary arithmetic results have the exponent of the argument.
-- Addition and subtraction results have an exponent equal to the
-- maximum of the exponents of the arguments. Other operators have
-- exponents sufficient to show the exact result, up to a limit of
@adept
adept / error.txt
Created December 8, 2017 22:48
./Shake.hs && ./Shake is broken for me
[127] adept@dimail> ./Shake all ~/devel/haskell/darcs-get/hledger
stack ghc tools/pandoc-drop-web-blocks
[1 of 1] Compiling Main ( tools/pandoc-drop-web-blocks.hs, tools/pandoc-drop-web-blocks.o )
tools/pandoc-drop-web-blocks.hs:4:1: error:
Could not find module ‘Text.Pandoc.Builder’
Use -v to see a list of the files searched for.
|
4 | import Text.Pandoc.Builder
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
{-
Lecture 1 on cubicaltt (Cubical Type Theory)
--------------------------------------------------------------------------
Anders Mörtberg
This is the first lecture in a series of hands-on lectures about
cubicaltt given at Inria Sophia Antipolis.
To try the system clone the github repository and follow the
compilation instructions at:
@adept
adept / andsym.ctt
Last active December 19, 2017 16:05
And is symmetric
module andsym where
Path (A : U) (a b : A) : U = PathP (<_> A) a b
data bool = true | false
and (x:bool) : bool -> bool = split
true -> x
false -> false
@adept
adept / eveneven.ctt
Last active December 21, 2017 16:33
odd+odd, even+even, even+odd
module eveneven where
Path (A : U) (a b : A) : U = PathP (<_> A) a b
data bool = true | false
data nat = zero
| suc (n : nat)
add (m : nat) : nat -> nat = split
@adept
adept / init.journal
Created March 15, 2019 20:24
Gist shows two attempts to create csv import rules for transactions in "foreign" currency with cost in "home" currency
2019-01-01 init
equity:opening balances
assets:bank $100