Skip to content

Instantly share code, notes, and snippets.

View johnfmorton's full-sized avatar
⌨️
Making stuff

John F Morton johnfmorton

⌨️
Making stuff
View GitHub Profile
@remy
remy / gist:350433
Created March 31, 2010 14:58
Storage polyfill
if (typeof window.localStorage == 'undefined' || typeof window.sessionStorage == 'undefined') (function () {
var Storage = function (type) {
function createCookie(name, value, days) {
var date, expires;
if (days) {
date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
expires = "; expires="+date.toGMTString();
@amphibian
amphibian / create_ee_thumbs
Created April 13, 2011 20:46
Creates internal thumbnails for images uploaded outside of ExpressionEngine. Requires EE 2.1.4 or later.
<?php
// Change your upload directory ID here.
$upload_dir_id = 2;
$this->EE =& get_instance();
$this->EE->load->library('filemanager');
$files = $this->EE->filemanager->fetch_files($upload_dir_id);
foreach($files->files[$upload_dir_id] as $data)
{
$dir = array('server_path' => $data['relative_path']);
@phaer
phaer / raw_tag.rb
Created June 11, 2011 19:11
Raw tag for jekyll. Keeps liquid from parsing text betweeen {% raw %} and {% endraw %}
module Jekyll
class RawTag < Liquid::Block
def parse(tokens)
@nodelist ||= []
@nodelist.clear
while token = tokens.shift
if token =~ FullToken
if block_delimiter == $1
end_tag
@phillipkoebbe
phillipkoebbe / multiple_find_replace.py
Created December 25, 2011 17:47
Sublime Text 2 Multiple Find/Replace script
# This script allows you to do multiple find/replace operations in one pass. The find/replace
# pairs are defined in a file (defaults to ~/.st2_multiple_find_replace) using the format
#
# find <separator> replace
# By default, the separator is the hash-pointer (=>), but it can be changed if
# necessary (see below). To use multiple find and replace, save this code to a file in
# your Packages/User folder using whatever name you like. I use multiple_find_replace.py.
# Edit your user key bindings and pick whatever key combinations you want to trigger
# these operations. On Mac OS X, I chose COMMAND+OPTION+M E to edit and COMMAND+OPTION+M R
@litzinger
litzinger / example.php
Last active November 9, 2017 05:20
How to use Assets or EE's File Manager anywhere in the CP
<?php
if ( array_key_exists('assets', $this->EE->addons->get_installed()) )
{
// Load Assets' assets
if ( ! isset($this->EE->session->cache['assets']['included_sheet_resources']))
{
if (! class_exists('Assets_helper'))
{
require PATH_THIRD.'assets/helper.php';
@jonathantneal
jonathantneal / README.md
Created September 19, 2012 06:34
Polyfill the EventListener interface in IE8

EventListener Polyfill

Is IE8 your new IE6? Level the playing field with polyfills.

This script polyfills addEventListener, removeEventListener, and dispatchEvent. It is less than half a kilobyte minified and gzipped.

addEventListener

addEventListener registers a single event listener on a single target.

@siebird
siebird / gist:4035793
Created November 8, 2012 01:19
Simple .htaccess rules for ExpressionEngine on Media Temple (dv)'s
## BEGIN Expression Engine Rewrite
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteRule ^(.*)$ /index.php?/$1 [L]
# END Expression Engine Rewrite
@jakejscott
jakejscott / fluid-ratio.scss
Created November 21, 2012 02:11
Fluid Ratio images
// credit Rolf Timmermans
// http://voormedia.com/blog/2012/11/responsive-background-images-with-fixed-or-fluid-aspect-ratios
/* Calculate fluid ratio based on two dimensions (width/height) */
@mixin fluid-ratio($large-size, $small-size) {
$width-large: nth($large-size, 1);
$width-small: nth($small-size, 1);
$height-large: nth($large-size, 2);
$height-small: nth($small-size, 2);
$slope: ($height-large - $height-small) / ($width-large - $width-small);
@stugoo
stugoo / modernizr-ios6-test.js
Created November 21, 2013 12:50
IOS 6 modernizer test, needed this for super edge case on iPad on landscape. :/
// i know, i know, browser sniffing :(
// adaptation of http://stackoverflow.com/questions/8348139/detect-ios-version-less-than-5-with-javascript
Modernizr.addTest('ios6', function() {
var ios6 = false,
v, ver = false;
if (/iP(hone|od|ad)/.test(navigator.platform)) {
v = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/),
ver = parseInt(v[1], 10);
@mrmurphy
mrmurphy / Example.coffee
Last active December 30, 2015 10:38
This is some sample code for a presentation on Snap.svg. It's just a snippet, not a functional example!
anims = []
class Slide
constructor: (@snap, @play, @reset, @animatables = []) ->
@snap = Snap.select @snap
addImage: (path, etc...) ->
e = @snap.image retinizePath(path), etc...
@animatables.push e
return e