Skip to content

Instantly share code, notes, and snippets.

@Ianfeather
Ianfeather / gist:8240922
Last active January 2, 2016 02:59
r.js path switching
// Is there a way to change a path for a specific module during the r.js build process?
// So that a module with a dependency of 'jquery' can be used with two versions?
// I have tried to show what I would be after with lines 16-18
({
baseUrl: "./",
paths: {
"jquery": "jquery/jquery-2.0"
},
modules: [
@Ianfeather
Ianfeather / SassMeister-input.sass
Created December 19, 2013 22:54
Generated by SassMeister.com.
// ----
// Sass (v3.3.0.rc.5)
// Compass (v1.0.0.alpha.18)
// ----
// ****
// TOGGLE THIS VARIABLE TO SEE THE DIFFERENCE
$is-ie: false
@mixin respond-to($screen-width)
@Ianfeather
Ianfeather / SassMeister-input.sass
Created November 19, 2013 17:30
Generated by SassMeister.com.
// ----
// Sass (v3.3.0.rc.1)
// Compass (v0.13.alpha.10)
// ----
$is-ie: true
@mixin respond-at($screen-width)
@if $is-ie == false
@media only screen and (min-width : #{$screen-width}px)
@Ianfeather
Ianfeather / proximity_loader.coffee
Last active December 23, 2015 03:39
Proximity loading for images/social scripts
# Really this is just a proximity_sensor, it will fire whatever event you pass as an arg
# It has nothing to do with loading, that's just how we've used it so far
required = if window.lp.isMobile then 'jsmin' else 'jquery'
define [required, 'lib/extends/events'], ($, EventEmitter) ->
class ProximityLoader
for key, value of EventEmitter
@Ianfeather
Ianfeather / gist:5955858
Last active December 19, 2015 12:38
Is there a way to make the jasmine src property honour the requirejs baseUrl?
// When I specify our baseUrl as '/public/assets/javascripts'
//
// Grunt will fail to import any files from here ('public/assets/javascripts/lib/**/*.js') into the require call, presumably becaus it is searching in ./lib/**/ which doesn't exist.
// Obviously the specs won't run because there are no src files to test against
jasmine: {
avocado: {
src: ['lib/**/*.js'],
options: {
@Ianfeather
Ianfeather / gist:5955912
Created July 9, 2013 09:15
SpecRunner.html
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Jasmine Spec Runner</title>
<link rel="stylesheet" type="text/css" href=".grunt/grunt-contrib-jasmine/jasmine.css">
@Ianfeather
Ianfeather / dabblet.css
Created May 10, 2012 09:13 — forked from anonymous/dabblet.css
Untitled
div{
display:inline-block;
padding:5px;
margin:10px;
border:1px solid #ccc;
transition: 0s background-color;
}
div:hover{
background-color:red;
transition-delay:1s;
function couldBePalindromic(word) {
let letters = word.split('');
let matches = letters.map(letter => {
// How many sets of characters are multiples of 2
return letters.filter((l) => l == letter).length % 2 == 0
})
// Filter out the ones that aren't
.filter((bool) => bool == true)
@Ianfeather
Ianfeather / gist:fefaee82c2ac0e66fddd
Created March 17, 2015 14:30
List files using node and generators
'use strict';
var co = require('co'),
fs = require('co-fs'),
each = require('co-each');
var dive = function* (path) {
var items = yield fs.readdir(path);
// This is a utility function that breaks a URL into an object
// parseUri 1.2.2
// (c) Steven Levithan <stevenlevithan.com>
// MIT License
function parseUri(d){for(var a=parseUri.options,d=a.parser[a.strictMode?"strict":"loose"].exec(d),c={},b=14;b--;)c[a.key[b]]=d[b]||"";c[a.q.name]={};c[a.key[12]].replace(a.q.parser,function(d,b,e){b&&(c[a.q.name][b]=e)});return c}
parseUri.options={strictMode:!1,key:"source protocol authority userInfo user password host port relative path directory file query anchor".split(" "),q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}};
function getCampaignMedium(landinguri, campcode, refuri){
/**********Campaign managem