Skip to content

Instantly share code, notes, and snippets.

Bacon = require 'Bacon'
_ = require 'underscore'
$ = require 'jquery'
# Reference: http://unixpapa.com/js/key.html
# IE = IE keycodes (webkit, IE)
# MZ = Mozilla keycodes (gecko)
# Opera = Opera keycodes (opera)
# US locale specific. About as well as can be done without browser detection.
@shameerc
shameerc / .htaccess
Last active August 29, 2015 14:12 — forked from ScottPhillips/.htaccess
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
<?php
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 20000))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Error: " . $_FILES["file"]["error"] . "<br />";
}
--Do not remove this if you are using--
Original Author: Remiz Rahnas
Original Author URL: http://www.htmlremix.com
Published date: 2008/09/24
Changes by Nick Fetchak:
- IE8 standards mode compatibility
- VML elements now positioned behind original box rather than inside of it - should be less prone to breakage
Published date : 2009/11/18
$load = sys_getloadavg();
if ($load[0] > 80) {
header('HTTP/1.1 503 Too busy, try again later');
die('Server too busy. Please try again later.');
}
/*
This is a function which returns three samples of the “load” on a system. Load is the number of processes in the system run queue. The 3 items in the array are the average load for the past 1, 5 and 15 minutes. The PHP Manual shows a great usage of this:
*/
//for a number of classes to load automatically
//We can define the following function in our file
function __autoload($class_name)
{
$path = str_replace("_", "/", $class_name);
require_once $path.".php";
}
if(navigator.appName=="Microsoft Internet Explorer" ) {
return false;
}
else {
return this.init(canvasId,displayRadius,skinId,showSecondHand,gmtOffset);
}
@shameerc
shameerc / gist:662115
Created November 4, 2010 04:02
Avoid double encoding special characters
//Use the fourth argument as false
echo htmlentities($foo, ENT_COMPAT, 'UTF-8',false);
@shameerc
shameerc / pdo_conn_select.php
Created November 10, 2010 07:24
PHP Pdo class
<?
$dsn = 'mysql:dbname=test;host=hostname';
$user = 'username';
$password = 'Password';
try {
$dbh = new PDO($dsn, $user, $password);
echo "Connected";
} catch (PDOException $e) {
echo 'Connection failed: ' . $e->getMessage();
}
@shameerc
shameerc / simple_labda.php
Created December 2, 2010 04:04
basic example for lambda function
<?php
$sum = function($a,$b){
return $a+$b;
};
echo $sum(2,5);
?>