Skip to content

Instantly share code, notes, and snippets.

@fj-auto
fj-auto / Middleware.js
Created July 7, 2022 06:55 — forked from unbug/Middleware.js
Powerful Javascript Middleware Pattern Implementation, apply middleweares to any object. https://unbug.github.io/js-middleware/
'use strict';
/* eslint-disable consistent-this */
let middlewareManagerHash = [];
/**
* Composes single-argument functions from right to left. The rightmost
* function can take multiple arguments as it provides the signature for
* the resulting composite function.
*

CLI - Command line interface:

A utility in your computer that you use to type commands rather than using your mouse. That's what it all means. Examples are Terminal on Mac, Command Prompt on Windows etc.

This is the way things used to be in old school days.

Working with NodeJS will require CLI's usage mostly.

Arguments

@fj-auto
fj-auto / MySQL_macOS_Sierra.md
Created November 2, 2021 08:42 — forked from nrollr/MySQL_macOS_Sierra.md
Install MySQL on Sierra using Homebrew

Install MySQL on macOS Sierra

This procedure explains how to install MySQL using Homebrew on macOS Sierra 10.12

Install Homebrew

  • Installing Homebrew is effortless, open Terminal and enter :
    $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • Note: Homebrew will download and install Command Line Tools for Xcode 8.0 as part of the installation process.

Install MySQL

At this time of writing, Homebrew has MySQL version 5.7.15 as default formulae in its main repository :

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
@fj-auto
fj-auto / gist:48bb379cd1510be2f066d5bf22eee9ed
Created February 2, 2017 06:57
`brew install node` can't symlink notes
sudo chown -R `whoami`:admin /usr/local/bin
sudo chown -R `whoami`:admin /usr/local/share
@fj-auto
fj-auto / gist:6d86b31f114e4b2314280219983ad7f5
Created February 2, 2017 06:25 — forked from tonymtz/gist:d75101d9bdf764c890ef
Uninstall nodejs from OSX Yosemite
# first:
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/${f}; done
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
# To recap, the best way (I've found) to completely uninstall node + npm is to do the following:
# go to /usr/local/lib and delete any node and node_modules
cd /usr/local/lib
sudo rm -rf node*
@fj-auto
fj-auto / angularjs$q.js
Created March 23, 2016 03:13
angularJS $q Promise
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.min.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body ng-app="app">
<div ng-controller="mainController">
@fj-auto
fj-auto / js-challenges-SIF.js
Created February 24, 2016 03:41
[js-challenges-book] Self Invoking Functions 答案
var testValue;
function test() {
testValue = 3;
}();
// 问题1:
// 答案 =>
//
@fj-auto
fj-auto / scale.js
Last active February 2, 2016 10:29
移动Web伸缩方案
(function() {
var dpr, rem, scale,
resize = 'orientationchange' in window ? 'orientationchange' : 'resize',
docElem = document.documentElement,
fontElem = document.createElement('style'),
metaElem = document.querySelector('meta[name="viewport"]');
dpr = docElem.clientWidth >= 540 ? 1 : window.devicePixelRatio || 1;
rem = docElem.clientWidth * dpr / 10;
scale = 1 / dpr;
@fj-auto
fj-auto / dpr.js
Last active April 23, 2020 04:22
移动端web伸缩方案
var dpr, rem, scale,
docElem = document.documentElement,
fontElem = document.createElement('style'),
metaElem = document.querySelector('meta[name="viewport"]');
dpr = window.devicePixelRatio || 1; // 获取屏幕dpi, default设为1
rem = docElem.clientWidth * dpr / 10; // 根据屏幕宽度和dpr来动态计算base 'rem' font-size, 取10是为了好计算
scale = 1 / dpr; // 不用再傻傻的拿[设计稿/2];
// 同时也处理retina屏幕下border: 1px的情况;