Skip to content

Instantly share code, notes, and snippets.

View kaleocheng's full-sized avatar
🦀

Kaleo kaleocheng

🦀
View GitHub Profile

Keybase proof

I hereby claim:

  • I am kaleocheng on github.
  • I am kaleocheng (https://keybase.io/kaleocheng) on keybase.
  • I have a public key ASAfaSIXBDt-aEo0GGROqrTy0yXBIQOzVXySLAQWhylvHQo

To claim this, I am signing this object:

#!/usr/bin/swift
# How to run:
# swiftc dict.swift
# ./dict hello
import Foundation
if (CommandLine.argc < 2) {
print("Usage: dictionary word")
}else{
let argument = CommandLine.arguments[1]
@kaleocheng
kaleocheng / Remove all git tags
Created December 28, 2017 06:18 — forked from okunishinishi/Remove all git tags
Delete all git remote tags
#Delete local tags.
git tag -l | xargs git tag -d
#Fetch remote tags.
git fetch
#Delete remote tags.
git tag -l | xargs -n 1 git push --delete origin
#Delete local tasg.
git tag -l | xargs git tag -d
@kaleocheng
kaleocheng / Makefile
Created December 26, 2017 06:01 — forked from prwhite/Makefile
Add a help target to a Makefile that will allow all targets to be self documenting
# Add the following 'help' target to your Makefile
# And add help text after each target name starting with '\#\#'
help: ## Show this help.
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'
# Everything below is an example
target00: ## This message will show up when typing 'make help'
@echo does nothing
package valid
import (
"reflect"
)
const tagName = "valid"
func IsZero(x interface{}) bool {
return reflect.DeepEqual(x, reflect.Zero(reflect.TypeOf(x)).Interface())
@kaleocheng
kaleocheng / translate.go
Created September 25, 2017 08:15 — forked from hvoecking/translate.go
Golang reflection: traversing arbitrary structures
// Traverses an arbitrary struct and translates all stings it encounters
//
// I haven't seen an example for reflection traversing an arbitrary struct, so
// I want to share this with you. If you encounter any bugs or want to see
// another example please comment.
//
// The MIT License (MIT)
//
// Copyright (c) 2014 Heye Vöcking
//
# Add init repo
mkdir hello
cd hello
git init
echo "Hello World" > README.md
git add . && git commit -m "Add README.md"
# Add empty vendor dir
git checkout --orphan vendor
@kaleocheng
kaleocheng / equals.go
Created September 12, 2017 02:46
Equals check if two Resources are equals.
// Equals check if two Resources are equals.
func Equals(r1, r2 *Obj) bool {
r1JSON, _ := json.Marshal(r1)
r2JSON, _ := json.Marshal(r2)
if string(r1JSON) == string(r2JSON) {
return true
}
return false
}
@kaleocheng
kaleocheng / rs-connect.js
Created August 24, 2017 09:26 — forked from chrisckchang/rs-connect.js
replica set connection with nodejs native
/**
* MongoDB NodeJS Driver Production Connection Example
*
* Copyright (c) 2015 ObjectLabs Corporation
* Distributed under the MIT license - http://opensource.org/licenses/MIT
*/
var MongoClient = require('mongodb').MongoClient;
/**
#!/usr/bin/env python2
from SimpleHTTPServer import SimpleHTTPRequestHandler
import BaseHTTPServer
class CORSRequestHandler (SimpleHTTPRequestHandler):
def end_headers (self):
self.send_header('Access-Control-Allow-Origin', '*')
SimpleHTTPRequestHandler.end_headers(self)
if __name__ == '__main__':