Skip to content

Instantly share code, notes, and snippets.


Chiyu Zhong CatTail

View GitHub Profile
CatTail / charlist.ex
Created Sep 30, 2018
string to charlist
View charlist.ex
to_charlist "hello world"
CatTail /
Created Aug 4, 2018
Simple CLI script read kinesis record and log to console
#! /usr/bin/env python
import sys
import boto3
import json
from datetime import datetime
import time
if len(sys.argv) != 3:
print "Usage: <region name> <stream name>"
CatTail /
Last active Mar 20, 2018 — forked from thomasst/
Migrate Redis data on Amazon ElastiCache
Copies all keys from the source Redis host to the destination Redis host.
Useful to migrate Redis instances where commands like SLAVEOF and MIGRATE are
restricted (e.g. on Amazon ElastiCache).
The script scans through the keyspace of the given database number and uses
a pipeline of DUMP and RESTORE commands to migrate the keys.
Requires Redis 2.8.0 or higher.
CatTail / proto.js
Last active Nov 27, 2017
Javascript prototype in a nutshell
View proto.js
var assert = require('assert')
var util = require('util')
function test (inherits) {
function Fruit () {
Fruit.prototype.round = false
Fruit.prototype.sweet = true = function () {}
CatTail / close.html
Last active May 10, 2017
close the fucking window
View close.html
<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<script src=""></script>
setTimeout(function () {
CatTail /
Last active Apr 13, 2017
convert lines output to json array
ls | jq -R -s -c 'split("\n")'
CatTail /
Created Apr 13, 2017
Dedupe large number of images in a directory
ls | xargs -I{} bash -c 'mv {} $(md5 -q {})'
CatTail / client.html
Created Feb 9, 2017
Simple Req/Rep pattern for (which is Pub/Sub in nature)
View client.html
<script src=""></script>
var socket = io('http://localhost:8088');
var route = createRouter((reply) => {
socket.on('rep', reply)
socket.emit('req', route('hello world', (data) => {
CatTail /
Last active Jan 9, 2017
Add all exsiting vim bundle to gitmodules
plugins=$(find . -type d -d 1 | tail -n +3)
for plugin in $plugins; do
echo plugin: $plugin
cd $plugin
repo=$(git remote -v | head -n 1 | cut -f 2 | cut -f 1 -d ' ')
echo repo: $repo
cd ..
git submodule add $repo
CatTail / gen-jsonschema
Last active Dec 7, 2016
Generate json schema definition (yaml format) from example snippt
View gen-jsonschema
#! /bin/bash
# npm install -g yamljs json-schema-generator
# json-pretty came from [here](
cat "${1:-/dev/stdin}" | json-pretty | json-schema-generator | tail -n +2 | json2yaml -d 10 -