Skip to content

Instantly share code, notes, and snippets.

View twhid's full-sized avatar
💭
⌨️ probably clacking

Tim Whidden twhid

💭
⌨️ probably clacking
View GitHub Profile
@twhid
twhid / pre-commit
Last active November 13, 2015 18:42
Run JSHint validation before commit.
#!/bin/sh
#
# Run JSHint validation before commit.
#
# Originally: http://stackoverflow.com/a/21238963/302550
#
# Requires Node (http://nodejs.org/) and jshint (https://www.npmjs.org/package/jshint)
# be globally installed (e.g.: npm install jshint -g).
#
# Edited slightly to make it easier to work with Git GUIs (e.g. PHPStorm IDE, Tower).
@twhid
twhid / unix-timestamp-converter.js
Created April 19, 2014 02:24
BBEdit Text Filter to transform unix timestamp to human a readable string in the UTC time zone.
#!/usr/local/bin/node
// Note that a more standard node hashbang doesn't seem to work
// in a BBEdit Text Filter (or perhaps it's Homebrew installed node weirdness).
// So, change the hashbang to a path to your node executable
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (data) {
@twhid
twhid / uglify.js
Last active November 13, 2015 11:13
#!/usr/local/bin/node
// BBEdit text filter to uglify Javascript.
// Uses the default compression options, *except* it turns off warnings because they cause the script to error out.
//
// Requires uglifyjs https://github.com/mishoo/UglifyJS2
// In this example, I've installed uglifyjs globally via `npm install uglify-js -g`
// Your install directory may be different...
var UglifyJS = require('/usr/local/share/npm/lib/node_modules/uglify-js');
@twhid
twhid / helper.html
Created July 25, 2012 17:04
elledecor/1stdibs cross-frame helper code
<!--
* 1stdibs cross-domain iframe helper
* put this near the top of the page
-->
<script type="text/javascript">
(function () {
// SET DOCUMENT.DOMAIN FOR CROSS-FRAME COMMUNICATION
var domain = document.location.hostname.split('.');
document.domain = domain[domain.length-2] + '.' + domain[domain.length-1];
@twhid
twhid / gist:2648062
Created May 9, 2012 19:05
grunt task to deploy JS files to S3 with awssum
grunt.registerMultiTask('s3deploy', 'deploy to S3 using awssum', function () {
// dependencies
var awssum = require('awssum'),
fs = require('fs'),
path = require('path'),
aws = require('./settings').aws;
var amz = awssum.load('amazon/amazon'),
AmazonS3 = awssum.load('amazon/s3'),
s3 = new AmazonS3(aws.accessKey, aws.secretKey, aws.accountId , amz.US_EAST_1),
@twhid
twhid / cssmin.js
Created May 3, 2012 17:13 — forked from FiNGAHOLiC/cssmin.js
grunt cssmin sqwish task
// grunt minify CSS task using sqwish
grunt.registerMultiTask('cssmin', 'minify css with sqwish', function () {
var sqwish = require('sqwish'),
dest = this.file.dest;
try {
var css = grunt.file.read(this.file.src),
min = sqwish.minify(css);
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Skeleton Parent Page</title>
<style type="text/css">
html {
width: 100%;
height: 100%;
}