Skip to content

Instantly share code, notes, and snippets.

View xiaohutai's full-sized avatar

Xiao-Hu Tai xiaohutai

  • The Netherlands
View GitHub Profile
(function() {
if (document.getElementById('flying-focus')) return;
var flyingFocus = document.createElement('flying-focus'); // use uniq element name to decrease the chances of a conflict with website styles
flyingFocus.id = 'flying-focus';
document.body.appendChild(flyingFocus);
var DURATION = 100;
flyingFocus.style.transitionDuration = flyingFocus.style.WebkitTransitionDuration = DURATION / 1000 + 's';
@xiaohutai
xiaohutai / user.cfg
Created November 12, 2013 06:29
Battlefield 4 user.cfg
RenderDevice.Dx11Enable 1
RenderDevice.Dx11Dot1Enable 1
RenderDevice.Dx11Dot1RuntimeEnable 1
RenderDevice.TripleBufferingEnable 0
WorldRender.TransparencyShadowmapsEnable 0
WorldRender.MotionBlurEnable 0
WorldRender.MotionBlurForceOn 0
WorldRender.MotionBlurFixedShutterTime 0
WorldRender.MotionBlurMax 0
WorldRender.MotionBlurQuality 0
.disable-hover,
.disable-hover * {
pointer-events: none !important;
}
.hero-img {
width: 100%;
height: 100%;
background: url('/img/hero.jpg') center center no-repeat;
background-size: cover;
position: relative;
&:after {
content: '';
position: absolute;
top: 0;
/**
* (C)Leanest CSS spinner ever
*/
@keyframes spin {
to { transform: rotate(1turn); }
}
.progress {
position: relative;
.element {
position: relative;
top: 50%;
transform: translateY(-50%);
}

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@xiaohutai
xiaohutai / introrx.md
Last active August 29, 2015 14:24 — forked from staltz/introrx.md

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called Reactive Programming, particularly its variant comprising of Rx, Bacon.js, RAC, and others.

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

@xiaohutai
xiaohutai / preprocessor_fun.h
Last active August 29, 2015 14:27 — forked from aras-p/preprocessor_fun.h
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
@xiaohutai
xiaohutai / The Technical Interview Cheat Sheet.md
Last active August 25, 2015 20:23 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.