Skip to content

Instantly share code, notes, and snippets.

View kkdai's full-sized avatar

Evan Lin kkdai

View GitHub Profile
@kkdai
kkdai / main.go
Last active March 21, 2022 13:40 — forked from adityarama1210/main.go
Test Uploader GCP
package main
import (
"cloud.google.com/go/storage"
"context"
"log"
)
const (
projectID = "your-project-id" // FILL IN WITH YOURS
@kkdai
kkdai / gen_le_cert.sh
Created October 16, 2016 12:32 — forked from pahud/gen_le_cert.sh
letsencrypt cert generator with docker
#!/bin/bash
#
# 1. create a EC2 instance with public IP
# 2. create a A RR in route53 pointing your.domain.com to the public IP
# 3. make sure HTTP/HTTPS ports(80 443) are public to all in security group of this EC2 instance
# 4. make sure docker daemon is running in this EC2 instance
# 5. run this script !
# 6. keys/cert will be generated under /root/letsencrypt/etc/live/
mkdir -p /root/letsencrypt/log /root/letsencrypt/lib /root/letsencrypt/etc
package math
type A struct {
FieldA1 int32
FieldA2 int32
}
func (this A) MarshalJSON() ([]byte, error) {
m := make(map[string]interface{}, 3)
m["FieldA1"] = this.FieldA1
@kkdai
kkdai / Dockerfile.slack
Created August 7, 2016 01:15 — forked from alexellis/Dockerfile.slack
Slack Dockerfile for 2.1.0
FROM debian:stretch
ENV LC_ALL en_US.UTF-8
ENV LANG en_US.UTF-8
RUN apt-get update && apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
gconf2 \
@kkdai
kkdai / SHELL
Created June 1, 2016 01:17 — forked from jeffhung/SHELL
Vagrantfile for Declaring Tax (2016)
$ VBoxManage list usbhost
Host USB Devices:
...
UUID: 248ee848-3d9e-47cc-96d7-779e54946e39
VendorId: 0x0bda (0BDA)
ProductId: 0x0169 (0169)
Revision: 97.35 (9735)
Port: 1
@kkdai
kkdai / fbfeed2csv.py
Last active December 31, 2017 21:29 — forked from pofeng/fbfeed2csv.py
fbfeed2csv: a tool to download all posts from a user/group/page's facebook feed to a csv file 備份臉書文章
"""
modified for Python 2.7 and unicode
get your goup id at https://lookup-id.com/
get your acess token at https://developers.facebook.com/tools/explorer/
fork from
fbfeed2csv: a tool to download all posts from a user/group/page's facebook feed to a csv file
yuzawa-san
https://github.com/yuzawa-san
"""
1. 編輯你的fullchain.pem vim /etc/letsencrypt/live/blaha.tw/fullchain.pem
2. 把這個intermediate certificate(https://letsencrypt.org/certs/letsencryptauthorityx1.pem.txt)加入fullchain的兩個certificate中間
3. restart你的webserver

There are three easy to make mistakes in go. I present them here in the way they are often found in the wild, not in the way that is easiest to understand.

All three of these mistakes have been made in Kubernetes code, getting past code review at least once each that I know of.

  1. Loop variables are scoped outside the loop.

What do these lines do? Make predictions and then scroll down.

func print(pi *int) { fmt.Println(*pi) }
@kkdai
kkdai / gist:f6ee743172f6c2ca67e4
Created December 4, 2015 00:40 — forked from yyjim/gist:0b13e823646921827220
taipei opendata test
NSURL *url = [NSURL URLWithString:@"http://opendata.dot.taipei.gov.tw/opendata/alldescriptions.json"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[NSURLConnection sendAsynchronousRequest:request
queue:[NSOperationQueue mainQueue]
completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
unsigned long big5 = CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingBig5_HKSCS_1999);
NSString *json = [[NSString alloc] initWithData:data encoding:big5];
NSError *error;
NSDictionary *dictionary =
[NSJSONSerialization JSONObjectWithData:[json dataUsingEncoding:NSUTF8StringEncoding]
@kkdai
kkdai / test-1.S
Last active September 14, 2015 01:27 — forked from yinghau76/test-1.S
Test arithmetic on Go custom integer type
~/tmp $ go build -gcflags=-S test-1.go | more
# command-line-arguments
"".main t=1 size=256 value=0 args=0x0 locals=0x70
0x0000 00000 (/Users/patrick/tmp/test-1.go:7) TEXT "".main(SB), $112-0
0x0000 00000 (/Users/patrick/tmp/test-1.go:7) MOVQ (TLS), CX
0x0009 00009 (/Users/patrick/tmp/test-1.go:7) CMPQ SP, 16(CX)
0x000d 00013 (/Users/patrick/tmp/test-1.go:7) JLS 231
0x0013 00019 (/Users/patrick/tmp/test-1.go:7) SUBQ $112, SP
0x0017 00023 (/Users/patrick/tmp/test-1.go:7) FUNCDATA $0, gclocals·7d2d5fca80364273fb07d5820a76fef4(SB)
0x0017 00023 (/Users/patrick/tmp/test-1.go:7) FUNCDATA $1, gclocals·5ef976c2593056b9243adf402ae9d952(SB)