Skip to content

Instantly share code, notes, and snippets.

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

tianchaijz tianchaijz

🏠
Working from home
View GitHub Profile
@tianchaijz
tianchaijz / peranswer_score.txt
Created October 10, 2016 15:23 — forked from mjpieters/peranswer_score.txt
Top Stack Overflow users by tag score
User scores for the top 100 tags sorted on average per-answer score (users with 1000 or more answers only)
NAME TAG SCORE COUNT AVERAGE NORM WEIGHTED
1 CMS javascript 24985 1215 20.56 0.0314 38.1401
2 Eric Lippert c# 44175 2571 17.18 0.0581 149.2803
3 polygenelubricants java 12396 1024 12.11 0.0154 15.7527
4 Mehrdad Afshari c# 11975 1018 11.76 0.0157 16.0231
5 Johannes Schaub - litb c++ 21543 2002 10.76 0.0614 122.9951
6 Dave DeLong objective-c 12198 1254 9.73 0.0555 69.6445
7 Jon Skeet .net 47874 5065 9.45 0.2338 1184.0163
@tianchaijz
tianchaijz / forkpty.c
Created September 27, 2016 15:32
Forkpty + select example
#include <stdio.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <pty.h>
#include <termios.h>
#include <fcntl.h>
#include <sys/select.h>
@tianchaijz
tianchaijz / userstyle.styl
Created September 14, 2016 15:10 — forked from blackgear/userstyle.styl
I hate ugly font
CONFIG = {
'Arial Black' : 'ENG',
'Arial' : 'ENG',
'Calibri' : 'ENG',
'Cambria' : 'ENG',
'Candara' : 'ENG',
'Comic Sans MS' : 'ENG',
'Constantia' : 'ENG',
'Corbel' : 'ENG',
'Georgia' : 'ENG',
@tianchaijz
tianchaijz / planet-explore.c
Created September 14, 2016 12:53 — forked from skeeto/planet-explore.c
Planet exploration solver
/* 1) Immediately prints the base puzzle SVG to stdout.
* 2) Creates a path-*.svg each * time it hits a longest path.
* 3) Creates a solution-*.svg for each solution.
*/
#include <stdio.h>
#include <stdint.h>
#define WIDTH 8u
#define HEIGHT 8u
@tianchaijz
tianchaijz / RegIntIntval.hs
Created September 9, 2016 09:48 — forked from chaoxu/RegIntIntval.hs
Build a regular expression to match all non-negative integers between a and b.
module RegIntIntval (RegEx, matchIntRange, matchLessThan, matchGreaterThan) where
import Data.Digits
import Text.Regex.PCRE.Light
import Data.ByteString (pack)
import Data.ByteString.Internal (c2w)
import Data.Maybe
import Data.List
import FreeMonoidCompress
@tianchaijz
tianchaijz / fifo-queues.js
Created September 7, 2016 06:32
Two different FIFO queue data structures in JS. They both perform 5-10x faster than Arrays. http://jsperf.com/3-queue-implementations
var MISSING = {};
var QUEUE_COMPACT_SIZE = 500;
function define(object, properties) {
for (var key in properties) {
var desc = Object.getOwnPropertyDescriptor(properties, key);
desc.enumerable = false;
Object.defineProperty(object, key, desc);
}
}
@tianchaijz
tianchaijz / combreact.lua
Created September 6, 2016 07:50 — forked from marcoonroad/combreact.lua
Simple combinators reactive-like at Lua...
-- supply test --
-- protótipo --
local Supply = {
subs = { } -- funções inscritas --
}
-- construtor --
function Supply: new ( )
return setmetatable ({ subs = { } }, { __index = Supply })
@tianchaijz
tianchaijz / fun.cpp
Created August 15, 2016 03:09 — forked from kizzx2/fun.cpp
Illustrative C++ Lua binding example/tutorial
// fun.cpp
extern "C"
{
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
}
#include <iostream>
@tianchaijz
tianchaijz / Kahn_algorithm.cc
Created July 29, 2016 07:41 — forked from timshen91/Kahn_algorithm.cc
Kahn's algorithm for topological sort
template<typename NodeRef>
class Graph {
public:
std::vector<NodeRef> allNodes() const;
std::vector<NodeRef> getChildren(NodeRef) const;
};
template<typename NodeRef>
std::vector<NodeRef> TopologicalSort(const Graph<NodeRef>& G) {
std::map<NodeRef, unsigned> RefCount;
@tianchaijz
tianchaijz / fs-read-method-bench.cpp
Created July 25, 2016 02:52 — forked from aktau/fs-read-method-bench.cpp
benchmark fread/read/mmap/std::streams
// @aktau: this is not my file, I tried to find the original article this was from but couldn't, I'm pasting it here for posterity
#include <fcntl.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <sys/resource.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/uio.h>