This file contains hidden or 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
// deep _.pluck/_.map combined with a _.compact | |
_.mixin({ | |
extract: function(object, predicate, values) { | |
values = _.isArray(values) ? values : []; | |
_.each(object, function(value, key, hash) { | |
if (_.isObject(value)) { | |
_.extract(hash[key], predicate, values); | |
} |
This file contains hidden or 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
Show hidden characters
{ | |
"folders": | |
[ | |
{ | |
"path": "." | |
} | |
], | |
"virtualenv": "$project_path", | |
"build_systems": [ | |
{ |
This file contains hidden or 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
$pip_file = "requirements.txt" | |
try { | |
pip freeze > $pip_file | |
# PowerShell creates UTF16 LE with Windows line endings so we must convert | |
# for pip to consume | |
# http://stackoverflow.com/questions/8852682/convert-file-from-windows-to-unix-through-powershell-or-batch | |
Get-ChildItem $pip_file | ForEach-Object { | |
$contents = [IO.File]::ReadAllText($_) -replace "`r`n?", "`n" |
This file contains hidden or 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 NormalizeString(Optional ByVal value As Variant) As String | |
If value = vbNullString Then | |
NormalizeString = "" | |
Else | |
NormalizeString = StrConv(value, vbUpperCase) | |
End If | |
End Function | |
Function getPhoneDigit(Optional ByVal value As Variant) As Variant | |
getPhoneDigit = NormalizeString(value) |
This file contains hidden or 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 checkOption = function(optionName) { | |
return process.argv.some(function(option) { | |
if (option.indexOf("--", 0) === 0 && optionName) { | |
return option.substr(2).toLowerCase() === optionName.toLowerCase(); | |
} | |
return false; | |
}); | |
}; |
This file contains hidden or 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
// a1Foo => a1_foo | |
function getRange(start, end) { | |
return [start.charCodeAt(0), end.charCodeAt(0)]; | |
} | |
function inRange(value, start, end) { | |
return value >= start && value <= end; | |
} |
This file contains hidden or 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 Stats(data, precision) { | |
var PRECISION = precision || 2; | |
var length = data.length; | |
var mean = (function() { | |
var sum = data.reduce(function(a, b) { | |
return a + b; | |
}, 0); | |
return sum / length; | |
})(); |
This file contains hidden or 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 getPath(object, path) { | |
if (typeof object === 'undefined' || typeof path !== 'string') { | |
return undefined; | |
} | |
var index = path.trim().indexOf('.'); | |
if (index < 0) { | |
return object[path]; | |
} |
This file contains hidden or 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 findBalancePoint(array) { | |
if (array.length === 0) { | |
return 0; | |
} | |
if (array.length === 1) { | |
return 1; | |
} | |
// initial sums | |
var left = 0; | |
var right = 0; |
This file contains hidden or 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(Factory, Lorem, underscore) { | |
var SHA_CHARS = "0123456789abcdef"; | |
var ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; | |
var CATEGORIES = ["Low", "Medium", "High"]; | |
var ONE_YEAR_IN_MILLISECONDS = 31536000000; | |
var _ = underscore; | |
var methods; | |
// http://www.ssa.gov/oact/babynames/decades/century.html | |
var FIRST_NAME = ["James", "John", "Robert", "Michael", "William", "David", "Richard", "Joseph", "Charles", "Thomas", "Christopher", "Daniel", "Matthew", "Donald", "Anthony", "Mark", "Paul", "Steven", "George", "Kenneth", "Mary", "Patricia", "Jennifer", "Elizabeth", "Linda", "Barbara", "Susan", "Margaret", "Jessica", "Sarah", "Dorothy", "Karen", "Nancy", "Betty", "Lisa", "Sandra", "Ashley", "Kimberly", "Donna", "Helen"]; | |
// https://en.wikipedia.org/wiki/List_of_most_common_surnames_in_North_America |