Skip to content

Instantly share code, notes, and snippets.

@jiaoyk
jiaoyk / unicode_normalization.md
Created July 25, 2024 06:24 — forked from ciscorn/unicode_normalization.md
Normalizing Unicode strings in Python / Go / Rust

Normalizing Unicode strings in Python / Go / Rust

NFC, NFD, NFKC, NFKD

input:

it’säå(1−2)ドブロク㍿

result:

@jiaoyk
jiaoyk / parallels-reset.sh
Created May 3, 2023 04:21 — forked from gdurastanti/parallels-reset.sh
Reset Parallels' trial
#!/bin/sh
# Reset Parallels Desktop's trial and generate a casual email address to register a new user
rm /private/var/root/Library/Preferences/com.parallels.desktop.plist /Library/Preferences/Parallels/licenses.xml
jot -w pdu%d@gmail.com -r 1
@jiaoyk
jiaoyk / .bash_profile
Created May 2, 2023 14:38 — forked from jonsuh/.bash_profile
Bash echo in color
# ----------------------------------
# Colors
# ----------------------------------
NOCOLOR='\033[0m'
RED='\033[0;31m'
GREEN='\033[0;32m'
ORANGE='\033[0;33m'
BLUE='\033[0;34m'
PURPLE='\033[0;35m'
CYAN='\033[0;36m'
@jiaoyk
jiaoyk / ordering.cpp
Created April 30, 2023 05:23 — forked from adah1972/ordering.cpp
Intel CPU reordering example made to work on macOS
// Jeff Preshing's example that shows the reordering of Intel CPUs made to
// work on both Linux and macOS.
//
// Original source:
//
// https://preshing.com/20120515/memory-reordering-caught-in-the-act/
//
// Apple semaphore change is based on the answer by dho at:
//
// https://stackoverflow.com/questions/27736618/why-are-sem-init-sem-getvalue-sem-destroy-deprecated-on-mac-os-x-and-w
@jiaoyk
jiaoyk / .gitignore
Created April 30, 2023 01:20 — forked from hghwng/.gitignore
SciTools Understand for Arch Linux
pkg/
src/
understand-bin-*.pkg.*
Understand-*.tgz
.SRCINFO
@jiaoyk
jiaoyk / gist:682266e8aa85d77403029a75f95d4716
Created January 19, 2023 08:59 — forked from vmsmith/gist:ff511036e9abba7c3385
Streaming Algorithms and Data Structures
1. *General Background and Overview*
* [Probabilistic Data Structures for Web Analytics and Data Mining](http://highlyscalable.wordpress.com/2012/05/01/probabilistic-structures-web-analytics-data-mining/) : A great overview of the space of probabilistic data structures and how they are used in approximation algorithm implementation.
* [Models and Issues in Data Stream Systems](http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.106.9846)
* [Philippe Flajolet’s contribution to streaming algorithms](https://speakerdeck.com/timonk/philippe-flajolets-contribution-to-streaming-algorithms) : A presentation by Jérémie Lumbroso that visits some of the hostorical perspectives and how it all began with Flajolet
* [Approximate Frequency Counts over Data Streams](http://www.vldb.org/conf/2002/S10P03.pdf) by Gurmeet Singh Manku & Rajeev Motwani : One of the early papers on the subject.
* [Methods for Finding Frequent Items in Data Streams](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.187.9800&rep
@jiaoyk
jiaoyk / geo.rb
Created January 13, 2023 12:25 — forked from gilles/geo.rb
Some geo functions for Ruby (haversine) and a mixin for spherical search in Mongo (tested with mongoid)
# geo.rb
# Formulas from
#
# haversine formula to compute the great circle distance between two points given their latitude and longitudes
#
# Copyright (C) 2008, 360VL, Inc
# Copyright (C) 2008, Landon Cox
#
# http://www.esawdust.com (Landon Cox)
@jiaoyk
jiaoyk / c99.l
Created August 15, 2022 12:33 — forked from codebrainz/c99.l
C99 Lex/Flex & YACC/Bison Grammars
D [0-9]
L [a-zA-Z_]
H [a-fA-F0-9]
E ([Ee][+-]?{D}+)
P ([Pp][+-]?{D}+)
FS (f|F|l|L)
IS ((u|U)|(u|U)?(l|L|ll|LL)|(l|L|ll|LL)(u|U))
%{
#include <stdio.h>
@jiaoyk
jiaoyk / lua_tobignum.lua
Created August 11, 2022 03:55 — forked from luxiao/lua_tobignum.lua
lua tonumber can't handle big integer
function tobignum(v, f, step)
-- 自带tonumber遇到大整数溢出
-- v is a md5 hexdigest value, f is base format like binary or hex, use step to slice v
if f == nil then
f = 16
end
if step == nil then
step = 8
end
local len = string.len(v)