Skip to content

Instantly share code, notes, and snippets.

View sillykelvin's full-sized avatar

Kelvin Hu sillykelvin

View GitHub Profile
@acenqiu
acenqiu / redis-backup.sh
Last active March 15, 2024 09:59
redis rdb backup script
#!/bin/bash
#
## redis backup script
## usage
## redis-backup.sh port backup.dir
port=${1:-6379}
backup_dir=${2:-"/data/backup/redis"}
cli="/usr/local/bin/redis-cli -p $port"
@sim642
sim642 / delegate.hpp
Last active July 22, 2020 17:27
C++11 variadic template class for C# equivalent of delegates.
#ifndef DELEGATE_HPP_INCLUDED
#define DELEGATE_HPP_INCLUDED
#include <functional>
#include <vector>
// general case
template<typename R, typename... Args>
class delegate
{
@Jxck
Jxck / README.md
Created December 16, 2012 09:16
libuv TCP server/client sample

how to compile

$ gcc -g -Wall -I /path/to/libuv/include /path/to/libuv/uv.a -framework CoreServices server.c -o server
$ gcc -g -Wall -I /path/to/libuv/include /path/to/libuv/uv.a -framework CoreServices client.c -o client
@roxlu
roxlu / SSLBuffer.cpp
Created November 2, 2012 11:38
libuv + openssl + SSLBuffer
#include "SSLBuffer.h"
SSLBuffer::SSLBuffer()
:ssl(NULL)
,read_bio(NULL)
,write_bio(NULL)
,write_to_socket_callback(NULL)
,write_to_socket_callback_data(NULL)
,read_decrypted_callback(NULL)
,read_decrypted_callback_data(NULL)
@roxlu
roxlu / main.cpp
Created November 2, 2012 09:46
OpenSSL + LibUV: client https
#include <iostream>
#include <libgen.h>
#include <openssl/ssl.h>
#include <openssl/bio.h>
#include <openssl/err.h>
#include <openssl/pem.h>
#include <uv.h>
#include <vector>
#include <iterator>
#include <algorithm>
@dmytro
dmytro / ssh-multi.sh
Created October 31, 2012 03:46
Start multiple synchronized SSH connections with Tmux
#!/bin/bash
# ssh-multi
# D.Kovalov
# Based on http://linuxpixies.blogspot.jp/2011/06/tmux-copy-mode-and-how-to-control.html
# a script to ssh multiple servers over multiple tmux panes
starttmux() {
if [ -z "$HOSTS" ]; then
@andyferra
andyferra / github.css
Created April 30, 2012 02:11
Github Markdown CSS - for Markdown Editor Preview
body {
font-family: Helvetica, arial, sans-serif;
font-size: 14px;
line-height: 1.6;
padding-top: 10px;
padding-bottom: 10px;
background-color: white;
padding: 30px; }
body > *:first-child {

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@utaal
utaal / Makefile
Created September 5, 2011 16:42
webserver using libuv
webserver: webserver.c libuv/uv.a http-parser/http_parser.o
gcc -I libuv/include \
-lrt -lm -lpthread -o \
webserver webserver.c \
libuv/uv.a http-parser/http_parser.o
libuv/uv.a:
$(MAKE) -C libuv
http-parser/http_parser.o: