- SOLID principles http://en.wikipedia.org/wiki/SOLID_(object-oriented_design)
- Cuurly's Law: Do One Thing http://www.codinghorror.com/blog/2007/03/curlys-law-do-one-thing.html
- The Open-Closed Principle, in review http://msmvps.com/blogs/jon_skeet/archive/2013/03/15/the-open-closed-principle-in-review.aspx
- Refactoring: Improving the Design of Existing Code http://www.cs.umss.edu.bo/doc/material/mat_gral_137/M.Fowler%20et%20al%20-%20Refactoring%20-%20Improving%20the%20Design%20of%20Existing.pdf
- Patterns of Enterpise Application Architecture http://martinfowler.com/books/eaa.html
- Smalltalk Best Practice Patterns https://www.goodreads.com/book/show/781561.SmallTalk_Best_Practice_Patterns
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
# | |
# 2011-04-18 Changed from client.up.tunnelblick.sh to client.3.up.tunnelblick.sh and to use leasewatch3 | |
trap "" TSTP | |
trap "" HUP | |
trap "" INT | |
export PATH="/bin:/sbin:/usr/sbin:/usr/bin" | |
# Process optional arguments (if any) for the script |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# USAGE: | |
# | |
# Inside a bitbucket repo (remote must be origin) call: | |
# | |
# bb -> Go to overview page | |
# bbs <branch> -> Go to branch source. Defaults to master | |
# bbc <commit> -> Go to commit diff. Defaults to HEAD | |
# bbp -> Go to pull requests page | |
# bbnp -> New pull reques form | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Completions for npmenv.fish | |
function __fish_npmenv_needs_command | |
set cmd (commandline -opc) | |
if [ (count $cmd) -eq 1 -a $cmd[1] = 'npmenv' ] | |
return 0 | |
end | |
return 1 | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from "react"; | |
import PropTypes from "prop-types"; | |
import ReactDOM from 'react-dom'; | |
// Toy redux ---------------------------------------------------------- | |
const createStore = (reducer, initialState) => { | |
let state = initialState; | |
let subscribers = []; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const callbackify = fn => (...args) => { | |
const callback = args[args.length - 1]; | |
const fnArgs = args.slice(0, -1); | |
fn(...fnArgs) | |
.then(value => { | |
callback(undefined, value); | |
}) | |
.catch(error => { | |
callback(error); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const jwt = require("jsonwebtoken"); | |
const verifyToken = token => new Promise((resolve, reject) => { | |
jwt.verify(token, CERTIFICATE, { algorithms: ["RS256"] }, (error, payload) => { | |
if (error) { | |
reject(error); | |
} else { | |
resolve(payload); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const usefulFunction = async () => { | |
try { | |
const payload = await verifyToken(token); | |
return payload; | |
} catch(e) { | |
console.error("Bad token", e); | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const jwt = require("jsonwebtoken"); | |
const promisify = fn => (...args) => new Promise((resolve, reject) => { | |
fn(...args, (error, value) => { | |
if (error) { | |
reject(error); | |
} else { | |
resolve(value); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { promisify } = require("util"); | |
const jwt = require("jsonwebtoken"); | |
const jwtVerify = promisify(jwt.verify); | |
const verifyToken = token => jwtVerify(token, CERTIFICATE, { algorithms: ["RS256"] }); |
OlderNewer