Skip to content

Instantly share code, notes, and snippets.

View callumlocke's full-sized avatar

Callum Locke callumlocke

View GitHub Profile
@rrobe53
rrobe53 / gist:976610
Created May 17, 2011 14:46
Node.js File Extension Content Type
exports.ext = function () {
var extTypes = {
"3gp" : "video/3gpp"
, "a" : "application/octet-stream"
, "ai" : "application/postscript"
, "aif" : "audio/x-aiff"
, "aiff" : "audio/x-aiff"
, "asc" : "application/pgp-signature"
, "asf" : "video/x-ms-asf"
, "asm" : "text/x-asm"
@paulirish
paulirish / rAF.js
Last active March 22, 2024 00:00
requestAnimationFrame polyfill
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
@patocallaghan
patocallaghan / css-triangle.scss
Created June 21, 2012 01:07
CSS Triangles SCSS Mixin #css #scss #triangle #mixin
//==== Simple SCSS mixin to create CSS triangles
//==== Example: @include css-triangle ("up", 10px, #fff);
@mixin css-triangle ($direction: "down", $size: 20px, $color: #000) {
width: 0;
height: 0;
border-left: $size solid #{setTriangleColor($direction, "left", $color)};
border-right: $size solid #{setTriangleColor($direction, "right", $color)};
border-bottom: $size solid #{setTriangleColor($direction, "bottom", $color)};
border-top: $size solid #{setTriangleColor($direction, "top", $color)};
}
@marcedwards
marcedwards / high-dpi-media.css
Last active November 19, 2023 12:56
A CSS media query that captures almost all high DPI aware devices.
/* ---------------------------------------------------------- */
/* */
/* A media query that captures: */
/* */
/* - Retina iOS devices */
/* - Retina Macs running Safari */
/* - High DPI Windows PCs running IE 8 and above */
/* - Low DPI Windows PCs running IE, zoomed in */
/* - Low DPI Windows PCs and Macs running Firefox, zoomed in */
/* - Android hdpi devices and above */
@nicdaCosta
nicdaCosta / Grep.js
Last active March 9, 2024 13:39
Basic function that searches / filters any object or function and returns matched properties.
/*
Grep.js
Author : Nic da Costa ( @nic_daCosta )
Created : 2012/11/14
Version : 0.2
(c) Nic da Costa
License : MIT, GPL licenses
Overview:
Basic function that searches / filters any object or function and returns matched properties.
@Darep
Darep / item.rb
Created January 24, 2013 19:15
Ruby on Rails concern example: making an ActiveRecord item sortable. Adapted from: http://say26.com/show-us-your-production-code-1-concerns
# app/models/item.rb
require 'concerns/sortable'
class Item < ActiveRecord::Base
include Sortable
attr_accessible :title
end
@SlexAxton
SlexAxton / .zshrc
Last active April 25, 2023 03:57
My gif workflow
gifify() {
if [[ -n "$1" ]]; then
if [[ $2 == '--good' ]]; then
ffmpeg -i $1 -r 10 -vcodec png out-static-%05d.png
time convert -verbose +dither -layers Optimize -resize 600x600\> out-static*.png GIF:- | gifsicle --colors 128 --delay=5 --loop --optimize=3 --multifile - > $1.gif
rm out-static*.png
else
ffmpeg -i $1 -s 600x400 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > $1.gif
fi
else
Heh
Anyway
Obviously it's not a huge deal
It just makes me sad
I like Node
And I can write Node
I just don't use it for anything
I like JS
And I can write JS
I just prefer CoffeeScript for day to day use

micromatch vs. minimatch (WIP)

Can micromatch be used as a drop-in replacement for minimatch?

For mainstream features, I tried to keep as much parity as possible between micromatch and minimatch. But there are some differences.

Key differences

  • the main minimatch function, minimatch(), works like micromatch.isMatch()
  • the main micromatch function, micromatch(), works like multimatch, with support for multiple patterns.
@MadeByMike
MadeByMike / bling.js
Last active July 23, 2021 12:32 — forked from paulirish/bling.js
/* bling.js */
window.$ = document.querySelectorAll.bind(document)
Node.prototype.on = window.on = function (name, delegate, fn) {
var f
var target = this, match = false
var matches = this.matchesSelector || this.mozMatchesSelector || this.webkitMatchesSelector || this.oMatchesSelector || (function (name) {
$(name).forEach(function (elm) {
if (elm === target){