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 formatDuration (seconds) { | |
// Complete this function | |
if (seconds === 0) return 'now'; | |
var calc = { | |
years: {time: 60*60*24*365, str: 'year'}, | |
days: {time: 60*60*24, str: 'day'}, | |
hours: {time: 60*60, str: 'hour'}, | |
mins: {time: 60, str: 'minute'} | |
}, duration = []; |
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 prime(num) { | |
var primes = [], | |
i, j; | |
if (num < 2) return []; | |
for (i = 2; i <= num; i++) { primes[i] = true; } | |
for (i = 2; i <= Math.floor(Math.sqrt(num)); i++) { | |
var n = 0; |
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 tongues(code) { | |
var vowels = ['a', 'i', 'y', 'e', 'o', 'u'], | |
consonants = ['b', 'k', 'x', 'z', 'n', 'h', 'd', 'c', 'w', 'g', 'p', 'v', 'j', 'q', 't', 's', 'r', 'l', 'm', 'f']; | |
return code.split('').map(function(l) { | |
var v = vowels.indexOf(l.toLowerCase()), | |
c = consonants.indexOf(l.toLowerCase()), | |
letter = l; | |
if (v !== -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
/** | |
* @param {Number} length (optional) Number of UUIDs to generate | |
* @return {String|Array} UUID(s) | |
*/ | |
generateUuid: function(length) { | |
var uuids = length ? [] : null, | |
uuid, | |
generate = function() { | |
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { |
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
/** | |
* Defines the start point of a debugging section | |
* @param {string} what Decription of debug section [optional] | |
* @example | |
* console.beginDebugging(); // Will try to use the function name as description | |
* console.beginDebugging('my method'); // Uses 'my method' as description | |
*/ | |
console.beginDebugging = function beginDebugging(what) { | |
var caller = console.beginDebugging.caller, | |
title; |
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
String.prototype.capitalizeFirstLetter = function capitalizeFirstLetter() { | |
return this[0].toUpperCase() + this.slice(1); | |
}; | |
String.prototype.capitalizeAllWords = function capitalizeAllWords() { | |
return this.replace(/(^| )\w/g, function(match) { | |
return match.toUpperCase(); | |
}); | |
}; |
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
#!/usr/bin/env ruby -w | |
FORBIDDEN = [ | |
/(?<!\/\/\s)console\.log/, | |
/(?<!\/\/\s)console\.debug/, | |
/(?<!\/\/\s)echo print_r/, | |
/\bdo not commit\b/i | |
] | |
full_diff = `git diff --cached --` |
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/sh | |
files=$(git diff --cached --name-only --diff-filter=ACM | grep ".js$") | |
if [ "$files" = "" ]; then | |
exit 0 | |
fi | |
pass=true | |
for file in ${files}; do |
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 | |
SCRIPTPATH=`git rev-parse --show-toplevel`"/.git/hooks" | |
HOOKS="${SCRIPTPATH}/pre-commit-*" | |
shopt -s nullglob | |
pass=true | |
for hook in $HOOKS |
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
{ | |
"important": true, | |
"adjoining-classes": true, | |
"known-properties": true, | |
"box-sizing": false, | |
"box-model": true, | |
"overqualified-elements": true, | |
"display-property-grouping": true, | |
"bulletproof-font-face": true, | |
"compatible-vendor-prefixes": true, |
OlderNewer