Skip to content

Instantly share code, notes, and snippets.

View dkua's full-sized avatar

David Kua dkua

View GitHub Profile
@dkua
dkua / .gitconfig
Last active July 29, 2020 17:23
safebase – git alias for backing up branch before rebasing
[alias]
# Returns name of current branch
# Usage: git current
current = rev-parse --abbrev-ref HEAD
# Makes a full copy of the current branch with `backup.<epoch>` appended before doing an interactive rebase
# Usage: git safebase HEAD~2
safebase = !CURRENT=$(git current) && git branch -c $CURRENT $CURRENT.backup.$(date +%s) && git rebase -i
@dkua
dkua / README.md
Created December 21, 2018 23:06 — forked from joyrexus/README.md
collapsible markdown

collapsible markdown?

CLICK ME

yes, even hidden code blocks!

print("hello world!")
@dkua
dkua / consul_handler.rb
Created February 1, 2018 15:19 — forked from blalor/consul_handler.rb
Chef report handler for Consul
## chef report handler for Consul
## depends on a chef-client check being registered with the agent
## • pings TTL-style check with ok/warning status on chef run pass/fail
## • stores run report and node attributes in chef/reports/<datacenter>/<consul_node_name>
require "chef/handler"
require "rest_client"
class ConsulHandler < Chef::Handler
attr_reader :config
<!-- Bibliography data -->
{{ $numParams := len .Params }}
{{ if eq $numParams 0 }}
{{ if isset .Page.Params "bibliography" }}
{{ $.Scratch.Set "bib_source" .Page.Params.bibliography }}
{{ end }}
{{ if isset .Page.Params "bibliography_ignore" }}
{{ $.Scratch.Set "bib_ignore" .Page.Params.bibliography_ignore }}
{{ end }}
{{ else if eq $numParams 1 }}
def binary_search(L, s):
'''(list) -> bool
Return True iff s is an element of L, otherwise False
REQ: L must be a sorted list
'''
# BASE CASE: If L is empty, it's not in the list
if L == []:
result = False
# RECURSIVE DECOMP: Pick the middle element, if we found
# what we're looking for, great. If not, then we've at
export ANACONDAPATH=$HOME/anaconda;
anaconda() {
export PATH=$ANACONDAPATH/bin:$PATH;
}
alias "anaconda"="anaconda"
nanaconda() {
export PATH=$(echo $PATH | sed -e "s|$ANACONDAPATH/bin:||g");
}
alias "nanaconda"="nanaconda"
@dkua
dkua / gist:ddf5333266b95370c808
Created March 8, 2015 06:34
SICP Exercise 1.12
#lang scheme
(define (fact n)
(fact-tail n 1))
(define (fact-tail n acc)
(if (= 0 n)
acc
(fact-tail (- n 1) (* acc n))))
  1. General Background and Overview
@dkua
dkua / qmd_bench.sh
Last active August 29, 2015 14:02
Test script to test exit cases in QMD
#!/bin/bash
## Sample POST request to /scripts/qmd_bench.sh
##
## {
## "args": ["1", "10"],
## "callback_url": "http://192.168.88.88:9090"
## }
MIN=$1

Keybase proof

I hereby claim:

  • I am dkua on github.
  • I am dkua (https://keybase.io/dkua) on keybase.
  • I have a public key whose fingerprint is C0B1 FA59 DF22 4942 E70C D4FC 3884 0595 7325 33A5

To claim this, I am signing this object: