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/php | |
<?php | |
# Array of the servers you want to ping. | |
$servers = array('mikerogers.io', 'google.com', 'downserver.come'); | |
# PingDomain() from http://stackoverflow.com/a/9843251/445724 | |
function pingDomain($domain){ | |
$start_time = microtime(true); | |
$file = @fsockopen ($domain, 80, $errno, $errstr, 10); | |
$end_time = microtime(true); |
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 | |
echo file_get_contents('http://tinyurl.com/api-create.php?url='.'http://www.example.com/'); | |
/* For example | |
http://tinyurl.com/api-create.php?url=http://www.fullondesign.co.uk/ | |
Would return: | |
http://tinyurl.com/d4px9f | |
*/ | |
?> |
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 sh | |
# | |
# Things I normally install when I first install Homebrew / Homebrew cask | |
# Make sure you've install XCode commandline tools & accepted the terms and conditions before running this. | |
# Homebrew stuff | |
## A nice text editor (Will show how to configure in another post) | |
brew install vim | |
brew install macvim |
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 | |
// Coded by Mike Rogers (http://www.fullondesign.co.uk/) 1st October 2010. | |
function shorten($url, $qr=NULL){ | |
if(function_exists('curl_init')){ | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
curl_setopt($ch, CURLOPT_URL, 'http://goo.gl/api/shorten'); | |
curl_setopt($ch, CURLOPT_POST, TRUE); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, 'security_token=null&url='.urlencode($url)); |
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 | |
function validEmail($email){ | |
// Check the formatting is correct | |
if(filter_var($email, FILTER_VALIDATE_EMAIL) === false){ | |
return FALSE; | |
} | |
// Next check the domain is real. | |
$domain = explode("@", $email, 2); | |
return checkdnsrr($domain[1]); // returns TRUE/FALSE; |
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
@section = File.open('input.real.txt').read.split("\n\n").compact | |
# Get all the rules as ranges (e.g. 0..3), with their names. | |
@rules = @section[0] | |
.split("\n") | |
.collect { |line| | |
line.scan(/(.+): ([0-9\-]+)-([0-9]+) or ([0-9\-]+)-([0-9]+)/ism).flatten | |
} | |
.collect { |name, start_range_1, end_range_1, start_range_2, end_range_2| | |
{ |
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
@section = File.open('input.real.txt').read.split("\n\n").compact | |
# Get all the rules as ranges (e.g. 0..3) | |
@rules = @section[0] | |
.scan(/([0-9\-]+)-([0-9]+)/im) | |
.collect { |start_range, end_range| (start_range.to_i..end_range.to_i) } | |
# Get all the numbers on the nearby tickets | |
@nearby_ticket_numbers = @section[2] | |
.gsub("nearby tickets:\n", '') |
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
@input = [0,12,6,13,20,1,17] | |
@numbers = {} | |
@input.each_with_index do |input, index| | |
@numbers[input] = { count: 1, last_spoken_on: index + 1, last_spoken_before_on: nil } | |
end | |
@last_number_spoken = @input.last | |
@turn_count = @input.length + 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
class Ship | |
def initialize | |
@x = 0 | |
@y = 0 | |
@waypoint_x = 10 | |
@waypoint_y = 1 | |
end | |
def rotate!(direction, degrees_to_turn) | |
puts "Waypoint was: #{current_waypoint}" |
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
@rows = {} | |
File.open('input.real.txt').read.split("\n").compact.each_with_index do |row, index| | |
@rows[index] = {} | |
row.each_char.with_index do |element, element_index| | |
@rows[index][element_index] = element | |
end | |
end | |
@last_row = @rows.keys.last | |
@last_column = @rows[0].keys.last |
NewerOlder