Skip to content

Instantly share code, notes, and snippets.

View ldong's full-sized avatar
❤️
Love & Peace

Alan Dong ldong

❤️
Love & Peace
  • Sunnyvale, CA
View GitHub Profile
@ldong
ldong / python_docstring.md
Created July 24, 2014 00:32
Python docstring

python docstring

What is docstring?

It is a type of comment format in python, using pairs of either ''' or """.

Standard format of docstring

There's a list of standard docstring format one can follow:

  1. PEP8
@ldong
ldong / javascript_prototype.md
Last active August 29, 2015 14:04
javascript prototype

JavaScript

Prototype

JavaScript Prototype, is a way to share functions, one can simply think that is class function.

No shared functions and properties, i.e.

@ldong
ldong / vim_shortcuts.md
Created July 24, 2014 18:11
Vim Shortcuts

Vim shortcuts

zz                                       Position cursor at middle of screen
zt                                       Position cursor at top of screen
zb                                       Position cursor at the bottom of screen

H                                        Go to the Header
M                                        Go to the Middle
L                                        Go to the Lower
@ldong
ldong / javascript_create_object.md
Last active August 29, 2015 14:04
javascript create object

JavaScript

Create objects

Create an object i.e.

var person = Object.create(null);
@ldong
ldong / javascript_inheritance.md
Created July 25, 2014 02:05
javascript inheritance
@ldong
ldong / javascript_sinon_js.md
Last active August 29, 2015 14:04
javascript testing library - SinonJS

JavaScript

Sinon

What is Sinon? It is a unit test library for JavaScript.

It has 5 parts:

  1. Spy: The Test Spy is designed to act as an observation point by recording the method calls made to it by the SUT as it is exercised.
@ldong
ldong / javascript_iife.md
Created July 27, 2014 04:41
javascript Immediately-Invoked Function Expression (IIFE)

JavaScript

Immediately-Invoked Function Expression (IIFE)

So, what is IIFE? As far as I know, it is a function that being invoked right after you defined it (not quite percise, but you get the idea).

You might see this

@ldong
ldong / node_module_exports.md
Created July 27, 2014 16:26
node module exports vs exports

Node

See the repo for examples.

exports vs module.exports

Both exports and module.export use to export module for others to use

export is used to export module instance

@ldong
ldong / javasript_amd_commonjs.md
Created July 27, 2014 16:32
javascript AMD CommonJS modules

JavaScript

Lets talk about how to write modules in JavaScript.

AMD vs CommonJS

AMD and CommonJS are the two most popular JavaScript conventions for writing modules.

Asynchronous Module Definition (AMD)

@ldong
ldong / multiplication_table.py
Created July 27, 2014 18:02
python print multiplication able (九九乘法表)
#!/usr/bin/env/ python
# coding=utf8
"""
Print Multiplication Table (九九乘法表)
Original Post: http://www.oschina.net/code/snippet_915543_37544
"""
def main():
for k in range(1, 10):
s = ''