Skip to content

Instantly share code, notes, and snippets.

@whwkong
whwkong / validate_uuid.py
Last active November 6, 2020 00:17
Checks if string is valid uuid4
from uuid import UUID
def is_valid_uuid4(uuid_to_test):
"""
Check if uuid_to_test is a valid UUID, version 4.
Args:
uuid_to_test : str
@whwkong
whwkong / Search my gists.md
Last active June 24, 2020 17:48 — forked from santisbon/Search my gists.md
How to search gists

Enter this in the search box along with your search terms:

Get all gists for the user.
user:username

Find all gists with a .yml extension.
extension:yml

Find all gists with HTML files.
language:html

@whwkong
whwkong / mixins_as_fixtures.py
Last active February 16, 2019 19:07
Using Mixins as fixtures for Python UnitTest
"""
Consider the case of reusing the setUp() of a some base class that derives from
unittest.TestCase.
class BaseTest(unittest.TestCase):
def setUp(self):
super().setUp()
print('BaseTest setUp')
def testCommon(self):
#lang racket
; lecture 1B
(define (square x) (* x x))
;1.45
(define (sos x y)
(+ (square x) (square y)))
;~14.10 Iterative model (even though it'd done recursively)
@whwkong
whwkong / gnupg-pinentry-osx.md
Last active January 2, 2018 22:44
Configuring gpg-agent and pinentry on OSX

Configuring gpg-agent and pinentry on OSX

Install pinentry

pinentry is a secure PinEntry dialog.

Install pinentry for Mac

$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null
$ brew install pinentry
@whwkong
whwkong / .gitconfig
Last active March 28, 2017 16:17
.gitconfig
[alias]
ch = checkout
br = branch
st = status
#############
brm = branch --merged
brnm = branch --no-merged
#############
lsf = "!git ls-files | grep -i"
@whwkong
whwkong / Python Cheatsheet.md
Last active January 11, 2017 14:02
Python Cheatsheet
@whwkong
whwkong / merge-link-lists.py
Last active February 19, 2021 14:45
Merge Linked Lists in Python
@whwkong
whwkong / merge-link-lists.cpp
Last active December 29, 2016 20:54
MergeLinkedLists
@whwkong
whwkong / rotated-search.cpp
Last active December 23, 2016 15:51
ctci 11.3 Rotated Search
/*
For problem description, see : http://www.geeksforgeeks.org/search-an-element-in-a-sorted-and-pivoted-array/
This solution handles duplicate entries.
161223
In a rotated array with increasing elements, one-half is always in order.
In a rotated array with non-decreasing elements:
- both sides cannot be out of order.
- one or both sides must be in order.