Skip to content

Instantly share code, notes, and snippets.

@agentbellnorm
agentbellnorm / TypedSwap.ts
Last active April 13, 2021 08:03
clojure's swap function in typescript with proper typing.
swap<K extends unknown[]>(swapFunction: (state: T, ...args: K) => T, ...args: K): T {
this.state = swapFunction.apply(null, [this.state, ...args]);
return this.state;
}
(ns day-eleven
(:require
[ysera.test :refer [is is-not is= deftest]]
[ysera.debug :refer [printreturn printlet]]))
(defn get-seat
{:test (fn []
(is= (get-seat [".#"
"L."] [1 0]) "#")
(is= (get-seat [".#"
export default new Store();
swap(swapFunction: (state: T, ...rest: any[]): T, ...args: any[]): T {
this.state = swapFunction.apply(null, [this.state, ...args]);
return this.state;
}
onChange(listener: (state: T) => void) {
autorun(() => listener(this.state));
}
from datetime import timedelta, date
import subprocess
import json
import pandas
def run(command, current_date, end_date):
transactions = []
fifteen_days = timedelta(days=15)
@agentbellnorm
agentbellnorm / business_hours_in_range.py
Last active July 30, 2018 09:43
Calculate business hours between two datetime instances. Non office hours and configured holidays are excluded.
from datetime import datetime, timedelta
import numpy
def hour_diff(a, b):
delta = a - b
day_hours = delta.days * 24
second_hours = delta.seconds / 3600
return day_hours + second_hours
@agentbellnorm
agentbellnorm / onename
Created April 18, 2016 06:15
onename link
Verifying that +morganbentell is my blockchain ID. https://onename.com/morganbentell