Skip to content

Instantly share code, notes, and snippets.

View reinink's full-sized avatar

Jonathan Reinink reinink

View GitHub Profile
@reinink
reinink / gist:1392767
Created November 25, 2011 03:42
PHP wrapper for Google Weather API
<?php
class Google_Weather
{
public $condition;
public $temperature;
public $humidity;
public $icon;
public $wind_direction;
public $wind_speed;
@reinink
reinink / gist:1467201
Created December 12, 2011 13:41
Example of how to parse HTML document with phpQuery
<?php
// Include the phpQuery library
// Download at http://code.google.com/p/phpquery/
include 'phpQuery.php';
// Load Mike Fisher's player page on thescore.com
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.thescore.com/nhl/player_profiles/859-mike-fisher');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@reinink
reinink / gist:1472117
Created December 13, 2011 13:22
Make mobile browsers display websites at their native resolution
<meta name="viewport" content="width=device-width, initial-scale=1.0">
@reinink
reinink / less.html
Created December 30, 2011 15:12
Use less.js in development mode with watch (auto-reload) enabled
<link rel="stylesheet/less" type="text/css" href="styles.less">
<script type="text/javascript">
/* Put Less in development mode */
less = {};
less.env = 'development';
</script>
<script src="less.js"></script>
<script type="text/javascript">
/* Enable Less auto reloading */
less.watch();
@reinink
reinink / index.html
Last active September 29, 2015 05:48
Base HTML5 document.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="style.css">
</head>
<body>
@reinink
reinink / gist:1645193
Created January 20, 2012 04:27
PHP function to calculate age
<?php
function calculate_age($birthday)
{
$today = new DateTime();
$diff = $today->diff(new DateTime($birthday));
if ($diff->y)
{
return ($diff->y == 1) ? $diff->y . ' year' : $diff->y . ' years';
@reinink
reinink / gist:1680575
Created January 26, 2012 02:29
Typical .htaccess index.php rewrite
# Route all requests through index.php
<IfModule mod_rewrite.c>
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
@reinink
reinink / gist:1683466
Created January 26, 2012 15:58
Remove yellow background caused by Google Chrome autocomplete
if (navigator.userAgent.toLowerCase().indexOf("chrome") >= 0)
{
$(window).load(function()
{
setTimeout(function()
{
$('input:-webkit-autofill').each(function()
{
var text = $(this).val();
var name = $(this).attr('name');
@reinink
reinink / search_and_replace.sql
Created April 23, 2012 16:09
Search and replace within a MySQL database
UPDATE TableName set FieldName = replace(FieldName, 'find string', 'replace string')
@reinink
reinink / php-headers.php
Created April 27, 2012 00:36
PHP header examples
<?php
// Source: http://www.jonasjohn.de/snippets/php/headers.htm
// Use this header instruction to fix 404 headers
// produced by url rewriting...
header('HTTP/1.1 200 OK');
// Page was not found:
header('HTTP/1.1 404 Not Found');