Skip to content

Instantly share code, notes, and snippets.

View hden's full-sized avatar

Haokang Den hden

View GitHub Profile
@hden
hden / sinon-1.15.4.js
Created July 9, 2015 17:51
Sinon.JS 1.15.4, 2015/06/27
/**
* Sinon.JS 1.15.4, 2015/06/27
*
* @author Christian Johansen (christian@cjohansen.no)
* @author Contributors: https://github.com/cjohansen/Sinon.JS/blob/master/AUTHORS
*
* (The BSD License)
*
* Copyright (c) 2010-2014, Christian Johansen, christian@cjohansen.no
* All rights reserved.
@hden
hden / core.clj
Created August 5, 2023 02:35
Async datascript reader using firestore
(ns dev.core
(:require [clojure.edn :as edn]
[datascript.core :as d]
[datascript.storage :refer [IStorage]])
(:import
(com.google.cloud.firestore DocumentReference
EventListener
FieldMask
Firestore
FirestoreOptions)
@hden
hden / index.js
Created July 27, 2023 03:34
BayesianCircuitBreaker
class BayesianCircuitBreaker {
constructor(windowSize, thresholdHealthy, thresholdStruggling, credibleLevel, gcInterval = 100) {
this.windowSize = windowSize
this.thresholdHealthy = thresholdHealthy
this.thresholdStruggling = thresholdStruggling
this.credibleLevel = credibleLevel
this.successCount = 0
this.failureCount = 0
this.samples = []
@hden
hden / bundle.js
Last active September 13, 2021 00:49
D3 realtime visulization
(function(){var require = function (file, cwd) {
var resolved = require.resolve(file, cwd || '/');
var mod = require.modules[resolved];
if (!mod) throw new Error(
'Failed to resolve module ' + file + ', tried ' + resolved
);
var cached = require.cache[resolved];
var res = cached? cached.exports : mod();
return res;
};
@hden
hden / .env
Last active November 10, 2020 13:28
Dockerized Datomic development environment
AWS_ACCESS_KEY_ID=
AWS_DEFAULT_REGION=
AWS_SECRET_ACCESS_KEY=
AWS_SESSION_TOKEN=
DATOMIC_SYSTEM=
@hden
hden / component.js
Created August 6, 2015 17:56
React JS Event-Emitter Mixin (you don't even have to inherent from React.Component)
import EventEmitter from 'events'
import shallowEqual from 'shallowEqual'
const shallowCompare = (instance, nextProps, nextState) => {
// https://github.com/facebook/react/blob/master/src/addons/shallowCompare.js
return (
!shallowEqual(instance.props, nextProps) ||
!shallowEqual(instance.state, nextState)
)
}
@hden
hden / terraform.log
Created October 17, 2018 09:08
google_cloudbuild_trigger resource should not force destroy and then create replacement
2018/10/17 18:07:53 [INFO] Terraform version: 0.11.8
2018/10/17 18:07:53 [INFO] Go runtime version: go1.10.3
2018/10/17 18:07:53 [INFO] CLI args: []string{"/usr/local/Cellar/terraform/0.11.8/bin/terraform", "plan"}
2018/10/17 18:07:53 [DEBUG] Attempting to open CLI config file: /Users/hden/.terraformrc
2018/10/17 18:07:53 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2018/10/17 18:07:53 [INFO] CLI command args: []string{"plan"}
2018/10/17 18:07:53 [INFO] command: empty terraform config, returning nil
2018/10/17 18:07:53 [DEBUG] command: no data state file found for backend config
2018/10/17 18:07:53 [DEBUG] New state was assigned lineage "3503affa-e226-015a-cfbe-94205c8f69b8"
2018/10/17 18:07:53 [INFO] command: backend initialized: <nil>
@hden
hden / my.cnf
Created October 26, 2018 09:13
MySQL best practice for data analysis.
[client]
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
[mysqld]
# Enabling the binlog
binlog_format = row
binlog_row_image = full
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
(ns baseball
(:require [clojure.core.match :refer [match]]))
(def initial-state {:ball 0
:strike 0
:out 0
:error 0})
(defn rules [state]
(match [state]