Skip to content

Instantly share code, notes, and snippets.

View kissofjudase23's full-sized avatar
🌴
On vacation

Tom Lin kissofjudase23

🌴
On vacation
View GitHub Profile

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@kissofjudase23
kissofjudase23 / golang-tls.md
Created January 22, 2020 02:22 — forked from denji/golang-tls.md
Simple Golang HTTPS/TLS Examples

Moved to git repository: https://github.com/denji/golang-tls

Generate private key (.key)
# Key considerations for algorithm "RSA" ≥ 2048-bit
openssl genrsa -out server.key 2048

# Key considerations for algorithm "ECDSA" ≥ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)
@kissofjudase23
kissofjudase23 / stack.go
Created January 1, 2020 08:44
go library
type Item interface{}
// ItemStack the stack of Items
type ItemStack struct {
items []Item
lock *sync.RWMutex
}
// New creates a new ItemStack
func New(len int, cap int) *ItemStack {
@kissofjudase23
kissofjudase23 / asyncio_add_callback.py
Last active March 10, 2019 09:15
asyncio, use ensure_future to create task
import time
import asyncio
now = lambda : time.time()
start = now()
async def do_some_work(x):
print('Waiting: ', x)
return 'Done after {}s'.format(x)
with concurrent.futures.ProcessPoolExecutor(max_workers=os.cpu_count()) as executor:
futures_d = dict()
# extract the features of anti data
for anti_meta_path, anti_feature_path in meta_feature_path_map.items():
FileUtility.mkdir_p(anti_feature_path)
kwargs = {'src_meta_path': anti_meta_path,
'dest_feature_path': anti_feature_path}
futures_d[executor.submit(_extract_and_save_feature_from_folder, **kwargs)] = anti_meta_path
#!/bin/bash
DIR_LIST=( "${PWD}" )
function Generate_DB_File() {
Clean_DB_File
echo "<<Start to generate database for ctags and cscope!>>"
#create ctag data base
for dir in ${DIR_LIST[@]}
#ifdef WIN32
#include <cstdio>
#include <cstdlib>
#include <cstring>
#define BUFSIZE 4096
//please refer https://msdn.microsoft.com/en-us/library/ms682499%28VS.85%29.aspx?f=255&MSPPError=-2147217396
class PopenWrapper{
@kissofjudase23
kissofjudase23 / gzipCompress.cpp
Last active July 27, 2018 20:38
gzip compress/uncompress for zlib
// gzip compress, decompress sample code useing zlib
#include <string>
#include "zlib.h"
// https://www.zlib.net/manual.html
#define GZIP_CHUNK (16384)
#define GZIP_ENCODING (16)
#define GZIP_DECODING (16)
@kissofjudase23
kissofjudase23 / curl_data_callback.cpp
Last active December 25, 2018 06:43
Curl Callback Example
// curl data callback function
// https://curl.haxx.se/libcurl/c/CURLOPT_WRITEFUNCTION.html
size_t CurlWrapper:: curlDataCallback (void *buffer,
size_t size,
size_t nitems,
void *userdata)
{
if(!buffer || !userdata){
CW_DEBUG_CB("CurlWrapper::curlDataCallback",
"buffer or userdata error");
@kissofjudase23
kissofjudase23 / find_xargs.sh
Last active July 28, 2018 10:33
Shell Script Notes
# remove all c files (-p means promption)
find . -name "*.c" | xargs -p rm -f
# try to grep 'regexp' from c files
find . -name "*.c" | xargs grep 'regexp'
# or
find . -name "*.h"\
-o -name "*.hpp" \
-o -name "*.c" \