router <- method + URL
authentication <- middleware
controller <- function/class
request <- object
command <- pattern
validation <- rules
CRUD/search <- models
authorization <- throwing exception
quota <- filter
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
(function ($){ | |
$.fn.wrapInHtml = function (options) { | |
var tags = $.extend({i: {css: 'font-style', | |
val: 'italic'}, | |
b: {css: 'font-weight', | |
val: 'bold'}, | |
u: {css: 'text-decoration', | |
val: 'underline'}}, | |
options); |
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 { Cc, Ci } from 'chrome'; | |
const mediator = Cc['@mozilla.org/appshell/window-mediator;1']; | |
const gBrowser = mediator.getService(Ci.nsIWindowMediator).getMostRecentWindow('navigator:browser').gBrowser; | |
function onLocationChange(aProgress, aRequest, aURI) { | |
console.log(aURI.spec); | |
}; | |
gBrowser.addProgressListener({ onLocationChange }, Ci.nsIWebProgress.NOTIFY_LOCATION); |
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
def indexof(fromstr, substr): | |
f = s = 0 | |
while f < len(fromstr): | |
if fromstr[f] == substr[s]: | |
if s == len(substr) - 1: | |
return f - s | |
s += 1 | |
else: |
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
// <div id="block"></div> | |
// #block { | |
// position: relative; | |
// left: 200px; | |
// width: 40px; | |
// height: 40px; | |
// background-color: #456; | |
// } |
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 axios from 'axios'; | |
import { mapKeys, mapValues, camelCase, snakeCase } from 'lodash'; | |
const { API_URL } = process.env; | |
function getAccessToken() { | |
// @todo: load access token from cookie | |
return 'token'; | |
} |
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 { has } from 'lodash'; | |
// "user" assumed to always represent currently authenticated user | |
// once this assumption isn't sufficient, the politic has to be extended | |
// with something like: | |
// * isCurrentUser(user, currentUser) | |
// * belongsToCurrentUser(user, currentUser, resource) | |
// a "resource" should at least have the "type" attribute for matching purposes | |
// "user" is one possible detalization of a "resource" (e.g. 'const user = {type: "admin", profileId: 1, email: "[email protected]", ...}'), |
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
table = [ | |
{'age': 32, 'gender': 'm', 'country': 'Germany', 'transactions': 4233}, | |
{'age': 23, 'gender': 'f', 'country': 'US', 'transactions': 11223}, | |
{'age': 31, 'gender': 'f', 'country': 'France', 'transactions': 3234}, | |
{'age': 41, 'gender': 'm', 'country': 'France', 'transactions': 2230}, | |
{'age': 19, 'gender': 'm', 'country': 'Germany', 'transactions': 42}, | |
{'age': 21, 'gender': 'f', 'country': 'France', 'transactions': 3315}, | |
{'age': 23, 'gender': 'm', 'country': 'Italy', 'transactions': 520} | |
] |