Skip to content

Instantly share code, notes, and snippets.

@WillJW
WillJW / monty-hall.php
Created June 16, 2015 23:03
The Monty Hall Problem
<?php
class MontyHall
{
const CAR = 'Car';
const GOAT = 'Goat';
public $doors;
public $choice;
public function __construct()
@WillJW
WillJW / gist:5a6090a2e0b26afd93ce
Created September 5, 2014 15:08
Upload photo to Twitter
<?php
require '3rdparty/tmhOAuth/tmhOAuth.php';
$connection = new tmhOAuth(array(
'consumer_key' => TWITTER_API_KEY,
'consumer_secret' => TWITTER_API_SECRET,
'user_token' => TWITTER_ACCESS_TOKEN,
'user_secret' => TWITTER_ACCESS_TOKEN_SECRET
));
@WillJW
WillJW / en.js
Created November 2, 2012 19:19
StatsFC widgets internationalisation
var sfc_lang = {
errors: {
'Missing parameters': 'Missing parameters',
'Competition not found': 'Competition not found',
'Team not found': 'Team not found',
'There are no fixtures at the moment': 'There are no fixtures at the moment',
'There is no team form information at the moment': 'There is no team form information at the moment',
'There are no live games at the moment': 'There are no live games at the moment',
'There are no results at the moment': 'There are no results at the moment',
'There are no standings at the moment': 'There are no standings at the moment',
@WillJW
WillJW / progress.php
Created August 2, 2012 10:57
Upload progress bar with PHP & APC
<?php
if (isset($_GET['progress_key'])) {
$status = apc_fetch('upload_' . $_GET['progress_key']);
// Return null if total is empty to avoid divide by zero error below.
if (empty($status['total'])) {
exit;
}
echo ($status['current'] / $status['total'] * 100);