Skip to content

Instantly share code, notes, and snippets.

package main
import (
"encoding/json"
"fmt"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
"log"
)
@hollychen503
hollychen503 / autossh.service
Created June 13, 2017 15:37 — forked from thomasfr/autossh.service
Systemd service for autossh
[Unit]
Description=Keeps a tunnel to 'remote.example.com' open
After=network.target
[Service]
User=autossh
# -p [PORT]
# -l [user]
# -M 0 --> no monitoring
# -N Just open the connection and do nothing (not interactive)
@hollychen503
hollychen503 / base64.js
Created January 8, 2018 05:06 — forked from jarus/base64.js
Base64 encode and decode in javascript
var Base64 = {
characters: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=" ,
encode: function( string )
{
var characters = Base64.characters;
var result = '';
var i = 0;
do {

I have been an aggressive Kubernetes evangelist over the last few years. It has been the hammer with which I have approached almost all my deployments, and the one tool I have mentioned (shoved down clients throats) in almost all my foremost communications with clients, and it was my go to choice when I was mocking my first startup (saharacluster.com).

A few weeks ago Docker 1.13 was released and I was tasked with replicating a client's Kubernetes deployment on Swarm, more specifically testing running compose on Swarm.

And it was a dream!

All our apps were already dockerised and all I had to do was make a few modificatons to an existing compose file that I had used for testing before prior said deployment on Kubernetes.

And, with the ease with which I was able to expose our endpoints, manage volumes, handle networking, deploy and tear down the setup. I in all honesty see no reason to not use Swarm. No mission-critical feature, or incredibly convenient really nice to have feature in Kubernetes that I'm go

@hollychen503
hollychen503 / ListAllDep.sh
Last active March 26, 2018 14:47
List all dependencies of a golang program
go list -f '{{ join .Deps "\n" }}' .
go list -f '{{ join .Imports "\n" }}' .
@hollychen503
hollychen503 / gfwlistaction.sh
Created March 30, 2018 07:14
Bash / Awk script that converts GFWList into Privoxy action file
#!/bin/bash
#
# Generate Privoxy action file from gfwlist.
# $1 = proxy, example: socks5://127.0.0.1:9050
url='https://raw.githubusercontent.com/gfwlist/tinylist/master/tinylist.txt'
url='https://raw.githubusercontent.com/gfwlist/gfwlist/master/gfwlist.txt'
wget -qO- "$url"| base64 -d |
gawk -f <(sed '/^#<:>#/!d;s///' "$0") -v proxy="$1" -v verbose="$3"
@hollychen503
hollychen503 / intro.md
Created April 5, 2018 18:17 — forked from derhuerst/intro.md
Installing the Z Shell (zsh) on Linux, Mac OS X and Windows

Installing zsh – the easy way

The Z shell (zsh) is a Unix shell [...]. Zsh can be thought of as an extended Bourne shell with a large number of improvements, including some features of bash, ksh, and tcsh.

Z shell – Wikipedia

Read more about ZSH at An Introduction to the Z Shell.

Choose one of the following options.

@hollychen503
hollychen503 / Instructions.md
Created April 10, 2018 07:05 — forked from shreyaskarnik/Instructions.md
Route Docker Logs to ELK Stack
  • With Docker 1.8.0 shipped new log-driver for GELF via UDP, this means that the logs from Docker Container(s) can be shipped directly to the ELK stack for further analysis.
  • This tutorial will illustrate how to use the GELF log-driver with Docker engine.
  • Step 1: Setup ELK Stack:
    • docker run -d --name es elasticsearch
    • docker run -d --name logstash --link es:elasticsearch logstash -v /tmp/logstash.conf:/config-dir/logstash.conf logstash logstash -f /config-dir/logstash.conf
    • Note the config for Logstash can be found at this link
    • docker run --link es:elasticsearch -d kibana
  • Once the ELK stack is up now let's fire up our nginx container which ships its logs to ELK stack.
  • LOGSTASH_ADDRESS=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' logstash)
  • `docker run -d --net=host --log-driver=gelf --log-opt gelf-address=u
@hollychen503
hollychen503 / youtube2srt.py
Created April 20, 2018 09:23 — forked from YungSang/youtube2srt.py
Convert a youtube transcript in srt subtitle (Python recipe)
#!/usr/bin/python
# -*- encoding:utf-8 -*-
"""Translate Google's Transcript into srt file.
Takes google's transcript filename as argument (xml extension required).
NB: to get google's transcript, use tihs URL:
http://video.google.com/timedtext?lang=en&v=VIDEO_ID
"""
@hollychen503
hollychen503 / iterm2-solarized.md
Created April 20, 2018 17:23 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Meslo powerline font + [Powerlevel9k] - (macOS)

Default

Default

Powerlevel9k

Powerlevel9k