Skip to content

Instantly share code, notes, and snippets.

View forl's full-sized avatar
🎯
Focusing

Peter Yang forl

🎯
Focusing
View GitHub Profile
A login shell will try ~/.bash_profile, ~/.bash_login and ~/.profile in order and only open the first one it finds.
@forl
forl / gist:f6ab635aeedb865650f0f758485b16ae
Created October 30, 2019 06:33
unzip specify a character encoding for DOS, Windows and OS/2 archives
unzip -O CP936 xxx.zip -d xxx
@forl
forl / js
Created July 22, 2017 17:34
isNumber
var isNumber = function isNumber (value) {
return typeof value === 'number' && isFinite(value);
}
@forl
forl / gist:e18658464f1b5d696c078e2c480ca830
Created July 22, 2017 16:41
Why doesn't a GET request have a body?
XMLHttpRequest.send() accepts an optional argument for the request body. If the request method is GET or HEAD, the argument is ignored and request body is set to null.
@forl
forl / 0_reuse_code.js
Created December 2, 2016 09:00
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
Autobinding
React.createClass has a built-in magic feature that bound all methods to this automatically for you. This can be a little confusing for JavaScript developers that are not used to this feature in other classes, or it can be confusing when they move from React to other classes.
Therefore we decided not to have this built-in into React's class model. You can still explicitly prebind methods in your constructor if you want.
class Counter extends React.Component {
constructor() {
super();
this.tick = this.tick.bind(this);
}
@forl
forl / storeImgInMongoWithMongoose.js
Created April 20, 2016 03:28 — forked from aheckmann/storeImgInMongoWithMongoose.js
store/display an image in mongodb using mongoose/express
/**
* Module dependencies
*/
var express = require('express');
var fs = require('fs');
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
// img path