Skip to content

Instantly share code, notes, and snippets.

View mailtruck's full-sized avatar
👨‍✈️

Brian Danowski mailtruck

👨‍✈️
  • Ferndale, MI
View GitHub Profile

shiminy: minimal es5-shim

Looking at the ES5 compatibility table, several browsers provide everything often used (i. e. not Object.freeze() and friends) except Function.prototype.bind. So I just inline that. Browsers that don't provide other functions also don't include Object.getOwnPropertyNames, so I used it as my test for including the entire shim.

Note that I haven't tested it yet, and it doesn't work for the six Object functions next to each other in the Safari 5 part of the compatibility chart (Safari 5 is deemed good enough).

Update: I added JSON for IE <= 7. JSON is used in a good number of node.js modules.

@mailtruck
mailtruck / colormeter.js
Created April 18, 2012 07:09 — forked from krypton/colormeter.js
Calculate difference in percentage between 2 hex colors
function color_meter(cwith, ccolor) {
if (!cwith && !ccolor) return;
var _cwith = (cwith.charAt(0)=="#") ? cwith.substring(1,7) : cwith;
var _ccolor = (ccolor.charAt(0)=="#") ? ccolor.substring(1,7) : ccolor;
var _r = parseInt(_cwith.substring(0,2), 16);
var _g = parseInt(_cwith.substring(2,4), 16);
var _b = parseInt(_cwith.substring(4,6), 16);
<?php
$provider = new stdClass;
$provider->disabled = FALSE; /* Edit this to true to make a default provider disabled initially */
$provider->name = 'twitter';
$provider->title = 'Twitter';
$provider->url = 'http://api.twitter.com';
$provider->consumer_advanced = array(
'signature method' => 'HMAC-SHA1',
'request token endpoint' => '/oauth/request_token',
'authorization endpoint' => '/oauth/authenticate',
@mailtruck
mailtruck / readme.md
Created April 23, 2012 03:53 — forked from chriseppstein/readme.md
How to integrate Compass with Rails 3.1 asset pipeline

This gist is no longer valid. Please see Compass-Rails for instructions on how to install.

@mailtruck
mailtruck / StripeTutorialPage.html
Created May 2, 2012 16:37 — forked from boucher/StripeTutorialPage.html
Stripe Tutorial Payment Form
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Stripe Getting Started Form</title>
<script type="text/javascript" src="https://js.stripe.com/v1/"></script>
<!-- jQuery is used only for this example; it isn't required to use Stripe -->
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript">
// this identifies your website in the createToken call below
<VirtualHost *>
Servername whoahbot.example.com
DocumentRoot /var/www
RewriteEngine On
RewriteRule ^/http-bind/ http://jabber.example.com:5280/http-bind/ [P]
</VirtualHost>
@mailtruck
mailtruck / LICENSE.txt
Created June 27, 2012 13:42 — forked from jed/LICENSE.txt
polyfill requestAnimationFrame across browsers
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Jed Schmidt <http://jed.is>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@mailtruck
mailtruck / client.js
Created July 11, 2012 07:56 — forked from anildigital/client.js
Twitter streaming API example twitter-node and socket.io
<!DOCTYPE HTML>
<head>
<title>Codesnippit NodeJS Twitter Tracker Client</title>
</head>
<body>
<ul></ul>
<script>
(function() {
var script = document.createElement("script");
script.src = "http://code.jquery.com/jquery.min.js";
@mailtruck
mailtruck / ClickToSplit.js
Created October 4, 2012 23:22 — forked from clauswitt/ClickToSplit.js
Click to Split
function onclick(e) {
var range;
if (document.caretRangeFromPoint) {
range = document.caretRangeFromPoint(e.pageX, e.pageY);
} else if (e.rangeParent) {
range = document.createRange();
range.setStart(e.rangeParent, e.rangeOffset);
}
var textContainer = range.startContainer;
@mailtruck
mailtruck / app.js
Created October 9, 2012 00:45 — forked from prognostikos/app.js
AngularJS & Rails
/**
* Angular needs to send the Rails CSRF token with each post request.
*
* Here we get the token from the meta tags (make sure <%= csrf_meta_tags %>
* is present in your layout.)
*/
angular.module('myapp',[]).
// configure our http requests to include the Rails CSRF token
config(["$httpProvider", function(p) {
var m = document.getElementsByTagName('meta');