Skip to content

Instantly share code, notes, and snippets.

View hden's full-sized avatar

Haokang Den hden

View GitHub Profile
@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 / .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 / 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
@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>
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]
@hden
hden / index.html
Last active December 19, 2017 08:25
Tokyo map
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Geo Mapping</title>
<style>
html, body {
height: 100%;
margin: 0;
@hden
hden / log.txt
Created November 16, 2017 09:19
metabase
$ docker run --rm -p 3000:3000 metabase/metabase
11-16 09:07:49 INFO metabase.util :: Loading Metabase...
11-16 09:07:58 INFO util.encryption :: DB details encryption is DISABLED for this Metabase instance. 🔓
See http://www.metabase.com/docs/latest/operations-guide/start.html#encrypting-your-database-connection-details-at-rest for more information.
11-16 09:08:09 INFO metabase.core :: Starting Metabase in STANDALONE mode
11-16 09:08:09 INFO metabase.core :: Launching Embedded Jetty Webserver with config:
{:port 3000, :host "0.0.0.0"}
11-16 09:08:09 INFO metabase.core :: Starting Metabase version v0.26.2 (3b65f11 release-0.26.2) ...
11-16 09:08:09 INFO metabase.core :: System timezone is 'GMT' ...
@hden
hden / index.html
Created January 17, 2017 17:18
Collision-resistant ids optimized for horizontal scaling and performance.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Collision-resistant ids optimized for horizontal scaling and performance.</title>
<script src="//cdnjs.cloudflare.com/ajax/libs/cuid/1.3.8/browser-cuid.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/d3/4.4.1/d3.min.js"></script>
</head>
<body>
<div>How many cuids do you need?</div>