Skip to content

Instantly share code, notes, and snippets.

View philfreo's full-sized avatar

Phil Freo philfreo

View GitHub Profile
@philfreo
philfreo / gist:9241308
Created February 26, 2014 23:49
Einstein's favorite limerick
There was an old lady called Wright
who could travel much faster than light.
She departed one day
in a relative way
and returned on the previous night.
@philfreo
philfreo / gruntfile.js
Created July 17, 2014 20:28
grunt require.js view filesize of each dependency
options: {
done: function(done, output) {
// this callback is simply used to print the file sizes of each dependency so you
// can see which ones should considered for elimination
var lines = output.split('\n').slice(3, -1);
var filesWithSizes = [];
lines.forEach(function(line) {
filesWithSizes.push({ size: getFilesizeInBytes(line), file: line });
});
@philfreo
philfreo / gist:cbab6aad493a6a3c21e8
Last active August 29, 2015 14:08
SMTP & IMAP details for popular email services

IMAP

Gmail/Google Apps:

Host: imap.gmail.com
Port: 993
Username: youremail@gmail.com or youremail@yourdomain.com (Google Apps)
Password: Your email password
SSL: Yes
@philfreo
philfreo / keybase.md
Created May 21, 2015 18:18
keybase.md

Keybase proof

I hereby claim:

  • I am philfreo on github.
  • I am philfreo (https://keybase.io/philfreo) on keybase.
  • I have a public key whose fingerprint is 1F81 B578 6E87 8A29 B28B 4578 2DCA C2F7 8DAA 538B

To claim this, I am signing this object:

// ==UserScript==
// @name Gmail "From" Address auto-selector
// @version 0.18
// @description Looks in your "To" field and sees if you have an email address in your "From" addresses with the same domain. Changes <select> onblur
// @author Andrew Sutherland, https://github.com/asuth
// @include http://mail.google.com/*
// @include https://mail.google.com/*
// @include http://*.mail.google.com/*
// @include https://*.mail.google.com/*
// ==/UserScript==
@philfreo
philfreo / class.cconvert.js
Created June 4, 2011 01:01
Chinese Simplified<->Traditional Converter (PHP)
//Edited by 168funpc
var Default_isFT = 0 //ĬÈÏÊÇ·ñ·±Ì壬0-¼òÌ壬1-·±Ìå
var StranIt_Delay = 50 //·­ÒëÑÓʱºÁÃ루ÉèÕâ¸öµÄÄ¿µÄÊÇÈÃÍøÒ³ÏÈÁ÷³©µÄÏÔÏÖ³öÀ´£©
//£­£­£­£­£­£­£­´úÂ뿪ʼ£¬ÒÔϱð¸Ä£­£­£­£­£­£­£­
//ת»»Îı¾
function StranText(txt,toFT,chgTxt)
{
if(txt==""||txt==null)return ""
@philfreo
philfreo / utf8.php
Created June 24, 2011 19:25
Convert between Unicode code points and UTF-8
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
@philfreo
philfreo / model.js
Last active October 6, 2015 21:37
Backbone Model mutators / computed properties
var Model = Backbone.Model.extend({
/**
* Override main attribute getter to handle mutators.
* Looks for an object on the model called 'mutators', keyed by key name,
* with values of either the getter function or an object like:
* { get: function() {}, set: function() {} }
*/
get: function(attr) {
var val,
@philfreo
philfreo / gist:3148064
Created July 20, 2012 01:21 — forked from mattheworiordan/gist:1037984
Backbone patch to defer update method requests when new create requests are not complete on a model
// Queue of Backbone.Model save()s so that we don't issue multiple POSTs while waiting for
// the first one to come back. The first save() will always POST and the second will always PUT now.
// https://github.com/documentcloud/backbone/issues/345
// https://gist.github.com/1037984 and https://gist.github.com/gists/3148064
(function() {
function proxyAjaxEvent(event, options, dit) {
var eventCallback = options[event];
options[event] = function() {
// check if callback for event exists and if so pass on request
if (eventCallback) { eventCallback(arguments) }