schema | type | description |
---|---|---|
id | number | id of current instance |
created_at | date | when instance created? |
updated_at | date | when instance updated? |
status | [1,2,3] | life status of instance |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const value = Number(amount) | |
this.validateFaield = !isNaN(value) ? value > balance : true | |
|| | |
|| | |
this.validateFailed = !(value <= balance) | |
// compare NaN value always return false. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const binary = 0b1111 | |
//=> 15 | |
const oct = 0o1111 | |
//=> 585 | |
const decimal = 1111 | |
// => 1111 | |
const hex = 0x1111 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const random = require('lodash/random') | |
const swap = (arr, a, b) => { | |
const c = arr[a] | |
arr[a] = arr[b] | |
arr[b] = c | |
} | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with open('file') as f: | |
data = f.read() | |
print(data) | |
# with expression construct a context | |
# class method,最关键的是,context 本质上就是 __enter__, __exit__ 这两个方法,with 会自动的运行这两个方法。 | |
class CustomOpen(object): | |
def __init__(self, filename): | |
self.file = open('filename') | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# python built-in data types. | |
Boolean bool 值 True or Flase | |
String | |
Bytes / bytes array | |
Number | |
dict key/value pairs | |
tuple immutable unorder data | |
list ordered mutable data | |
set unorder mutable data, values is unique, |
When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:
var Article = require('../../../models/article');
Those suck for maintenance and they're ugly.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# CORS header support | |
# | |
# One way to use this is by placing it into a file called "cors_support" | |
# under your Nginx configuration directory and placing the following | |
# statement inside your **location** block(s): | |
# | |
# include cors_support; | |
# | |
# As of Nginx 1.7.5, add_header supports an "always" parameter which |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1: sort a list | |
data = [{'cid': 32, 'haha': 'nice'}, | |
{'cid': 31, 'haha': 'nice'}, | |
{'cid': 30, 'haha': 'nice'}, | |
{'cid': 29, 'haha': 'nice'}, | |
{'cid': 28, 'haha': 'nice'}, | |
{'cid': 27, 'haha': 'nice'}, | |
{'cid': 26, 'haha': 'nice'}, | |
{'cid': 25, 'haha': 'nice'}, | |
{'cid': 24, 'haha': 'nice'}, |
This text now lives at https://github.com/MarcDiethelm/contributing/blob/master/README.md. I turned it into a Github repo so you can, you know, contribute to it by making pull requests.
If you want to contribute to a project and make it better, your help is very welcome. Contributing is also a great way to learn more about social coding on Github, new technologies and and their ecosystems and how to make constructive, helpful bug reports, feature requests and the noblest of all contributions: a good, clean pull request.