Skip to content

Instantly share code, notes, and snippets.

View ycliuhw's full-sized avatar
🏠
Working from home

Kelvin ycliuhw

🏠
Working from home
  • Sydney
View GitHub Profile
@ycliuhw
ycliuhw / caselessDictionary.py
Created July 5, 2016 01:29 — forked from bloomonkey/caselessDictionary.py
A Python dictionary sub-class that is case-insensitive when searching, but also preserves the keys as inserted.
class CaselessDictionary(dict):
"""A dictionary with case-insensitive keys.
A dictionary that is case-insensitive when searching, but also preserves
the keys as inserted.
"""
def __init__(self, initval={}):
if isinstance(initval, dict):
for key, value in initval.iteritems():
@ycliuhw
ycliuhw / gist:af3abe825495ea8aa6ea95bd43b2fea8
Created June 21, 2017 05:02 — forked from onlyyoujack/gist:c5796f3fa6591de52d0d
Jenkins REST API Automation via curl
#Get the current configuration and save it locally
curl -X GET http://user:password@hudson.server.org/job/myjobname/config.xml -o mylocalconfig.xml
#Update the configuration via posting a local configuration file
curl -X POST http://user:password@hudson.server.org/job/myjobname/config.xml --data-binary "@mymodifiedlocalconfig.xml"
#Creating a new job via posting a local configuration file
curl -X POST "http://user:password@hudson.server.org/createItem?name=newjobname" --data-binary "@newconfig.xml" -H "Content-Type: text/xml"
#!/usr/bin/env python3
import sys
from random import randrange
from math import log, ceil, trunc
import copy
from multiprocessing import cpu_count, Process, SimpleQueue
def minCut(g):
'''Runs the random contraction algorithm and returns the min cut (# of
@ycliuhw
ycliuhw / helm-rbac.md
Last active January 31, 2018 05:10 — forked from mgoodness/helm-rbac.md
Helm RBAC setup for K8s v1.6+ (tested on minikube)
# helm
kubectl -n kube-system create sa tiller
kubectl create clusterrolebinding tiller --clusterrole cluster-admin --serviceaccount=kube-system:tiller
helm init --service-account tiller


# draftd
kubectl patch -n kube-system deployment draftd -p '{"spec":{"template":{"spec":{"serviceAccount":"tiller"}}}}}'
kubectl create serviceaccount --namespace kube-system tiller
kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
kubectl patch deploy --namespace kube-system tiller-deploy -p '{"spec":{"template":{"spec":{"serviceAccount":"tiller"}}}}'
---
# PV_create4_jenkins_home.yml
kind: PersistentVolume
apiVersion: v1
metadata:
name: jenkins-home-pv
labels:
type: amazonEBS
purpose: jenkins-home
spec:
apiVersion: kops/v1alpha2
kind: Cluster
metadata:
creationTimestamp: 2018-01-25T00:55:52Z
name: k1.k8s.local
spec:
api:
loadBalancer:
type: Public
authorization:
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: kubernetes-dashboard
labels:
k8s-app: kubernetes-dashboard
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
@ycliuhw
ycliuhw / k8s-svc-annotations.md
Created February 7, 2018 06:23 — forked from mgoodness/k8s-svc-annotations.md
AWS ELB-related annotations for Kubernetes Services (v1.5)
  • service.beta.kubernetes.io/aws-load-balancer-access-log-emit-interval (in minutes)
  • service.beta.kubernetes.io/aws-load-balancer-access-log-enabled (true|false)
  • service.beta.kubernetes.io/aws-load-balancer-access-log-s3-bucket-name
  • service.beta.kubernetes.io/aws-load-balancer-access-log-s3-bucket-prefix
  • service.beta.kubernetes.io/aws-load-balancer-backend-protocol (http|https|ssl|tcp)
  • service.beta.kubernetes.io/aws-load-balancer-connection-draining-enabled (true|false)
  • service.beta.kubernetes.io/aws-load-balancer-connection-draining-timeout (in seconds)
#
# ---- Base Node ----
FROM alpine:3.5 AS base
# install node
RUN apk add --no-cache nodejs-npm tini
# set working directory
WORKDIR /root/chat
# Set tini as entrypoint
ENTRYPOINT ["/sbin/tini", "--"]
# copy project file