Skip to content

Instantly share code, notes, and snippets.

View sillykelvin's full-sized avatar

Kelvin Hu sillykelvin

View GitHub Profile
@sillykelvin
sillykelvin / generic_dispatcher.cpp
Last active May 11, 2017 07:02
A callback dispatcher with generic types
#include <memory>
#include <iostream>
#include <unordered_map>
// this is useful when dealing with google protobuf messages, what
// you get in your message callback is a google::protobuf::Message
// type, however, what you need is a concrete type, something like
// LoginRequest/LoginResponse, so you have to do the following:
//
// const LoginRequest *req = static_cast<const LoginRequest*>(msg);
@sillykelvin
sillykelvin / tmux-dev.sh
Created October 9, 2017 08:35
A tmux script to restore work environment quickly after reboot
#!/bin/sh
tmux new-session -d -s dev -n fkgfw 'sslocal -v -c own.conf'
tmux new-window -n src -c '/data/project/src'
tmux new-window -n dist -c '/data/project/dist'
tmux new-window -n build -c '/data/project/src/build'
tmux new-window -n tmp -c '/home/kelvin/tmp'
tmux new-window -n vm1 'ssh ubuntu@192.168.2.101'
tmux new-window -n vm2 'ssh ubuntu@192.168.2.102'
@sillykelvin
sillykelvin / XIRR.js
Created October 10, 2019 11:07 — forked from ghalimi/XIRR.js
XIRR Function
// Copyright (c) 2012 Sutoiku, Inc. (MIT License)
// Some algorithms have been ported from Apache OpenOffice:
/**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file