Skip to content

Instantly share code, notes, and snippets.

@culttm
culttm / gist:6937eff1ae65601324a7
Created September 28, 2015 09:45
POLYFILL for requestAnimationFrame
//=========================================================================
// POLYFILL for requestAnimationFrame
//=========================================================================
if (!window.requestAnimationFrame) { // http://paulirish.com/2011/requestanimationframe-for-smart-animating/
window.requestAnimationFrame = window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function(callback, element) {
@culttm
culttm / gulpfile.js
Last active August 29, 2015 14:26
My web development gulpfile
var browserSync = require('browser-sync');
var del = require('del');
var gulp = require('gulp');
var pageSpeed = require('psi');
var plugins = require('gulp-load-plugins')();
var runSequence = require('run-sequence');
// Optimize images
gulp.task('images', function () {
return gulp.src('app"<%= asset_path('$1') %>"**/*')
@culttm
culttm / trimSerialize.jquery.js
Last active August 29, 2015 14:26 — forked from darrennolan/trimSerialize.jquery.js
jQuery Trim Serialize form function. Leaves previous form intact, allows for giving selector for trim to run on. Defaults to only input[type=text] inputs.
(function($) {
/**
* Trim Form Elements before returning Serialize()
* @param {string} selector Defaults to 'input[type=text]'
* @return {serialized()} Returned jQuery serialize() string
*/
$.fn.trimSerialize = function(selector) {
// Deep clone form (to get all nested elements), then unbind everything off the clone
var clonedObject = $(this).clone(true).off();
@culttm
culttm / jquery.alterclass.js
Last active August 29, 2015 14:26 — forked from peteboere/jquery.alterclass.js
jQuery alterClass plugin: Remove element classes with wildcard matching. Optionally add classes.
/**
* jQuery alterClass plugin
*
* Remove element classes with wildcard matching. Optionally add classes:
* $( '#foo' ).alterClass( 'foo-* bar-*', 'foobar' )
*
* Copyright (c) 2011 Pete Boere (the-echoplex.net)
* Free under terms of the MIT license: http://www.opensource.org/licenses/mit-license.php
*
*/
BrowserDetect = {
init:->
this.browser = this.searchString(this.dataBrowser) || "Other"
this.version = this.searchVersion(navigator.userAgent) || this.searchVersion(navigator.appVersion) || "Unknown"
searchString: (data) ->
for (var i = 0; i < data.length; i++) {
var dataString = data[i].string;
this.versionSearchString = data[i].subString;
# A class-based template for jQuery plugins in Coffeescript
#
# $('.target').myPlugin({ paramA: 'not-foo' });
# $('.target').myPlugin('myMethod', 'Hello, world');
#
# Check out Alan Hogan's original jQuery plugin template:
# https://github.com/alanhogan/Coffeescript-jQuery-Plugin-Template
#
(($, window) ->
@culttm
culttm / _grab.scss
Last active August 29, 2015 14:15 — forked from shiwano/_grab.scss
@charset "UTF-8";
@mixin grab-cursor {
// http://www.google.com/intl/en_ALL/mapfiles/openhand.cur
cursor: url('data:image/vnd.microsoft.icon;base64,AAACAAEAICACAAcABQAwAQAAFgAAACgAAAAgAAAAQAAAAAEAAQAAAAAAAAEAAAAAAAAAAAAAAgAAAAAAAAAAAAAA////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD8AAAA/AAAAfwAAAP+AAAH/gAAB/8AAA//AAAd/wAAGf+AAAH9gAADbYAAA2yAAAZsAAAGbAAAAGAAAAAAAAA//////////////////////////////////////////////////////////////////////////////////////gH///4B///8Af//+AD///AA///wAH//4AB//8AAf//AAD//5AA///gAP//4AD//8AF///AB///5A////5///8='), all-scroll;
// cursor: -webkit-grab;
cursor: -moz-grab;
cursor: -o-grab;
cursor: -ms-grab;
cursor: grab;
<!DOCTYPE html>
<!--[if IE 8]> <html lang="sv-SE" class="no-js ie8"> <![endif]-->
<!--[if gt IE 8]><!--> <html lang="sv-SE" class="no-js"> <!--<![endif]-->
<head>
<meta charset="UTF-8">
<title>Breakpoint detection test</title>
<style type="text/css" media="screen">
@media screen and (min-width: 320px) {
#page:after {
content: 'smallest'; /* represent the current width-bracket */
@culttm
culttm / 0_reuse_code.js
Last active August 29, 2015 14:15
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console