Skip to content

Instantly share code, notes, and snippets.

View zw963's full-sized avatar
🏠
Working from home

Billy.Zheng zw963

🏠
Working from home
View GitHub Profile
@jgaskins
jgaskins / require.cr
Created May 11, 2022 21:18
Project-local requires in Crystal
# Experiment with macros to allow for project-local requires
# https://forum.crystal-lang.org/t/project-relative-require/4617
{% begin %}
ROOT = "{{system("pwd").strip.id}}"
{% end %}
macro spec(file)
macro load_spec
\{% path = __DIR__.gsub(%r{\A{{ROOT.id}}}, "").gsub(%r{[^/]+}, "..").id %}
require "\{{path[1..]}}/spec/{{file.id}}"
@straight-shoota
straight-shoota / Makefile
Last active February 5, 2024 00:21
Makefile for Crystal + Shards
.POSIX:
all:
# Recipes
## Build application
## $ make
## Run tests
## $ make test
## Install application
@stephan-nordnes-eriksen
stephan-nordnes-eriksen / key-value-performance-test.md
Last active February 21, 2024 03:22
Performance testing different Key-Value stores in Ruby

For a project I am on I need to use a key-value store to converts file-paths to fixnum IDs. The dataset will typically be in the range of 100 000 to 1 000 000. These tests use 305 000 file paths to fixnum IDs.

The Different Key-Value stores tested are:

Daybreak: "Daybreak is a simple and very fast key value store for ruby" GDBM: GNU dbm. "a simple database engine for storing key-value pairs on disk." DBM: "The DBM class provides a wrapper to a Unix-style dbm or Database Manager library" PStore: "PStore implements a file based persistence mechanism based on a Hash. "

Out of these, all except Daybreak are in the Ruby standard library.

@epitron
epitron / kv_bench.rb
Last active May 18, 2020 05:21
Benchmark Ruby's various key/value databases (GDBM, SDBM, CDB)
require 'epitools'
%w[gdbm sdbm cdb].each { |lib| require lib }
DBS = [
[GDBM, GDBM],
[SDBM, SDBM],
[CDBMake, CDB ],
]
NUM = 100000
@wen-long
wen-long / ss-redir 透明代理.md
Last active March 18, 2024 12:13
ss-redir 透明代理.md

##ss-redir 的 iptables 配置(透明代理)

透明代理指对客户端透明,客户端不需要进行任何设置就使用了网管设置的代理规则

创建 /etc/ss-redir.json 本地监听 7777 运行ss-redir -v -c /etc/ss-redir.json

iptables -t nat -N SHADOWSOCKS
# 在 nat 表中创建新链
iptables -t nat -A SHADOWSOCKS -p tcp --dport 23596 -j RETURN
# 23596 是 ss 代理服务器的端口,即远程 shadowsocks 服务器提供服务的端口,如果你有多个 ip 可用,但端口一致,就设置这个
@doitian
doitian / emacsclient-find-file-in-dedicated-frame.sh
Created September 23, 2012 03:45
Open file in dedicated Emacs frame
#!/bin/sh
for file; do
emacsclient -e "(find-file-in-dedicated-frame \"${file/\"/\\\"}\" \"Finder\" 'focus)"
done
@unak
unak / history.txt
Last active November 29, 2021 01:40
The History of Ruby
* Only the releases of the stable versions are listed in principle. The releases of the unstable versions especially considered to be important are indicated as "not stable."
* The branches used as the source of each releases are specified, and the branching timing of them are also shown. BTW, before subversionizing of the repository, the term called "trunk" was not used, but this list uses it in order to avoid confusion.
* In order to show a historical backdrop, big conferences (RubyKaigi, RubyConf and Euruko) are also listed. About the venues of such conferences, general English notations are adopted, in my hope.
* ruby_1_8_7 branch was recut from v1_8_7 tag after the 1.8.7 release because of an accident.
* 1.2.1 release was canceled once, and the 2nd release called "repack" was performed. Although there were other examples similar to this, since the re-releases were performed during the same day, it does not write clearly in particular.
* Since 1.0 was released with the date in large quantities, the mi
@brixen
brixen / gist:1132332
Created August 8, 2011 18:13
Proposal to change .rbc files to use only the rbc.db mechanism
Rubinius uses .rbc files to cache on disk the compiled bytecode for a Ruby
source code file. Typically, these cache files exist alongside the
corresponding .rb file, however, it is possible to collect all the cache files
into a single directory (and subdirectories) by hashing the full path to the
Ruby source file as a key to find a file in the cache directory.
In Rubinius 2.0, we have multiple language modes. The bytecode for 1.8
language mode differs from the bytecode for 1.9 language mode. The .rbc file
format was extended to include language version. This ensures that running the