Skip to content

Instantly share code, notes, and snippets.

View lierdakil's full-sized avatar

Nikolay Yakimov lierdakil

View GitHub Profile
@lierdakil
lierdakil / example.ts
Last active September 19, 2022 13:28
An example of Functor in TypeScript. You can run this on https://www.typescriptlang.org/play/
interface Functor<T> {
map<U>(f: (x: T) => U): Functor<U>
}
class Box<T> implements Functor<T> {
value: T
constructor(x: T) {
this.value = x
}
map<U>(f: (x: T) => U): Box<U> {
@lierdakil
lierdakil / macros.c
Created December 6, 2017 20:41
Example of C concatenating macros
#define AMACROS(id, size) \
static BIN_ATTR_RW(eeprom, size); \
static struct bin_attribute *w1_f ## id ## _bin_attrs[] = { \
&bin_attr_eeprom, \
NULL, \
}; \
static const struct attribute_group w1_f ## id ## _group = { \
.bin_attrs = w1_f ## id ## _bin_attrs, \
}; \
static const struct attribute_group *w1_f ## id ## _groups[] = { \
@lierdakil
lierdakil / Caddyfile
Created August 12, 2017 19:20
Minimal example of php dev. server with Caddy (Linux)
localhost
startup php-cgi -b 10000 &
fastcgi / 127.0.0.1:10000 php
root .
errors stderr
main :: IO ()
main = putStrLn $ "Hello World!"
@lierdakil
lierdakil / index-filter.hs
Last active July 20, 2017 13:39
Pandoc filter to make indexes
import Text.Pandoc
import Text.Pandoc.JSON
import Text.Pandoc.Builder
import Control.Monad.State
import qualified Data.Map as M
main :: IO ()
main = toJSONFilter go
where
go (Just (Format "latex")) p = bottomUp runLatex p
@lierdakil
lierdakil / ArrowTest.hs
Last active April 11, 2017 20:22
A small example of using loop from Control.Arrow
{-# LANGUAGE FlexibleContexts #-}
module ArrowTest where
import Control.Arrow
import Test.QuickCheck
f, g :: Floating a => [a] -> [a]
f = loop go
where

Empty

@lierdakil
lierdakil / test-grammar.cson
Last active September 4, 2016 15:05
Grammar with indentation blocks
fileTypes: []
name: 'TestGrammar'
scopeName: 'source.test-grammar'
patterns: [
{include: '#indent-block'}
]
repository:
'indent-block': {
name: 'indent-block.test-grammar'
begin: '^(\\s+)(?=\\S)'
@lierdakil
lierdakil / stack.log
Created August 21, 2016 06:17
GHCJS install error
Version 1.1.2 x86_64 hpack-0.14.1
2016-08-21 09:16:54.646365: [debug] Checking for project config at: /home/livid/github/atom-haskell-utils/hs/stack.yaml @(5BJ0oDzTifWLpSS0yqiJ1g:Stack.Config src/Stack/Config.hs:811:9)
2016-08-21 09:16:54.646627: [debug] Loading project config file stack.yaml @(5BJ0oDzTifWLpSS0yqiJ1g:Stack.Config src/Stack/Config.hs:829:13)
2016-08-21 09:16:54.648320: [debug] Checking whether stack was built with libgmp4 @(5BJ0oDzTifWLpSS0yqiJ1g:Stack.Config src/Stack/Config.hs:326:5)
2016-08-21 09:16:54.648458: [debug] Run process: ldd /usr/bin/stack @(5BJ0oDzTifWLpSS0yqiJ1g:System.Process.Read src/System/Process/Read.hs:283:3)
2016-08-21 09:16:54.667295: [debug] Stack was not built with libgmp4 @(5BJ0oDzTifWLpSS0yqiJ1g:Stack.Config src/Stack/Config.hs:330:14)
2016-08-21 09:16:54.667742: [debug] Trying to decode /home/livid/.stack/build-plan-cache/x86_64-linux/lts-5.12.cache @(5BJ0oDzTifWLpSS0yqiJ1g:Data.Binary.VersionTagged src/Data/Binary/VersionTagged.hs:55:5)
2016-08-21 09:16:54.674994:
@lierdakil
lierdakil / xmonad.hs
Last active May 5, 2016 16:45
A toy implementation of fully monadic config
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# OPTIONS_GHC -Wall #-}