This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
TZ='CST6CDT' date | |
TZ='EST' date | |
TZ='UTC' date | |
date | |
while [[ $# -gt 0 ]] && [[ "$1" == "--"* ]] ; | |
do | |
opt="$1"; | |
shift; #expose next argument |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#VAR=${1:-DEFAULTVALUE} | |
#https://coderwall.com/p/s8n9qa/default-parameter-value-in-bash | |
filename=$1 | |
privatekey="${2:-/Users/user1/.keys/private.pem}" | |
publickey="${3:-/Users/user1/.keys/public.pem}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
const fs = require('fs') | |
const decouple = xs => xs.reduce( (acc, curr) => Object.assign(acc, {[curr[0]]: curr[1]}),{}); | |
const intersection = set1 => set2 => new Set([...set1].filter(x => set2.has(x))); | |
const difference = set1 => set2 => new Set([...set1].filter(x => !set2.has(x))); | |
function ldif2json(ldif) { | |
return decouple( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Trie where | |
import qualified Data.Map.Strict as M | |
import Data.Maybe | |
import qualified Data.List as L | |
newtype Trie a = Trie (M.Map a (Trie a)) deriving Show | |
find :: Ord a => [a] -> Trie a -> Maybe (Trie a) | |
find [] t = Just t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import qualified Data.List as L | |
splitEvery :: Int -> [a] -> [[a]] | |
splitEvery n [] = [] | |
splitEvery n list = first : splitEvery n second | |
where (first, second) = L.splitAt n list | |
tuplify2 :: [a] -> (a, a) | |
tuplify2 [x, y] = (x, y) | |
tuplify2 _ = error "list does not have 2 elements" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Control.Monad | |
import Data.List ( break ) | |
import Data.Function ( (&) ) | |
readList_ :: IO [Int] | |
readList_ = do | |
n <- readLn :: IO Int | |
map read . words <$> getLine | |
data Tree a = Empty | Node a (Tree a) (Tree a) deriving (Show) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f = id | |
main = do | |
inputdata <- getContents | |
mapM_ (putStrLn. show). f. map read. lines $ inputdata |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Throwaway where | |
import Control.Monad | |
import ConvexHull ( grahamScan | |
, perimeter | |
) | |
import Text.Printf | |
h :: [Int] -> (Int, Int) | |
h (x : y : []) = (x, y) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ConvexHull where | |
import Data.List ( maximumBy | |
, minimumBy | |
, sortBy | |
) | |
import Data.Ord ( comparing | |
, Ord | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import subprocess | |
import re | |
import sys | |
def is_a_git_repo(): | |
return os.path.exists('.git') and os.path.isdir('.git') | |
def split_SSH_URL(s): | |
m = re.search('git@(.*?):(.*?)/(.*?).git', s) |
NewerOlder