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
// Cross-browser object.watch and object.unwatch | |
// object.watch | |
if (!Object.prototype.watch) { | |
Object.prototype.watch = function (prop, handler) { | |
var oldval = this[prop], newval = oldval, | |
getter = function () { | |
return newval; | |
}, | |
setter = function (val) { |
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
var car_options = 0x5; // binary 0101 | |
var LEATHER_SEATS = 0x1; // 0001 | |
var TURBO = 0x2; // 0010 | |
var HID_LIGHTS = 0x4; // 0100 | |
var SPORT_KIT = 0x8; // 1000 | |
var daves_car = LEATHER_SEATS | HID_LIGHTS | SPORT_KIT; // 0001 | 0100 | 1000 => 1011 // 1 + 4 + 8 = 13 |
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
# INSTRUCTIONS: save in ~/.profile or some other profile-based load script for your distro | |
# Credit: http://gitimmersion.com/lab_11.html | |
alias gs='git status ' | |
alias ga='git add ' | |
alias gb='git branch ' | |
alias gc='git commit' | |
alias gd='git diff' | |
alias go='git checkout ' | |
alias gk='gitk --all&' | |
alias gx='gitx --all' |
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
Array.prototype.indexOf = function(obj, start) { | |
for (var i = (start || 0), j = this.length; i < j; i++) { | |
if (this[i] === obj) { return i; } | |
} | |
return -1; | |
} |
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
_ = require "lodash" | |
rest = (opts) -> | |
# simple prefix, ie http://localhost:1337/api/:collection/:id? | |
@prefix = '/api' | |
@path = null | |
@key = 'collection' |
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.well.commitment-modal | |
div.panel.panel-success | |
div.panel-heading | |
h2.panel-title Commitment Overview | |
div.panel-body |
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
[core] | |
autocrlf = false | |
[push] | |
default = upstream | |
[i18n] | |
filesEncoding = utf-8 | |
[color] | |
branch = auto | |
diff = auto | |
status = auto |
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
/* | |
Credit and Source: https://www.owasp.org/index.php/OWASP_Validation_Regex_Repository | |
*/ | |
'use strict'; | |
module.exports = { | |
url: /^((((https?|ftps?|gopher|telnet|nntp):\/\/)|(mailto:|news:))(%[0-9A-Fa-f]{2}|[-()_.!~*';\/?:@&=+$,A-Za-z0-9])+)([).!';\/?:,][[:blank:]])?$/, | |
ip: /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/, | |
email: /^[a-zA-Z0-9+&*-]+(?:\.[a-zA-Z0-9_+&*-]+)*@(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,7}$/, | |
safeText: /^[a-zA-Z0-9 .-]+$/, | |
date: /^(?:(?:(?:0?[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0?[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:0?2(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0?[1-9])|(?:1[0-2]))(\/|-|\.)(?:0?[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/, |
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
var roles = {'admin': 8, 'user': 1, 'powerUser': 4 }, | |
user = {role: 12}; // 4 + 8 | |
function hasRoleName(chkRole) { | |
chkRole = typeof(chkRole) === 'string' ? [chkRole] : chkRole; | |
var roleSum = chkRole.reduce(function(last, curr, idx, list) { return last + (roles[list[idx]] || 0); }, 0); | |
return hasAnyRolesBit(roleSum); | |
} | |
function hasAllRolesBit(roleSum) { | |
return (roleSum & user.role) >= roleSum; // must match all bits! | |
} |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
OlderNewer