Skip to content

Instantly share code, notes, and snippets.

View gist:c0f33c5716f5c48633edf3f76ac419d4
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 Oct 30, 2019
unzip specify a character encoding for DOS, Windows and OS/2 archives
View gist:f6ab635aeedb865650f0f758485b16ae
unzip -O CP936 xxx.zip -d xxx
@forl
forl / js
Created Jul 22, 2017
isNumber
View js
var isNumber = function isNumber (value) {
return typeof value === 'number' && isFinite(value);
}
@forl
forl / gist:e18658464f1b5d696c078e2c480ca830
Created Jul 22, 2017
Why doesn't a GET request have a body?
View gist:e18658464f1b5d696c078e2c480ca830
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 Dec 2, 2016
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
View React autobinding
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 Apr 20, 2016 — forked from aheckmann/storeImgInMongoWithMongoose.js
store/display an image in mongodb using mongoose/express
View storeImgInMongoWithMongoose.js
/**
* Module dependencies
*/
var express = require('express');
var fs = require('fs');
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
// img path