This file contains hidden or 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
/** | |
* Curry the hell out of any function. | |
* | |
* @param f function | |
* @returns function | |
*/ | |
function curry(f) { | |
const arity = f.length; | |
// preserve original `this` in case we're curring a class method; |
This file contains hidden or 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
/** | |
* @constructor | |
*/ | |
function* range(from, until) { | |
let i = from; | |
const stop = until ? i => i >= until : () => false; | |
while (true) { | |
if (!stop(i)) { | |
yield i; | |
} else { |
This file contains hidden or 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
interface Functor<T> { | |
map<U>(f: (x: T) => U): Functor<U> | |
} | |
class Box<T> implements Functor<T> { | |
value: T | |
constructor(x: T) { | |
this.value = x | |
} | |
map<U>(f: (x: T) => U): Box<U> { |
This file contains hidden or 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
# custom IntelliJ IDEA VM options | |
# https://docs.oracle.com/javase/8/docs/technotes/tools/unix/java.html | |
-ea | |
-Xms4096m | |
-Xmx8192m | |
-XX:CMSInitiatingOccupancyFraction=65 | |
-XX:MaxMetaspaceSize=512m | |
-XX:MaxTenuringThreshold=1 |
This file contains hidden or 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
Alamofire.request(urlString).responseJSON { response in | |
guard case let .failure(error) = response.result else { return } | |
if let error = error as? AFError { | |
switch error { | |
case .invalidURL(let url): | |
print("Invalid URL: \(url) - \(error.localizedDescription)") | |
case .parameterEncodingFailed(let reason): | |
print("Parameter encoding failed: \(error.localizedDescription)") | |
print("Failure Reason: \(reason)") |
This file contains hidden or 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 | |
till_date=$(echo $1 | tr -d "-") | |
echo ${till_date} | egrep -q "([0-9]){8,}" | |
(($? != 0)) && { | |
echo "Invalid date." 1>&2 | |
echo "Usage: days-till YYYY-MM-DD" 1>&2 |
This file contains hidden or 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 | |
vmm=VBoxManage | |
function usage { | |
echo "Usage:" $(basename $0) "start|stop" "hostname" >/dev/stderr | |
} | |
function get_ip { | |
VBoxManage guestproperty enumerate $1 \ |
This file contains hidden or 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
# Number of veterans in Russia | |
import matplotlib.pyplot as plt | |
import pandas as pd | |
from matplotlib.axes import Axes | |
from matplotlib.figure import Figure | |
raw_data_source = "https://twower.livejournal.com/2408991.html" |
This file contains hidden or 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 matplotlib.pyplot as plt | |
import pandas as pd | |
from pandas import DataFrame | |
from pandas.io.common import urlopen | |
import numpy as np | |
URL = "https://covidtracking.com/api/v1/states/daily.json" | |
ALPHA = 0.1 | |
LOGARITHMIC = False |
This file contains hidden or 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 $ivy.`dev.zio::zio:1.0.0-RC8-12` | |
import $ivy.`dev.zio::zio-streams:1.0.0-RC8-12` | |
import zio._, zio.stream._ | |
object Step1 { | |
import java.nio.file.{Files, Paths, Path} | |
import scala.collection.JavaConverters._ | |
import zio.blocking._ |