Skip to content

Instantly share code, notes, and snippets.

View w32zhong's full-sized avatar
⛹️
Trying to keep up.

Wei w32zhong

⛹️
Trying to keep up.
View GitHub Profile
@w32zhong
w32zhong / Treap.py
Created February 28, 2023 17:14 — forked from irachex/Treap.py
Treap (tree + heap) in Python
import random
class TreapNode(object):
def __init__(self, key, data):
self.key = key
self.ran = random.random()
self.size = 1
self.cnt = 1
self.data = data
self.left = None
@w32zhong
w32zhong / mutual_info.py
Created February 4, 2022 19:44 — forked from GaelVaroquaux/mutual_info.py
Estimating entropy and mutual information with scikit-learn: visit https://github.com/mutualinfo/mutual_info
'''
Non-parametric computation of entropy and mutual-information
Adapted by G Varoquaux for code created by R Brette, itself
from several papers (see in the code).
This code is maintained at https://github.com/mutualinfo/mutual_info
Please download the latest code there, to have improvements and
bug fixes.
@w32zhong
w32zhong / README.md
Created July 30, 2020 02:31 — forked from nitaku/README.md
Minimal JSON HTTP server in python

A minimal HTTP server in python. It sends a JSON Hello World for GET requests, and echoes back JSON for POST requests.

python server.py 8009
Starting httpd on port 8009...
curl http://localhost:8009
{"received": "ok", "hello": "world"}
@w32zhong
w32zhong / font-awesome-v5.0.1.json
Created February 21, 2020 15:05
List of all free Font Awesome icons class names v5.0.1
view icons: https://fontawesomeicons.com/
{"name":"Font Awesome v5.0.1", "icons":[
"fab fa-500px",
"fab fa-accessible-icon",
"fab fa-accusoft",
"fas fa-address-book", "far fa-address-book",
"fas fa-address-card", "far fa-address-card",
"fas fa-adjust",
"fab fa-adn",
@w32zhong
w32zhong / mathjax-responsive-scaling.html
Created August 1, 2018 05:51 — forked from adrianwong/mathjax-responsive-scaling.html
Responsive scaling of MathJax formulae
<script type="text/javascript">
window.MathJax = {
jax: ["input/TeX", "output/CommonHTML"],
extensions: ["tex2jax.js"],
TeX: {
equationNumbers: { autoNumber: "AMS" },
extensions: ["AMSmath.js", "AMSsymbols.js", "noErrors.js", "noUndefined.js"]
},
/* The MathJax API provides us with the ability to register
callbacks on signals broadcast during its startup sequence.
#include "var.h"
#include <stdio.h>
#define hello1(s) hello2(s, "default string")
void hello2(const char *s, const char* s2) {
printf("hello2 %s and %s\n", s, s2);
}
#define hello(...) xglue(hello, PP_NARG(__VA_ARGS__))(__VA_ARGS__)
@w32zhong
w32zhong / spectre.c
Created January 14, 2018 16:02 — forked from ErikAugust/spectre.c
Spectre example code
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#ifdef _MSC_VER
#include <intrin.h> /* for rdtscp and clflush */
#pragma optimize("gt",on)
#else
#include <x86intrin.h> /* for rdtscp and clflush */
#endif
@w32zhong
w32zhong / c99.l
Created May 16, 2016 19:38 — 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>
var minisiteUrl = 'http://www.wandoujia.com/campaign/pizzahut/';
var UTM = {
'weibo': '?utm_source=weibo&utm_medium=sns&utm_campaign=pizzahut',
'wechatFriend': '?utm_source=wechatFriend&utm_medium=sns&utm_campaign=pizzahut',
'wechatTimeline': '?utm_source=wechatTimeline&utm_medium=sns&utm_campaign=pizzahut',
// 扫描站内二维码的回流
'qrcode': '?utm_source=qrcode&utm_medium=minisite&utm_campaign=pizzahut'
};
@w32zhong
w32zhong / bb1.txt
Created January 6, 2016 01:10 — forked from dapangmao/bb1.txt
Bloomberg 全体展览
【===========算法============】
【*****leetcode/lintcode*****】
same tree, Binary tree inorder iterator, inorder & postorder traverse BST, binary tree level order traversal(print指定level的binary tree), tree upside down, add next to every tree node, Convert Sorted Array to BST, binary tree的maxSumPath, reverse linkedlist, linkedlist输出倒数K个node的值, linked list取中值, linked list做减法/加法(反序), valid BST, linkedlist找merge point, copy linkedlist with random pointer, flatten BST to linkedlist(把BST替换为2Dlinkedlist,本质不变), depth, interseciton of linked list(一个一步一个多步是否可以(复杂度高)) LRUCache, upside down, recover binary tree from inorder and preorder,
word search I, min stack, stock transaction I(buy date is needed) & II, two sum, subset, unique paths II, merge two/k sorted array/linked list, Find kth largest number(quickselect, array partition), sort colors, remove duplicate from a sorted array, search in sorted rotated array(binary search), search for a range and delete it in array, next permutation, find peak element(一个先降后升的数组,怎么在这个数组中找到