Skip to content

Instantly share code, notes, and snippets.

View CanoeFZH's full-sized avatar
🎯
Focusing

fanzhihang CanoeFZH

🎯
Focusing
  • ByteDance
  • Beijing, China
View GitHub Profile
@CanoeFZH
CanoeFZH / SplayTree`2.cs
Created December 5, 2019 09:55 — forked from otac0n/SplayTree`2.cs
A splay tree in C# for .NET, fully implementing IDictionary<TKey, TValue>.
/* ---- MIT LICENSE ----
Copyright (c) 2011 John Gietzen
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@CanoeFZH
CanoeFZH / System Design.md
Created December 10, 2018 12:37 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@CanoeFZH
CanoeFZH / pyspark-udf.py
Created April 11, 2018 09:29 — forked from zoltanctoth/pyspark-udf.py
Writing an UDF for withColumn in PySpark
from pyspark.sql.types import StringType
from pyspark.sql.functions import udf
maturity_udf = udf(lambda age: "adult" if age >=18 else "child", StringType())
df = sqlContext.createDataFrame([{'name': 'Alice', 'age': 1}])
df.withColumn("maturity", maturity_udf(df.age))
@CanoeFZH
CanoeFZH / cpp
Created March 29, 2018 09:17
fm
model:
w0: line 0; 1 column;
w: line 1 to 20000187; 1 column
v: line 20000188 to end; 4 columns;
num_factor: 4
user_feature :
@CanoeFZH
CanoeFZH / mmr.py
Last active December 11, 2017 08:28
mmr demo
import collections
'''
http://repository.cmu.edu/cgi/viewcontent.cgi?article=1330&context=compsci
https://www.quora.com/Where-can-I-find-a-maximum-marginal-relevance-algorithm-in-Python-for-redundancy-removal-in-two-documents
'''
def argmax(keys, f):
return max(keys, key=f)
@CanoeFZH
CanoeFZH / gist:2337649
Created April 8, 2012 14:40 — forked from clippit/gist:2118324
Play a 24 Game with four 0s
#include <stdio.h>
int main() {
printf("%d\n", '0'/(('0'+'0')/'0'));
printf("%d\n", '0'>>'0'/'0'+0);
printf("%d\n", -~-~-~-~-~-~0-~-~-~-~-~-~0-~-~-~-~-~-~0-~-~-~-~-~-~0);
return 0;
}