Skip to content

Instantly share code, notes, and snippets.

View deemp's full-sized avatar

Danila Danko deemp

View GitHub Profile
data Position = Position
{ row :: Int,
column :: Int
} deriving (Data)
data Segment = Segment {start::Position, end::Position} deriving (Data)
data Node a b = Node {pos::Segment, node::a, load::b} deriving (Data)
type I a = Node a ()
newtype PLicense = PLicense {cs::[I PComment]} deriving (Data)
newtype PComment = PComment {c::Text} deriving (Data)
@deemp
deemp / Main.hs
Last active April 11, 2022 16:52
Infinite recursion due to implementation of Functor via monadic bind
module Main where
import Data.Char (ord, toLower)
newtype PrsE a = PrsE { runPrsE :: String -> Either String (a, String) }
satisfyE :: (Char -> Bool) -> PrsE Char
satisfyE f = PrsE g
where
g "" = Left "unexpected end of input"
g (c:cs)
#!/bin/bash
TARGET=~/Downloads/Remote/
inotifywait -m -e create -e moved_to -e modify --format "%f" $TARGET \
| while read FILENAME
do
echo Detected $FILENAME, copying to clipboard
# https://askubuntu.com/a/759660
xclip -selection clipboard -t image/png -i "${TARGET}${FILENAME}"
import os {input}
import arrays {sum}
import math {min}
// custom IO
fn read_strings() ([]string) {return os.input('').split(' ')}
fn read_longs() ([]i64) {return read_strings().map(it.i64())}
fn read_ints() ([]int) {return read_strings().map(it.int())}
fn read_floats() ([]f64) {return read_strings().map(it.f64())}
module Main where
import Prelude
import Affjax as AX
import Affjax.ResponseFormat as AXRF
import Affjax.Web as AW
import Data.Either (hush)
import Data.Maybe (Maybe(..))
import Effect (Effect)
{-# LANGUAGE LambdaCase #-}
module Lib
where
import Text.Megaparsec
import Data.Void (Void)
import Text.Megaparsec.Char (digitChar)
import Data.Function ((&))
type Parser = Parsec Void String
{-# LANGUAGE DeriveDataTypeable #-}
module ListTemplate where
import Data.Data
import Data.HashMap.Strict
import Prelude hiding (lookup)
data A = A deriving (Data, Typeable, Show)
@deemp
deemp / nix.conf
Created September 28, 2022 14:58
accept-flake-config = false
access-tokens =
allow-dirty = true
allow-import-from-derivation = true
allow-new-privileges = false
allow-symlinked-store = false
allow-unsafe-native-code-during-evaluation = false
allowed-impure-host-deps =
allowed-uris =
allowed-users = *
example :: IO ()
example = do
ct <- getPOSIXTime
let
name = "3"
ws =
X.def
& X.atCell (3, 2) ?~ X.Cell (Just 0) (Just $ X.CellDouble 42.0) Nothing Nothing
styleSheet = sheet
where
@deemp
deemp / Database.sol
Last active December 15, 2022 09:42
Database-like contract using solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract Database {
struct Table {
string[] columns;
mapping(string => string[]) values;
bool exists;
}