Skip to content

Instantly share code, notes, and snippets.

View mrkschan's full-sized avatar
😀

KS Chan mrkschan

😀
View GitHub Profile
{
'subtotal_price': Decimal('38.0'),
'buyer_accepts_marketing': True,
'shipping_lines': [{
'source': 'shopify',
'price': Decimal('10.0'),
'code': 'Standard Shipping',
'title': 'Standard Shipping'
}],
'cart_token': None,
@mrkschan
mrkschan / git-graph
Created February 1, 2013 09:19
entire git graph from cli
#!/bin/bash
git log --graph --pretty="format:%C(yellow)%h%Cgreen%d%Creset %s %C(cyan) - %an, %Cred%ar%Creset"
@mrkschan
mrkschan / gist:6936112
Created October 11, 2013 14:56
dynamic object in Python via type()
o = type('anonymous', (object,), {'attr_1': 'value_1', 'attr_2': 'value_2'})
print o.attr_1, o.attr_2
@mrkschan
mrkschan / gist:7942083
Created December 13, 2013 09:46
my vim statusline
" Taglist integration
let Tlist_Process_File_Always = 1
" statusline config
set laststatus=2
set statusline=
set statusline+=%< " cut at start
set statusline+=%f " relative path
set statusline+=\ -\ %{Tlist_Get_Tagname_By_Line()} " taglist
from datetime import datetime, timedelta
import functools
import pickle
def days_ago(days):
dt = datetime.now() - timedelta(days=days)
return dt.strftime('%y%m%s')
print pickle.dumps(functools.partial(days_ago, 1))

Keybase proof

I hereby claim:

  • I am mrkschan on github.
  • I am mrkschan (https://keybase.io/mrkschan) on keybase.
  • I have a public key whose fingerprint is E55A 36A8 E3E5 CBD6 467F F8FC 8530 7567 FE26 5CC9

To claim this, I am signing this object:

@mrkschan
mrkschan / curld
Last active April 22, 2020 03:29
curl -v -k -s -o /dev/null -w 'remote_ip=%{remote_ip}, total=%{time_total}, dns=%{time_namelookup}, connect=%{time_connect}, appconnect=%{time_appconnect}, pretransfer=%{time_pretransfer}, redirect: %{time_redirect}, starttransfer: %{time_starttransfer}'
@mrkschan
mrkschan / httpecho.py
Last active September 15, 2022 09:33
import http.server
import socketserver
PORT = 8080
class H(http.server.SimpleHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.end_headers()
@mrkschan
mrkschan / timedlock.go
Created November 5, 2018 03:48
Self expirying lock in golang
package main
import (
"fmt"
"sync"
"time"
)
type TimedLock struct {
mutex chan (uint)
@mrkschan
mrkschan / Dockerfile
Last active December 6, 2018 03:06
docker build -t sandpit:stretch
FROM debian:stretch
RUN set -ex; \
apt-get update; \
apt-get install -y --no-install-recommends \
build-essential \
curl \
python-pip python-setuptools python-virtualenv \
; \
rm -rf /var/lib/apt/lists/*