Skip to content

Instantly share code, notes, and snippets.

@nhocki
nhocki / backbone.authtokenadapter.js
Created September 29, 2011 19:44
Backbone Rails Auth Token Adapter
// REQUIRES JQUERY AND BACKBONE TO BE LOADED FIRST
//
// With additions by Maciej Adwent http://github.com/Maciek416
// If token name and value are not supplied, this code Requires jQuery
//
// Adapted from:
// http://www.ngauthier.com/2011/02/backbone-and-rails-forgery-protection.html
// Nick Gauthier @ngauthier
//
@addyosmani
addyosmani / async.js
Created February 7, 2012 17:20
Cache a library using localStorage and Base64
// some modified async work based on prior by necolas
(function(d){
var js,
fjs = d.getElementsByTagName('script')[0],
frag = d.createDocumentFragment(),
add = function(url, id) {
if (d.getElementById(id)) {return;}
js = d.createElement('script');
js.src = url;
id && (js.id = id);
@mattratleph
mattratleph / vimdiff.md
Last active June 21, 2024 15:33 — forked from roothybrid7/vimdiff_cheet.md
vimdiff cheat sheet

vimdiff cheat sheet

##git mergetool

In the middle file (future merged file), you can navigate between conflicts with ]c and [c.

Choose which version you want to keep with :diffget //2 or :diffget //3 (the //2 and //3 are unique identifiers for the target/master copy and the merge/branch copy file names).

:diffupdate (to remove leftover spacing issues)

:only (once you’re done reviewing all conflicts, this shows only the middle/merged file)

@adamjimenez
adamjimenez / gist:5917897
Created July 3, 2013 13:36
Generate thumbnails from video files using HTML5's video tag and canvas
<?php
//where you want your thumbnails to go
$thumbs_dir = 'uploads/thumbs/';
//this should be an array of video paths
$videos = array();
if( $_POST["name"] ){
// Grab the MIME type and the data with a regex for convenience
if (!preg_match('/data:([^;]*);base64,(.*)/', $_POST['data'], $matches)) {
@apexskier
apexskier / deploy-hooks.sh
Last active March 18, 2016 20:22
Script to deploy git hooks from version control.
#!/bin/sh
# Deploy hooks stored in your git repo to everyone!
# https://gist.github.com/apexskier/efb7c1aaa6e77e8127a8
#
# I keep this in $ROOT/$HOOK_DIR/deploy
# From the top level of your git repo, run ./hook/deploy (or equivalent) after
# cloning or adding a new hook.
# No output is good output.
BASE=`git rev-parse --git-dir`
@staltz
staltz / introrx.md
Last active July 6, 2024 17:07
The introduction to Reactive Programming you've been missing
@patriciogonzalezvivo
patriciogonzalezvivo / GLSL-Noise.md
Last active July 6, 2024 09:32
GLSL Noise Algorithms

Please consider using http://lygia.xyz instead of copy/pasting this functions. It expand suport for voronoi, voronoise, fbm, noise, worley, noise, derivatives and much more, through simple file dependencies. Take a look to https://github.com/patriciogonzalezvivo/lygia/tree/main/generative

Generic 1,2,3 Noise

float rand(float n){return fract(sin(n) * 43758.5453123);}

float noise(float p){
	float fl = floor(p);
  float fc = fract(p);
@1Marc
1Marc / vimeo-raw-file
Created July 27, 2014 01:02
Vimeo Raw File Script
copy('<ul>'
+ '<li><a download href="' + $("#use_your_own_player input:eq(2)").val() + '">Mobile .MP4 file</a> (480×270)</li>'
+ '<li><a download href="' + $("#use_your_own_player input:eq(1)").val() + '">Standard Def .MP4 file</a> (640x360)</li>'
+ '<li><a download href="' + $("#use_your_own_player input:eq(0)").val() + '">High Def .MP4 file</a> (1280x720)</li>'
+ '</ul>')
http://vimeo.com/99210022/download?t=1403810003&v=265672656&s=f423e5f7722fe0702204e25c76fea728
@addyosmani
addyosmani / README.md
Last active April 2, 2024 20:18 — forked from 140bytes/LICENSE.txt
108 byte CSS Layout Debugger

CSS Layout Debugger

A tweet-sized debugger for visualizing your CSS layouts. Outlines every DOM element on your page a random (valid) CSS hex color.

One-line version to paste in your DevTools

Use $$ if your browser aliases it:

~ 108 byte version

@dmnsgn
dmnsgn / .eslintrc.js
Created July 23, 2015 13:31
.eslintrc Google JavaScript Style Guide (eslint v0.24.1)
{
// http://eslint.org/docs/rules/
"env": {
"browser": true, // browser global variables.
"node": false, // Node.js global variables and Node.js-specific rules.
"worker": false, // web workers global variables.
"amd": false, // defines require() and define() as global variables as per the amd spec.
"mocha": false, // adds all of the Mocha testing global variables.
"jasmine": false, // adds all of the Jasmine testing global variables for version 1.3 and 2.0.