Skip to content

Instantly share code, notes, and snippets.

View nl253's full-sized avatar
🎯
Focusing

nl253

🎯
Focusing
View GitHub Profile
@nl253
nl253 / commandline.py
Created April 23, 2017 15:28 — forked from opie4624/commandline.py
Base Python Command Line template
#!/usr/bin/env python
#
# import modules used here -- sys is a very standard one
import sys, argparse, logging
# Gather our code in a main() function
def main(args, loglevel):
logging.basicConfig(format="%(levelname)s: %(message)s", level=loglevel)
@nl253
nl253 / array_slicing_and_compaction.advanced.bash
Created May 2, 2017 05:17
Advanced Bash :: Array slicing and compaction in bash
# Advanced Bash :: Array slicing and compaction in bash
# TL;DR
X=(something 'whatever' "i have more S P A C E S than i can give away. arent you jealous?")
# ${X[@]} the usual whole array
# ${X[@]:index:length} slice from index to index+length-1 inclusive
# ${X[@]::length} slice from 0 to length-1 inclusive
# ${X[@]:index} slice from index to end of array inclusive
@nl253
nl253 / css-units-best-practices.md
Created December 26, 2017 18:07 — forked from basham/css-units-best-practices.md
CSS Units Best Practices

CSS units

Recommendations of unit types per media type:

Media Recommended Occasional use Infrequent use Not recommended
Screen em, rem, % px ch, ex, vw, vh, vmin, vmax cm, mm, in, pt, pc
Print em, rem, % cm, mm, in, pt, pc ch, ex px, vw, vh, vmin, vmax

Relative units

Relative units

@nl253
nl253 / pipelines.erl
Last active March 8, 2018 20:17
Erlang concurrent pipelines
% module must match file name - no dashes `-`.
-module(pipelines).
-compile(export_all).
%% @doc Emmits signals of value V or F() every M miliseconds N times.
%%
%% @param V value to emit
%% @param M milisecond delay
%% @param N number of cycles
%% @param P process
@nl253
nl253 / Minimax.hs
Created March 15, 2018 19:36
Unfinished Minimax but this is all I can do at this point
import Data.List (nub)
data Move
= Maxi Int
| Mini Int
instance Show Move where
show (Mini n) = "Mini " ++ (show n)
show (Maxi n) = "Maxi " ++ (show n)
@nl253
nl253 / BinarySearchTrees.hs
Created March 15, 2018 21:23
Binary Search Trees in Haskell
module BinaryTree where
data BTree
= Leaf
| Node { value :: Int
, leftBTree :: BTree
, rightBTree :: BTree }
instance Show BTree where
show Leaf = ""
@nl253
nl253 / CsvParser.hs
Created March 18, 2018 10:21
Csv parser
module Csv where
import Data.List (lines)
type Row = [String]
type Lines = [String]
type Table = [Row]
@nl253
nl253 / hoogleProjectOmniFunct.vim
Last active April 14, 2018 21:02
Haskell OmniFunc - query hoogle and project file for functions with signatures etc
" NOTE: requires +timers
" cache storage
let g:hoogled_completions = {}
" non-function keywords
let g:hoogle_blacklist = [
\ 'where',
\ 'let',
@nl253
nl253 / showFunctSignatureHoogle.vim
Last active April 14, 2018 20:45
Haskell - show function signature on cursor hold autocommand (uses hoogle)
let g:hoogled_signatures = {}
let g:hoogle_blacklist = [
\ 'where',
\ 'let',
\ 'class',
\ 'then',
\ 'module',
\ 'qualified',
\ 'data',
\ 'type',
@nl253
nl253 / WriterMonad.hs
Created April 25, 2018 20:29
WriterMonad
module WriterMonad
( logInput
) where
import Control.Monad.Writer
import Data.Char (isDigit, isLetter, isLower,
isPunctuation, isSpace, isUpper)
logInput :: String -> [String]
logInput xs =