Skip to content

Instantly share code, notes, and snippets.

@cyfdecyf
cyfdecyf / gen-lut.py
Created December 21, 2023 04:55
Generate 3D LUT
#!/usr/bin/env python
class Lut3DGenerator:
def __init__(self):
pass
def gen_identity_3dlut(self, lut_size, output_fname):
lut_size_f = float(lut_size)
# Generate an identity 3D LUT and write to output file.
@cyfdecyf
cyfdecyf / chrome
Last active July 20, 2023 05:56
COW's log for opening taobao.com using Chrome 28, Firefox 22, Safari 6.0.5. Log in grouped file are grouped by different client connection. See comment for how is this log collected.
[DEBUG] 2013/07/28 12:45:38 cli(127.0.0.1:53365) connected, total 1 clients
[>>>>>] 2013/07/28 12:45:38 cli(127.0.0.1:53365) request GET www.taobao.com:80/
[DEBUG] 2013/07/28 12:45:39 cli(127.0.0.1:53365) connected to www.taobao.com:80 1 concurrent connections
[<<<<<] 2013/07/28 12:45:39 cli(127.0.0.1:53365) response GET www.taobao.com:80/ 200 OK
[DEBUG] 2013/07/28 12:45:39 cli(127.0.0.1:53365) close idle connections, remains 1
[DEBUG] 2013/07/28 12:45:39 cli(127.0.0.1:53367) connected, total 2 clients
[DEBUG] 2013/07/28 12:45:39 cli(127.0.0.1:53368) connected, total 3 clients
[DEBUG] 2013/07/28 12:45:39 cli(127.0.0.1:53369) connected, total 4 clients
[>>>>>] 2013/07/28 12:45:39 cli(127.0.0.1:53367) request GET g.tbcdn.cn:80/??tb/global/1.0.5/global-min.css,tb/fp/1.1.4/first-screen-min.css,tb/fp/1.1.4/second-screen-min.css?t=20130711
[>>>>>] 2013/07/28 12:45:39 cli(127.0.0.1:53368) request GET g.tbcdn.cn:80/??tb/conve/0.0.5/common-min.css,tcc/tbr/1.0.18/tbr/common.css,tcc/tbr/1.0.18/tbr/widget/phone/phone.
@cyfdecyf
cyfdecyf / lockvschan_test.go
Last active July 5, 2023 16:40
Performance test: mutex vs. channel in Go
// run with go test -test.bench Bench
package main
import (
// "fmt"
"runtime"
"sync"
"sync/atomic"
"testing"
@cyfdecyf
cyfdecyf / closure-wrap-function.c
Created February 27, 2011 07:41
Examples to wrap function in C in different ways (workable or not)
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
// This code can now only work on Linux system.
// It has some problem on OS X. Maybe I'll fix it someday.
#if __WORDSIZE != 64 || !defined(__x86_64__)
#error "This program only works on IA64 machine."
@cyfdecyf
cyfdecyf / Makefile
Created September 11, 2015 01:53
Test get and set pipe/fifo buffer size.
pipe-size: pipe-size.o
$(CC) $< -o $@
@cyfdecyf
cyfdecyf / git-svn-diff.py
Created December 2, 2015 12:38
Convert git diff to svn patch compatible format.
#!/usr/bin/python
# Author: Chen Yufei
# Convert git diff to svn patch compatible format.
import subprocess
import sys
import re
def check_output(cmd):
@cyfdecyf
cyfdecyf / strtod-test.cpp
Last active April 23, 2021 09:06
strtod inf & nan parsing test
#include <stdio.h>
#include <cstdlib>
#include <cerrno>
#include <limits>
#include <cmath>
#include <cassert>
#include <cstring>
static const char* AtofPrecise(const char* p, double* out) {
char* end;
@cyfdecyf
cyfdecyf / linode-speedtest.sh
Created August 4, 2015 07:53
Linode speedtest
#!/bin/bash
list="
http://speedtest.newark.linode.com/100MB-newark.bin
http://speedtest.atlanta.linode.com/100MB-atlanta.bin
http://speedtest.dallas.linode.com/100MB-dallas.bin
http://speedtest.fremont.linode.com/100MB-fremont.bin
http://speedtest.frankfurt.linode.com/100MB-frankfurt.bin
http://speedtest.london.linode.com/100MB-london.bin
http://speedtest.singapore.linode.com/100MB-singapore.bin
@cyfdecyf
cyfdecyf / CMakeLists.txt
Created September 11, 2018 06:18
pybind11 TLS test
cmake_minimum_required (VERSION 2.8)
add_subdirectory(pybind11)
pybind11_add_module(test_gil test_gil.cc)
@cyfdecyf
cyfdecyf / link-duplicates.rb
Last active March 30, 2018 08:41
Find duplicate files between two directories and use hardlink to keep only one copy.