Skip to content

Instantly share code, notes, and snippets.

@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

"""
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:

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

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.
@kumar-abhishek
kumar-abhishek / about.md
Created July 6, 2017 18:12 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer
@kumar-abhishek
kumar-abhishek / System Design.md
Created April 18, 2018 21:04 — 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?
@kumar-abhishek
kumar-abhishek / app.js
Created March 17, 2019 00:10 — forked from daffl/app.js
Basic service layer
class ChatApplication {
login (username, password) {},
logout (user) {},
joinChatRoom(roomId, user) {}
sendMessage(message, roomId, user) {}
sendPrivateMessage(message, receiverId, user) {}
@kumar-abhishek
kumar-abhishek / input.py
Last active January 12, 2020 05:24
Analyze Input
X_train_000 = pd.read_csv('chorale_000.csv')
print(X_train_000.head())
>>>
note0 note1 note2 note3
0 74 70 65 58
1 74 70 65 58
2 74 70 65 58
3 74 70 65 58
4 75 70 58 55
@kumar-abhishek
kumar-abhishek / standardize.py
Created January 12, 2020 05:10
Standardizing the data set
scaler = MinMaxScaler(feature_range=(0, 1))
dataXScaler = scaler.fit_transform(dataX)
dataYScaler = scaler.fit_transform(dataY)
print(dataXScaler[0:5])
print(dataYScaler[0:5])
>>>
[[0.44444444 0.77777778 1. 0.88235294]
[0.44444444 0.77777778 1. 0.88235294]
[0.44444444 0.77777778 1. 0.88235294]
[0.44444444 0.77777778 1. 0.88235294]