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 number_is_not_sum_of_previous_preamble?(index) | |
numbers = @numbers[(index - 25)...(index)] | |
aim_number = @numbers[index] | |
numbers.each do |number_1| | |
numbers.each do |number_2| | |
combined_number = number_1 + number_2 | |
return true if combined_number == aim_number | |
end | |
end |
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
passports = File.open('input.txt').read.split("\n\n") | |
class Passport | |
REQUIRED_FIELDS = %w[ | |
byr | |
iyr | |
eyr | |
hgt | |
hcl | |
ecl |
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
brew install puma/puma/puma-dev && | |
sudo puma-dev -setup && | |
puma-dev -install && | |
security add-trusted-cert -k login.keychain-db ~/Library/Application\ Support/io.puma.dev/cert.pem |
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 | |
## Email Variables | |
EMAILDATE=`date --date="today" +%y-%m-%d` | |
EMAIL="you@yourdomain.com" | |
SUBJECT="[servername] Backup Script Started! - "$EMAILDATE | |
EMAILMESSAGE="/tmp/emailmessage1.txt" | |
echo "Just to let you know that the backup script has started."> $EMAILMESSAGE | |
/bin/mail -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE |
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
.git | |
.gitignore | |
README.md | |
# | |
# OS X | |
# | |
.DS_Store | |
.AppleDouble | |
.LSOverride |
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
// The function that scales an images with canvas then runs a callback. | |
function scaleImage(url, width, height, liElm, callback){ | |
var img = new Image(), | |
width = width, | |
height = height, | |
callback; | |
// When the images is loaded, resize it in canvas. | |
img.onload = function(){ | |
var canvas = document.createElement("canvas"), |
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
<?php | |
class Weather { | |
public $lat, $long, $weather, $location; | |
private $weather_data, $location_data; | |
| |
public function __construct($lat=0.0, $long=0.0){ | |
$this->lat = (float) $lat; | |
$this->long = (float) $long; | |
} | |
|
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
<?php | |
/** | |
* Usage: | |
* Send the url you want to access url encoded in the url paramater, for example (This is with JS): | |
* /twitter-proxy.php?url='+encodeURIComponent('statuses/user_timeline.json?screen_name=MikeRogers0&count=2') | |
*/ | |
// The tokens, keys and secrets from the app you created at https://dev.twitter.com/apps | |
$config = array( |
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
<?php | |
// I have a function, embedVine(), which is a Wordpress shortcode. It uses one attribute, $id which I've assigned to $vine_id to avoid confusion ($post_id etc). This shortcode takes the ID (Vine IDs are the ending of the Vine URL, e.g http://vine.co/v/hx9LlrZxdqV, the id = hx9LlrZxdqV) and embed's the Vine within a Wordpress post. The shortcode markup is [vine id='...']. | |
$vine_id = false; | |
global $vine_id; | |
function embedVine($atts) { | |
global $vine_id; | |
extract(shortcode_atts(array( | |
"id" => '' |
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
$ brew uninstall dart; brew reinstall sass | |
Uninstalling /usr/local/Cellar/dart/2.0.0-dev.59.0... (1,206 files, 348.9MB) | |
dart 1.24.3 1 is still installed. | |
Remove all versions with `brew uninstall --force dart`. | |
==> Reinstalling sass/sass/sass | |
Error: /usr/local/opt/dart not present or broken | |
Please reinstall dart-lang/dart/dart. Sorry :( |