Skip to content

Instantly share code, notes, and snippets.

@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.
# If you're looking into the C10M problem (10 million concurrent connections)
# you might want to play with DPDK (Originally proprietry Intel, now open source)
#
# C10M: http://c10m.robertgraham.com/
# DPDK: http://dpdk.org/
#
# This is a quick summary how to install dpdk on ubuntu
# running inside virtualbox on a mac
# On my Mac:
@cyfdecyf
cyfdecyf / server.go
Last active August 29, 2015 14:04
Too many open file error in net.Listener.Accept loop
package main
/*
Observe different behavior of net.Listener.Accept on Linux and OS X.
Steps:
1. Build this program on Linux or OS X.
2. Execute "ulimit -Sn 5" to limit the number of open file. (You may need to
change the number to 6 or other values.)
@cyfdecyf
cyfdecyf / extract-link-url.rb
Last active December 31, 2015 12:29
Extract all link from Stanford CS 193P iTunes U feed.
@cyfdecyf
cyfdecyf / extract-cmd.sh
Last active December 29, 2015 03:59
Script to run and collect ROI (region of interest) time for the PARSEC benchmark.
#!/bin/bash
# Extract parsec benchmark run command.
APPS="blackscholes bodytrack canneal swaptions fluidanimate"
# Number of threads to run.
NTHR="2 4"
# Output file
OUTPUT=cmd
# Specify input data set.
@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 / atomic-assignment-test.go
Last active December 18, 2015 11:59
Test if Go's assignment is atomic
package main
import (
"fmt"
"runtime"
)
func main() {
var (
k string // do assignment and read to this variable
@cyfdecyf
cyfdecyf / change-slides-font.vb
Created April 17, 2013 08:59
Change font for all slides in powerpoint.
Sub textspace()
Dim slide As slide
Dim shape As shape
Dim text As TextRange2
For Each slide In ActivePresentation.Slides
For Each shape In slide.Shapes
If shape.HasTextFrame Then
Set text = shape.TextFrame2.TextRange
If Not IsNull(text) Then
@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 / gist:2005310
Created March 9, 2012 06:16 — forked from dx7/gist:1333785
Installing ruby-debug with ruby-1.9.3-p0
# Install with:
# bash < <(curl -L https://raw.github.com/gist/2005310)
#
# Reference: http://blog.wyeworks.com/2011/11/1/ruby-1-9-3-and-ruby-debug
echo "Installing ruby-debug with ruby-1.9.3-p0 ..."
curl -OL http://rubyforge.org/frs/download.php/75414/linecache19-0.5.13.gem
curl -OL http://rubyforge.org/frs/download.php/75415/ruby-debug-base19-0.11.26.gem