Skip to content

Instantly share code, notes, and snippets.

View vaer-k's full-sized avatar
🏠
Working from home

Vincent Raerek vaer-k

🏠
Working from home
View GitHub Profile
/**
* An implementation for Quicksort. Doesn't
* perform as well as the native Array.sort
* and also runs the risk of a stack overflow
*
* Tests with:
*
* var array = [];
* for(var i = 0; i < 20; i++) {
* array.push(Math.round(Math.random() * 100));
@vaer-k
vaer-k / switchy-emr.pac
Last active April 2, 2020 09:25
SwitchyOmega AWS EMR proxy configuration
function regExpMatch(url, pattern) {
try { return new RegExp(pattern).test(url); } catch(ex) { return false; }
}
function FindProxyForURL(url, host) {
if (shExpMatch(url, "*ec2*.amazonaws.com*")) return 'SOCKS5 localhost:8157';
if (shExpMatch(url, "*.compute.internal*") || shExpMatch(url, "*://compute.internal*")) return 'SOCKS5 localhost:8157';
if (shExpMatch(url, "*ec2.internal*")) return 'SOCKS5 localhost:8157';
return 'DIRECT';
}
@vaer-k
vaer-k / wavetime.py
Created August 4, 2017 18:57
Pyspark transformer converting datetime to sin and cos components
import numpy as np
from pyspark.ml import Transformer
from pyspark.ml.linalg import Vectors, VectorUDT
from pyspark.sql.functions import udf
from pyspark import keyword_only
from pyspark.ml.param.shared import HasInputCol, HasOutputCol
class WaveTime(Transformer, HasInputCol, HasOutputCol):
"""Transform time field into sin/cos of seconds elapsed since midnight"""
@keyword_only
@vaer-k
vaer-k / twitch_emotes.py
Created August 21, 2017 20:12
Download twitch emotes
import os
import json
from tqdm import tqdm
from urllib import request
PATH = '~/Downloads/twitch_emotes'
EMOTE_URI = 'https://twitchemotes.com/api_cache/v2/global.json'
path = os.path.expanduser(PATH)
if not os.path.exists(path):
@vaer-k
vaer-k / matplotlib-zeppelin
Last active September 29, 2017 21:58 — forked from andershammar/matplotlib-zeppelin
Example showing how to use matplotlib from a Zeppelin notebook
%pyspark
import matplotlib.pyplot as plt
z.configure_mpl(width=400, height=300, fmt='svg')
# Example data
people = ('Goku', 'Vegeta', 'Gohan', 'Raditz', 'Trunks')
y_pos = np.arange(len(people))
performance = 3 + 10 * np.random.rand(len(people))
error = np.random.rand(len(people))
@vaer-k
vaer-k / welford.py
Created February 13, 2018 22:34 — forked from alexalemi/welford.py
Python Welford Algorithm
import math
class Welford(object):
""" Implements Welford's algorithm for computing a running mean
and standard deviation as described at:
http://www.johndcook.com/standard_deviation.html
can take single values or iterables
Properties:
mean - returns the mean
@vaer-k
vaer-k / polish.clj
Last active February 14, 2018 03:32
polish calulator
(ns clojure.reverse-notation
(:require [clojure.edn :as edn]))
(def operators {'+ + '- - '/ / '* *})
(defn calc
[expr]
(loop [[e & es] (->> expr (re-seq #"\S+") (map edn/read-string) (replace operators))
stack '()]
@vaer-k
vaer-k / keybase.md
Created May 3, 2018 20:55
keybase.md

Keybase proof

I hereby claim:

  • I am vaer-k on github.
  • I am vaer_k (https://keybase.io/vaer_k) on keybase.
  • I have a public key ASAidjD7EAmD_XkerK4oiaLvxjD33VC2u0806LaICOVZhQo

To claim this, I am signing this object:

@vaer-k
vaer-k / lessons_in_scala.json
Last active November 14, 2018 19:11
Intro to scala
{"paragraphs":[{"text":"%md\n\n### [Benefits of FP](https://alvinalexander.com/scala/fp-book/benefits-of-functional-programming#pure-functions-are-easier-to-reason-about)\n1. Pure functions are easier to reason about (referential transparency -> substitution model)\n2. Testing is easier, and pure functions lend themselves well to techniques like property-based testing\n3. Debugging is easier\n4. Programs are more bulletproof (immutability -> determinism)\n5. Programs are written at a higher level, and are therefore easier to comprehend\n6. Function signatures are more meaningful\n7. Parallel/concurrent programming is easier\n\n#### FP excels in:\n- Modularity \n- Reusability \n- Composability \n- Extensibility \n- Testability","user":"anonymous","dateUpdated":"2018-11-13T22:42:58+0000","config":{"colWidth":12,"fontSize":9,"enabled":true,"results":{},"editorSetting":{"language":"markdown","editOnDblClick":true,"completionKey":"TAB","completionSupport":false},"editorMode":"ace/mode/markdown","editorHide":true,"
@vaer-k
vaer-k / lessons_in_scala.json
Created February 15, 2019 19:47
Lessons in Scala
{"paragraphs":[{"text":"%md\n\n### [Benefits of FP](https://alvinalexander.com/scala/fp-book/benefits-of-functional-programming#pure-functions-are-easier-to-reason-about)\n1. Pure functions are easier to reason about (referential transparency -> substitution model)\n2. Testing is easier, and pure functions lend themselves well to techniques like property-based testing\n3. Debugging is easier\n4. Programs are more bulletproof (immutability -> determinism)\n5. Programs are written at a higher level, and are therefore easier to comprehend\n6. Function signatures are more meaningful\n7. Parallel/concurrent programming is easier\n\n#### FP excels in:\n- Modularity \n- Reusability \n- Composability \n- Extensibility \n- Testability","user":"anonymous","dateUpdated":"2018-11-16T01:02:29+0000","config":{"colWidth":12,"fontSize":9,"enabled":true,"results":{},"editorSetting":{"language":"markdown","editOnDblClick":true,"completionKey":"TAB","completionSupport":false},"editorMode":"ace/mode/markdown","editorHide":true,"