Skip to content

Instantly share code, notes, and snippets.

View MikeRogers0's full-sized avatar
🚂

Mike Rogers MikeRogers0

🚂
View GitHub Profile
@MikeRogers0
MikeRogers0 / aoc_2020_day_9.rb
Created December 10, 2020 11:16
Advent Of Code 202 - day 9
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
@MikeRogers0
MikeRogers0 / aoc_day_4_part_two.rb
Last active December 4, 2020 10:39
Advent Of Code - Day 4 (Part two) - Ruby
passports = File.open('input.txt').read.split("\n\n")
class Passport
REQUIRED_FIELDS = %w[
byr
iyr
eyr
hgt
hcl
ecl
@MikeRogers0
MikeRogers0 / setup_puma_dev.local
Created September 23, 2017 13:58
Setup Puma Dev
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
@MikeRogers0
MikeRogers0 / backup-to-s3.sh
Last active May 19, 2020 15:33
A method of backing up your website to Amazon S3.
#!/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
@MikeRogers0
MikeRogers0 / .dockerignore
Last active April 9, 2020 12:52
Docker Setup for AWS Beanstalk
.git
.gitignore
README.md
#
# OS X
#
.DS_Store
.AppleDouble
.LSOverride
@MikeRogers0
MikeRogers0 / resize-image.js
Last active September 17, 2019 12:07
An example of how to resize an image on the fly with javascript.
// 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"),
@MikeRogers0
MikeRogers0 / weather-class.inc.php
Created June 16, 2012 17:04
Getting the Weather in PHP
<?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;
 }

@MikeRogers0
MikeRogers0 / twitter-proxy.php
Last active June 3, 2019 12:56
This is a neat little script you can use to quickly make OAuth requests to the twitter rest API v1.1.
<?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(
@MikeRogers0
MikeRogers0 / scopes.php
Last active November 19, 2018 01:25 — forked from tomoakley/PHP Variable Scope with Wordpress shortcode attributes
PHP Variable Scope with Wordpress shortcode attributes
<?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" => ''
$ 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 :(