Skip to content

Instantly share code, notes, and snippets.

@rickyzhang-cn
rickyzhang-cn / ReferenceCounting.cpp
Created May 15, 2015 07:34
Reference count, copy-on-write
//: C12:ReferenceCounting.cpp
// From Thinking in C++, 2nd Edition
// Available at http://www.BruceEckel.com
// (c) Bruce Eckel 2000
// Copyright notice in Copyright.txt
// Reference count, copy-on-write
#include "../require.h"
#include <string>
#include <iostream>
using namespace std;
@rickyzhang-cn
rickyzhang-cn / Makefile
Last active June 25, 2022 03:33
openssl demo
INC=/usr/local/ssl/include/
LIB=/usr/local/ssl/lib/
all:
g++ -I$(INC) -L$(LIB) cli.cpp -o cli -lssl -lcrypto -ldl -fpermissive
g++ -I$(INC) -L$(LIB) serv.cpp -o serv -lssl -lcrypto -ldl -fpermissive
clean:
rm -rf *~ cli serv
@rickyzhang-cn
rickyzhang-cn / minivpn.c
Created June 2, 2015 08:36
miniVPN based on OpenSSL and TUN/TAP
/*
* tunproxy.c --- small demo program for tunneling over UDP with tun/tap
*
* Copyright (C) 2003 Philippe Biondi <phil@secdev.org>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
@rickyzhang-cn
rickyzhang-cn / itimer_demo.c
Last active August 29, 2015 14:22
timerfd demo
//gcc -o itimer_demo itimer_demo.c -lrt
#include <sys/timerfd.h>
#include <time.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h> /* Definition of uint64_t */
#define handle_error(msg) \
@rickyzhang-cn
rickyzhang-cn / solution.cpp
Created March 9, 2016 09:01
interview solution
#include <vector>
#include <map>
#include <string>
#include <iostream>
#include <cctype>
using namespace std;
bool Substitude(const string &template_str, map<string,string> &mapping, string &output) {
int state=0;
@rickyzhang-cn
rickyzhang-cn / # python - 2018-11-05_20-05-36.txt
Created November 8, 2018 11:55
python on macOS 10.14 - Homebrew build logs
Homebrew build logs for python on macOS 10.14
Build date: 2018-11-05 20:05:36