Skip to content

Instantly share code, notes, and snippets.

@nicky-zs
nicky-zs / alacritty.toml
Created March 20, 2026 16:40
我的Alacritty配置文件
# 导入配色方案 https://github.com/alacritty/alacritty-theme
[general]
import = ["alacritty-theme/themes/campbell.toml"]
# 窗口设置
[window]
dimensions = { columns = 140, lines = 40 } # 初始窗口大小
padding = { x = 2, y = 2 } # 内边距
decorations = "none"
@nicky-zs
nicky-zs / shift_space.ahk
Created February 4, 2026 08:49
将 Shift+Space 映射为 Space 的 AHK2.0 脚本
+Space::Send("{Space}")
@nicky-zs
nicky-zs / case1-bad.c
Last active September 5, 2018 06:00
The classic memory model problems on Intel x86-64 multi-core systems. Return values of system calls or library calls are NOT CHECKED because they are only demos.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <pthread.h>
#include <semaphore.h>
pthread_t t1, t2;
sem_t sem_start1, sem_start2, sem_end;
@nicky-zs
nicky-zs / inner_ip_benchmark.c
Last active June 30, 2018 03:06
benchmark of SIMD
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <arpa/inet.h>
typedef int v4si __attribute__ ((vector_size (16)));
// /8 /10 /12 /16
const v4si mask = {0x000000FF, 0x0000C0FF, 0x0000F0FF, 0x0000FFFF};
@nicky-zs
nicky-zs / Base62IdCodec.java
Last active February 1, 2018 10:51
A simple, thread-safe Base62 codec for hiding the real ID and its incresing trend. No dependencies other than JDK are required. It can encode and decode 250k+ IDs per thread per second on i5-6200@2.3GHz.
import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
import java.security.InvalidKeyException;
import java.security.Key;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
@nicky-zs
nicky-zs / nginx.conf
Last active August 25, 2017 05:51
A general nginx config file with openresty health check support.
pid /run/nginx/nginx.pid;
lock_file /run/nginx/nginx.lock;
error_log /opt/logs/nginx/error.log error;
pcre_jit on
worker_processes 4;
worker_priority -10;
events {
worker_connections 4096;
@nicky-zs
nicky-zs / inflate_request_body.lua
Created July 17, 2016 02:57
Supporting gzipped request body.
-- lua-zlib is required
local MAX_BODY_SIZE = 16777216
ngx.ctx.max_chunk_size = tonumber(ngx.var.max_chunk_size) or 262144 -- 256KB
ngx.ctx.max_body_size = tonumber(ngx.var.max_body_size) or MAX_BODY_SIZE -- 16MB
function bad_request_response(status, msg)
local message = string.format('{"status": %d, "msg": "%s"}', status, msg)
ngx.status = ngx.HTTP_BAD_REQUEST
@nicky-zs
nicky-zs / ios-app-build.sh
Created November 7, 2014 03:32
This is a bash script running on Mac OS with Xcode, which can automatically build an iOS APP from its source project.
#!/bin/bash
# .ipa path: /tmp/packapp/com.xxx.${sub_domain}/build/com.xxx.${sub_domain}.app.ipa
# required progs:
# wget;
# python2.7 ./substitute.py;
# lockfile;
# imagemagick(convert, identify);
@nicky-zs
nicky-zs / substitute.py
Created July 11, 2014 06:15
A simple python template renderer.
#!/usr/bin/python2.7
import sys
import string
_usage = """
Please redirect stdin to the input file, redirect stdout to the output file.
./subtitute.py ARG1=XXX ARG2=YYY < path_to_input > path_to_output\n
"""
@nicky-zs
nicky-zs / tool.py
Created July 9, 2014 08:21
A modification to python's standard library: json/tool.py, which makes it better print JSON containing non-ascii code.
r"""Command-line tool to validate and pretty-print JSON
Usage::
$ echo '{"json":"obj"}' | python -m json.tool
{
"json": "obj"
}
$ echo '{ 1.2:3.4}' | python -m json.tool
Expecting property name: line 1 column 2 (char 2)