Skip to content

Instantly share code, notes, and snippets.

View nickylimjj's full-sized avatar
💭
loves itacho sushi

Nicky Lim nickylimjj

💭
loves itacho sushi
View GitHub Profile
@nickylimjj
nickylimjj / restaurant.js
Created July 1, 2016 15:19
NodeJS: non-blocking I/O
// understanding the Event Loop and async nature of nodejs
// resource help from : https://www.codeschool.com/blog/2014/10/30/understanding-node-js/
function submitOrder(orderNumber){
console.log('Submitted order and cooking: ' + orderNumber)
cookingFood(function afterEvent(){
console.log('food is cooked and ready to be delivered')
})
}
// 5s operation
@nickylimjj
nickylimjj / emitter.js
Created July 21, 2016 08:21
Nodejs: understanding Events and Emitters
// emitter.js
// returns a Function Constructor
function Emitter () {
this.events = {}
}
// Listener is the code that responds to an event
// analogy: a person taking a cue from an event to execute his task
// @type : type of event. Ie, onClick
// @listener: code to be executed
@nickylimjj
nickylimjj / classes.js
Created July 22, 2016 06:09
Nodejs: Classes - Syntactic sugar for function constructors and prototypal inheritance
// classes.js
'use strict'
var Person = class Person {
// function Person (args) {}
constructor (firstname, gender) {
this.firstname = firstname
this.gender = gender
}
@nickylimjj
nickylimjj / greet1.js
Last active July 22, 2016 06:10
Nodejs: module.exports vs exports
// module.exports
module.exports = function greet () {
console.log('greet1 [module.exports]')
}
console.log(exports)
console.log(module.exports)
@nickylimjj
nickylimjj / server.js
Last active July 22, 2016 08:53
Nodejs: simple json server
// server.js
var http = require('http')
http.createServer( function (req, res) {
res.writeHead(200, { 'Content-Type': 'application/json' })
var obj = {
firstname: 'John',
lastname: 'Lee'
}
import csv as csv
filename = '<FILENAME>'
data = []
f = open(filename)
reader = csv.reader(f)
for row in reader:
data.append(row[5])
@nickylimjj
nickylimjj / hackillinois2017.md
Last active February 26, 2017 19:32
DevPost submission for hack illinois 2017

Hack Illinois 2017

First Open Source contribution to Jupyter

About

Project Jupyter was born out of the IPython Project in 2014 as it evolved to support interactive data science and scientific computing across all programming languages.

My Work

Started with a introduction by Katy Huff to figure out the technicalities of submitting a pull request to the actual copy.(arfc/hipython#2).

Subsequently, I tried my hands on the jupyter project. I identified a beginner friendly issue with Jupyter notebook (http://jupyter.org/) which I could start with. It involved reading several issues and the codebase to identify the problem and making the necessary changes.

The issue was a bugfix in nb and server extensions where server extensions were not loaded when installed to different locations. (jupyter/notebook#2063) The solution was solved by modifiying to load with Config Manager so that the merge happens recursively by minrk (https://github.com/jupyter/noteb

@nickylimjj
nickylimjj / nric-cert.py
Last active June 15, 2017 15:49
nric-cert.py
# nric-cert.py
# verifies a Singaporean NRIC
# motivated by video from The Fun Social - How did your NRIC
# number come about?
# date created: June 15, 2017
# author: Nicky Lim
import sys
assert len(sys.argv) == 2, "Usage: python nric-cert.py <NRIC>"
@nickylimjj
nickylimjj / checkImpementation
Created November 20, 2017 12:43
Python list Implementation
$ python -m timeit --setup="x = [None]*1000" "x[500]"
10000000 loops, best of 3: 0.0579 usec per loop
$ python -m timeit --setup="x = [None]*1000" "x[0]"
10000000 loops, best of 3: 0.0566 usec per loop
m = {}
def foo(regex, s_list):
for idx, token in enumerate(regex):
# set token and ensure unique values
if (token not in m and
s_list[idx] not in m.values()):
m[token] = s_list[idx]
# fails if token not added (bcoz substring not unique) or