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
The prime factors of 13195 are 5, 7, 13 and 29. | |
What is the largest prime factor of the number 600851475143? | |
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 isPrime(number) { | |
var index; | |
var limit = Math.ceil(Math.sqrt(number)); | |
// since the main loop generates odd numbers only | |
// we can start testing primality dividing by 3 | |
for (index = 3; index <= limit; index += 2) { | |
if (number % index === 0) { | |
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
// _.propertyOf along with any other underscore (i.e. _.isObject) to check if something was available instead of | |
// doing an undefined and null check. | |
_.isObject(_.propertyOf(data.prop)("prop")); | |
// _.propertyOf returns a function so you can also assign that to a variable and then use it later as well | |
var dataPropOf = _.propertyOf(data.prop); | |
_.isObject(dataPropOf("prop")); | |
// The exact same technique can be used if the property was an array: |
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
#!/bin/bash | |
# Include any branches for which you wish to disable this script | |
if [ -z "$BRANCHES_TO_SKIP" ]; then | |
BRANCHES_TO_SKIP=(master develop test) | |
fi | |
# Get the current branch name and check if it is excluded | |
BRANCH_NAME=$(git symbolic-ref --short HEAD) | |
BRANCH_NAME="${BRANCH_NAME##*/}" |
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
#!/bin/bash | |
# Include any branches for which you wish to disable this script | |
if [ -z "$BRANCHES_TO_SKIP" ]; then | |
BRANCHES_TO_SKIP=(master develop test) | |
fi | |
# Get the current branch name and check if it is excluded | |
BRANCH_NAME=$(git symbolic-ref --short HEAD) | |
BRANCH_NAME="${BRANCH_NAME##*/}" |
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
/* A Queue object for queue-like functionality over JavaScript arrays. */ | |
var Queue = function() { | |
this.items = []; | |
}; | |
Queue.prototype.enqueue = function(obj) { | |
console.log("enqueue: ", obj); | |
this.items.push(obj); | |
}; | |
Queue.prototype.dequeue = function() { | |
return this.items.shift(); |
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
#!/bin/sh | |
# Apps | |
apps=( | |
# System Plugins | |
# flash | |
java | |
# silverlight | |
# alfred |
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
#!/bin/sh | |
binaries=( | |
ack | |
# Install Bash 4 | |
bash | |
bash-completion | |
# Install GNU core utilities (those that come with OS X are outdated) | |
coreutils | |
ffmpeg |
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
#!/bin/bash | |
# Check for Homebrew, | |
# Install if we don't have it | |
if test ! $(which brew); then | |
echo "Installing homebrew..." | |
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" | |
fi | |
# Update homebrew recipes |
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
#!/bin/sh | |
# fonts | |
fonts=( | |
font-m-plus | |
font-clear-sans | |
font-roboto | |
) | |
# install fonts |