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
parentheseBalance :: String -> Bool | |
parentheseBalance s = f s 0 | |
where | |
f s c | |
| s == [] = c == 0 -- if string is empty, return true if count == 0 | |
| c < 0 = False | |
| head s == '(' = f (tail s) (c+1) | |
| head s == ')' = f (tail s) (c-1) | |
| otherwise = f (tail s) c | |
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
/** | |
* Created by samidarko on 9/20/16. | |
*/ | |
import util.Random | |
object MergeSort extends App { | |
def merge(left: List[Int], right: List[Int]) : List[Int] = { | |
if (left.isEmpty) right | |
else if (right.isEmpty) left |
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
" plugins config | |
set runtimepath+=~/.config/nvim/repos/github.com/Shougo/dein.vim/ | |
call dein#begin(expand('~/.config/nvim')) | |
call dein#add('Shougo/dein.vim') | |
call dein#add('othree/yajs.vim', {'on_ft': 'javascript'}) | |
call dein#add('othree/jsdoc-syntax.vim', {'on_ft':['javascript']}) | |
call dein#add('othree/es.next.syntax.vim', {'on_ft': 'javascript'}) |
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 R from 'ramda'; | |
// TODO improve signature like add index and array | |
const arr = [1, 2, 3, 4, 5]; | |
function assertNotEmpytList(fnName, list) { | |
if (list.length === undefined || list.length <= 0) throw new Error(`${fnName}: empty list`); | |
} | |
function id(x) { |
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 Data.List (genericLength) | |
mean xs = sum xs / genericLength xs | |
variance xs = (sum [ (x - m)^2 | x <- xs ]) / genericLength xs | |
where m = mean xs | |
standardDeviation xs = sqrt $ variance xs |
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 bash | |
cd ${HOME}/mining/monitoring | |
module="eth" | |
set -e | |
GPU_LIST_USAGE=( `/opt/bin/nvidia-smi --query-gpu="utilization.gpu" --format=csv,noheader,nounits` ) | |
total=0 | |
for GPU in "${GPU_LIST_USAGE[@]}" |
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 bash | |
cd ${HOME}/zec | |
SRV="eu1-zcash.flypool.org:3333" | |
ADDRESS="" | |
RIG=`hostname` |
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
data Expr = Val Int | Div Expr Expr deriving Show | |
eval :: Expr -> Int | |
eval (Val x) = x | |
eval (Div x y) = eval x `div` eval y | |
safeDiv :: Int -> Int -> Maybe Int | |
safeDiv n m = if m == 0 then Nothing else Just (n `div` m) | |
safeEval :: Expr -> Maybe Int |
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
def brute_force(arr, s): | |
for i in arr: | |
for j in arr: | |
if i + j == s: | |
print("{} + {} = {}".format(i, j, s)) | |
# brute_force([5, 3, 7, 0, 1, 4, 2], 5) |
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 Data.List.Split (splitOn) | |
-- polygons.txt | |
-- 36 30 36 30 | |
-- 15 15 15 15 | |
-- 46 96 90 100 | |
-- 86 86 86 86 | |
-- 100 200 100 200 | |
-- -100 200 -100 200 |