Skip to content

Instantly share code, notes, and snippets.

View chrismendis's full-sized avatar

Chris Mendis chrismendis

  • Format
  • Toronto, Canada
View GitHub Profile
@chrismendis
chrismendis / prettyTweetDateForTumblr.js
Created December 1, 2010 21:22
Change the dates returned by Tumblr's tweet.js callback to something like 12:00 PM Oct. 27th
var prettyTweetDate = function (tweetDateFromJSON) {
var createDate = Date.parse(tweetDateFromJSON),
tweetDate = new Date(createDate),
tweetDateNum = tweetDate.getDate(),
tweetHours = tweetDate.getHours(),
tweetAMPM = (tweetHours < 12) ? "AM" : "PM",
tweetDateSuffix = "",
prettyTweetDateString = "",
months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
@chrismendis
chrismendis / hosts-sample
Created March 8, 2011 16:13
Example of Virtual Host setup for Apache
127.0.0.1 localhost
127.0.0.1 local.ltsb.mighty.ca
127.0.0.1 local.ltsb.fr.mighty.ca
@chrismendis
chrismendis / facebookSignedRequestToJSON.php
Created April 20, 2011 19:31
Returns a JSON object containing the signed request that Facebook sends to your FB app as a POST variable.
$req = htmlspecialchars($_POST['signed_request']);
$reqParts = split('\.', $req);
$encodedValue = $reqParts[1];
$encodedValue = preg_replace('/\+/', '-', $encodedValue);
$encodedValue = preg_replace('/\//', '_', $encodedValue);
$pad = strlen($encodedValue) % 4;
if ($pad > 0) {
$pad = 4 - $pad;
}
$encodedValue = str_pad($encodedValue, $pad, '=');
@chrismendis
chrismendis / external_interface_hack.as
Created August 22, 2011 21:22
Run arbitrary JavaScript from ActionScript 3
import flash.external.ExternalInterface;
var docTitle:String = ExternalInterface.call("function () {return window.document.title;}");
ExternalInterface.call("alert", "Alerting an Actionscript variable: " + docTitle);
@chrismendis
chrismendis / log_omniture_img_request.bookmarklet.js
Created October 5, 2011 16:53
Log the Omniture image request to the console
javascript:var%20j=document.styleSheets,i=document.images,r='';for(var%20x=0;x<j.length;x++)if(j[x].imports)for(var%20y=0;y<j[x].imports.length;y++)if(j[x].imports[y].href.toLowerCase().indexOf('/b/ss/')>=0)r+=j[x].imports[y].href+"\n\n";for(var%20x=0;x<i.length;x++)if(i[x].src.toLowerCase().indexOf('/b/ss/')>=0)r+=i[x].src+"\n\n";for(w_m%20in%20window)if(w_m.substring(0,4)=='s_i_'&&window[w_m].src)if(window[w_m].src.indexOf('/b/ss/')>=0)r+=window[w_m].src;void(console.info('The%20Omniture%20image%20request%20is\n\n'%20+%20r))
@chrismendis
chrismendis / preventForwardTabbing.coffee
Created February 11, 2013 15:17
Preventing the user from tabbing forward
preventFocusContinuation: (ev) ->
if ev.which == 9 and not ev.shiftKey
ev.preventDefault()
@chrismendis
chrismendis / install-error
Created November 5, 2013 18:17
generator-express-angular installation error
npm ERR! peerinvalid The package generator-karma does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer [email protected] wants generator-karma@~0.6.0
npm ERR! peerinvalid Peer [email protected] wants generator-karma@~0.5.0
npm ERR! peerinvalid Peer [email protected] wants generator-karma@~0.5.0
<!doctype html>
<html lang="en">
<head>
<title>My Web Page</title>
<meta charset="utf-8">
<link href="/stylesheets/main.css" rel="stylesheet">
</head>
<body>
</body>
</html>
@chrismendis
chrismendis / HOWTO.md
Created May 22, 2014 02:34
HOWTO: Contribute to another fork of a repo that you've already forked on Github

NB: This also works for the case where you'd like to contribute to the original repo, but you've already forked a fork of the original repo.

Let johndoe/coolrepo be the name of the fork that you'd like to contribute to.

Let master be the branch of johndoe/coolrepo that you'd like to start working from.

  1. Choose a name for a new remote that you'll use in subsequent steps. Let's use yupstream.
  2. git remote add yupstream [email protected]:johndoe/coolrepo.git
  3. git fetch yupstream master
  4. Choose a name for a new branch that will contain the fork that you'd like to contribute to. Let's use feature/add-to-coolrepo.
@chrismendis
chrismendis / android-ff-height-bug.html
Created May 26, 2014 17:18
Android Firefox 26 Height Issue
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, initial-scale=1, user-scalable=no, minimal-ui">
<link rel="stylesheet" href="http://s.codepen.io/assets/reset/reset.css">
<style media="screen">
html, body {
width: 100%;
}