Skip to content

Instantly share code, notes, and snippets.

View kumar-abhishek's full-sized avatar

Kumar Abhishek kumar-abhishek

View GitHub Profile
public void gameOfLife(int[][] board) {
if(board == null || board.length == 0) return;
int m = board.length, n = board[0].length;
for(int i = 0; i < m; i++) {
for(int j = 0; j < n; j++) {
int lives = liveNeighbors(board, m, n, i, j);
// In the beginning, every 2nd bit is 0;
// So we only need to care about when the 2nd bit will become 1.

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

"""
This file contains code that, when run on Python 2.7.5 or earlier, creates
a string that should not exist: u'\Udeadbeef'. That's a single "character"
that's illegal in Python because it's outside the valid Unicode range.
It then uses it to crash various things in the Python standard library and
corrupt a database.
On Python 3... well, this file is full of syntax errors on Python 3. But
if you were to change the print statements and byte literals and stuff:
@kumar-abhishek
kumar-abhishek / gist:1546168
Created January 1, 2012 03:41 — forked from theabraham/gist:1307910
JavaScript Resources

Google is the ultimate tool if you want to learn something new, but this link-fest is made up of some of my favorite bookmarks on JavaScript; there's a lot of reading to do!

Also, feel free to email me at xbrxhxmxlrxjhi@gmail.com (replace x's with a's) if you have any questions.

JavaScript