Skip to content

Instantly share code, notes, and snippets.

View Erichain's full-sized avatar

Erichain Erichain

  • Chengdu, Sichuan
View GitHub Profile
bondden /
Last active May 19, 2016 02:07
Temporary fix for graceful-fs related Node.js 5 to 6 update error: (node:14471) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.
#!/usr/bin/env bash
# Temporary fix for Node.js 5 to 6 aupdate error:
# (node:14471) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.
# Updates any package by package name, version number, if set,
# or graceful-fs to 4.1.3 by default.
# By default runs npm dedupe after applying fixes
# Usage: bash ./ [MODULE VERSION [noddp]]
# where
nepsilon /
Last active August 9, 2018 11:19
How to secure your site with HTTPS? — First published in issue #101

How to secure your site with HTTPS?

With HTTP everything is visible when traveling on the Internet. By generating an SSL certificate and configuring your webserver you can force browsers to use HTTPS. Here is how to proceed:

# 1. Install letsencrypt
sudo pip install letsencrypt
sean-hill / Ionic and ngCordova upload example
Last active May 6, 2019 01:52
Upload service for Ionic and ngCordova
Ionic and ngCordova upload example
balupton /
Last active June 7, 2021 16:00
Node.js Best Practice Exception Handling
fiznool / hashid.js
Created November 16, 2014 09:45
Short 'hash' ID generator.
'use strict';
* The default alphabet is 25 numbers and lowercase letters.
* Any numbers that look like letters and vice versa are removed:
* 1 l, 0 o.
* Also the following letters are not present, to prevent any
* expletives: cfhistu
remino / msconvert.js
Created January 5, 2012 05:37
JavaScript: Convert milliseconds to object with days, hours, minutes, and seconds
function convertMS(ms) {
var d, h, m, s;
s = Math.floor(ms / 1000);
m = Math.floor(s / 60);
s = s % 60;
h = Math.floor(m / 60);
m = m % 60;
d = Math.floor(h / 24);
h = h % 24;
return { d: d, h: h, m: m, s: s };
ijt / http_get.go
Last active August 23, 2021 12:37
Example of using http.Get in go (golang)
package main
import (
remino / datediff.js
Created January 5, 2012 06:07
JavaScript: DateDiff & DateMeasure: Calculate days, hours, minutes, seconds between two Dates
(function() {
function DateDiff(date1, date2) {
this.days = null;
this.hours = null;
this.minutes = null;
this.seconds = null;
this.date1 = date1;
this.date2 = date2;

##Fixing npm permissions

You may receive an EACCES error when you try to install a package globally. This indicates that you do not have permission to write to the directories that npm uses to store global packages and commands.

You can fix this problem using one of three options:

Change the permission to npm's default directory. Change npm's default directory to another directory. Install Node with a package manager that takes care of this for you. You should back-up your computer before moving forward.

jakemmarsh / directives.js
Created June 26, 2013 14:18
AngularJS directive to create a functional "back" button
app.directive('backButton', function(){
return {
restrict: 'A',
link: function(scope, element, attrs) {
element.bind('click', goBack);
function goBack() {