Skip to content

Instantly share code, notes, and snippets.

View sliding_windows.py
"""
Given a DataFrame like that:
date name mx my mz
0 2021-01-01 foo 46.676136 54.017562 1.882048
1 2021-01-01 bar 81.669122 51.525996 8.062095
2 2021-01-01 qux 54.584057 53.621155 9.475698
3 2021-01-02 foo 84.945618 51.289542 9.132064
4 2021-01-02 bar 87.438244 50.643675 1.881121
5 2021-01-02 qux 91.891133 50.347743 8.809469
View flexbase.php
<?php
class FlexBase {
private $spec = array();
private $bases = array();
private $checksum = 1;
private $num_digits;
private $pretty = FALSE;
private $base = 10;
View vimdemo.vim
syn keyword xError Error
hi def link xError Error
syn keyword xConstant Constant
hi def link xConstant Constant
syn keyword xString String
hi def link xString String
syn keyword xCharacter Character
View miu.hs
{-# LANGUAGE Haskell2010, LambdaCase #-}
import Data.List (nub)
data Symbol = M | I | U deriving (Eq, Show)
apply = \case
M : xs -> [ M : xs ++ xs ]
I : I : I : xs -> [ U : xs ]
U : U : xs -> [ xs ]
View miu-trace.hs
{-# LANGUAGE Haskell2010, LambdaCase, TupleSections #-}
import Data.List (nub)
data Symbol = M | I | U deriving (Eq, Show)
data Rule = Mx | III | UU | IU deriving (Eq, Show, Enum)
data Deduction = Axiom [Symbol] | Deduction [Symbol] Rule [Symbol]
instance Show Deduction where
show = \case
View cpp-lambda-initialization.md

The C++ Core Guidelines recommend using lambda initialization for complex initialization: https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Res-lambda-init

It gives the following reason:

Reason It nicely encapsulates local initialization, including cleaning up scratch variables needed only for the initialization, without needing to create a needless nonlocal yet nonreusable function. It also works for variables that should be const but only after some initialization work.

These examples use GCC 9.1 on x86-64 using -O2.

@scravy
scravy / nicify.hs
Created Sep 6, 2019
A Haskell Script to nicify all kinds of structured output
View nicify.hs
import Data.List (replicate)
main = getContents >>= (\x -> putStr (proc 0 x))
space = ' '
newline = '\n'
isOpening = \c -> case c of
'[' -> True
'{' -> True
View keybase.txt
### Keybase proof
I hereby claim:
* I am scravy on github.
* I am scravy (https://keybase.io/scravy) on keybase.
* I have a public key ASDeIpZp4Noqd8mYAEpKe4FGE0opfrjJK1SoWGZsGE_xrAo
To claim this, I am signing this object:
View run-unit-tests.sh
# tested on macOS, required GNU Parallel (`brew install parallel`)
src/test/test_unite --list_content 2>&1 | \
grep -v -F ' ' | \
awk '{ print "src/test/test_unite --run_test=" $0 " > /dev/null 2>&1 && echo - [x] " $0 " || echo - [ ] " $0 }' | \
parallel -j 0 bash -c 2> /dev/null | \
sort
@scravy
scravy / go-haskell-drugs.md
Last active Jan 24, 2019
golang and haskell
View go-haskell-drugs.md

<dev one> [7:20 PM]

yes!

go code immediately injects into the brain, no need to even read it 🙂

what a lovely language

<dev two> [7:20 PM]