Skip to content

Instantly share code, notes, and snippets.

View 92hackers's full-sized avatar
🎯
Focusing

CHEN Yuan 92hackers

🎯
Focusing
View GitHub Profile
@92hackers
92hackers / README-Template.md
Created August 31, 2017 11:58 — forked from avikalkohlinagarro/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@92hackers
92hackers / common_fields.md
Last active September 3, 2017 02:19
Common fields to a database model
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
@92hackers
92hackers / code_refactor.js
Created September 13, 2017 12:34
compare two snippets
const value = Number(amount)
this.validateFaield = !isNaN(value) ? value > balance : true
||
||
this.validateFailed = !(value <= balance)
// compare NaN value always return false.
@92hackers
92hackers / numbers.js
Last active September 14, 2017 02:54
javascript number types
const binary = 0b1111
//=> 15
const oct = 0o1111
//=> 585
const decimal = 1111
// => 1111
const hex = 0x1111
@92hackers
92hackers / randomRange.js
Last active September 14, 2017 05:45
Randomly align items between a range of numbers, no duplicates.
const random = require('lodash/random')
const swap = (arr, a, b) => {
const c = arr[a]
arr[a] = arr[b]
arr[b] = c
}
/**
@92hackers
92hackers / three_with_context.py
Created September 21, 2017 12:06
Three kinds of method to establish a with context
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')
@92hackers
92hackers / datatypes.py
Last active October 9, 2017 12:10
Important notes about Python
# 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,
@92hackers
92hackers / better-nodejs-require-paths.md
Created October 13, 2017 23:03 — forked from branneman/better-nodejs-require-paths.md
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

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.

Possible solutions

@92hackers
92hackers / nginx.conf
Created December 12, 2017 14:00 — forked from Stanback/nginx.conf
Example Nginx configuration for adding cross-origin resource sharing (CORS) support to reverse proxied APIs
#
# 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
@92hackers
92hackers / .vimrc
Last active June 14, 2019 08:50
new-cy-vimrc
" This line should not be removed as it ensures that various options are
" properly set to work with the Vim-related packages available in Debian.
runtime! debian.vim
" Vim self configurations
set cindent
set incsearch
set backspace=2
set foldenable