Skip to content

Instantly share code, notes, and snippets.

@TooTallNate
TooTallNate / anotherScript.js
Created June 10, 2010 19:15
"getScriptName" is a cross-browser function to retrieve the absolute URL of the currently executing JavaScript file.
// If no exception is passed into 'getScriptName', it will only
// retrieve the URL of the script where 'getScriptName' is defined.
// In order to get the URL of a different script file, you must
// pass an exception generated in this script file to 'getScriptName'.
try {
(0)();
} catch(ex) {
getScriptName(ex, onScriptNameKnown);
}
// selectorSupported lovingly lifted from the mad italian genius, diego perini
// http://javascript.nwbox.com/CSSSupport/
function selectorSupported(selector){
var support, link, sheet, doc = document,
root = doc.documentElement,
head = root.getElementsByTagName('head')[0],
impl = doc.implementation || {
@smtm
smtm / de.yml
Last active October 31, 2017 11:31
Parsing YAML in Rails i18n locale files to generate JSON for a javascript translation method
These are the code parts to grab related to this blog post.
Read more about it there
http://www.igumbi.com/en/blog/YAML-to-JSON-Rails-for-i18n-Language-Files
# The locale file structure de.yml
de:
obt:
@jschementi
jschementi / README.md
Created April 29, 2012 23:56
Trello to Todo.txt converter
@hay
hay / has-overflow-scrolling.js
Created November 7, 2012 16:14
Check if a browser supports the overflow-scrolling CSS property, optionally with a prefix
function hasOverflowScrolling() {
var prefixes = ['webkit', 'moz', 'o', 'ms'];
var div = document.createElement('div');
var body = document.getElementsByTagName('body')[0];
var hasIt = false;
body.appendChild(div);
for (var i = 0; i < prefixes.length; i++) {
var prefix = prefixes[i];
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active June 5, 2024 22:16
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@squallstar
squallstar / Gruntfile.js
Last active January 10, 2016 11:10
Retina images with Grunt
//Grunt Spritesmith plugin
sprite: {
build: {
src: ['src/img/sprite/*.png'],
destImg: 'build/img/s-' + timestamp + '.png',
destCSS: 'src/scss/common/sprite.scss',
imgPath: '../img/s-' + timestamp + '.png',
algorithm: 'binary-tree',
engine: 'gm',
'engineOpts': {
@sindresorhus
sindresorhus / post-merge
Last active May 2, 2024 03:18
git hook to run a command after `git pull` if a specified file was changed.In this example it's used to run `npm install` if package.json changed and `bower install` if `bower.json` changed.Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
#!/usr/bin/env bash
# MIT © Sindre Sorhus - sindresorhus.com
# git hook to run a command after `git pull` if a specified file was changed
# Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
check_run() {
echo "$changed_files" | grep --quiet "$1" && eval "$2"
@branneman
branneman / better-nodejs-require-paths.md
Last active June 27, 2024 10:40
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@jr314159
jr314159 / karma.coffee.erb
Created January 15, 2014 16:35
Karma rake task
# Karma configuration
# Generated on Tue Aug 20 2013 16:26:25 GMT-0400 (EDT)
module.exports = (config) ->
config.set
# base path, that will be used to resolve all patterns, eg. files, exclude
basePath: '..'
# frameworks to use