Skip to content

Instantly share code, notes, and snippets.

View matthewhudson's full-sized avatar

Matthew Hudson matthewhudson

View GitHub Profile
@matthewhudson
matthewhudson / pre-commit
Last active December 12, 2015 03:59
A pre-commit hook to minify JavaScript files and add them to staging.
#!/usr/bin/env node
var fs = require('fs');
var uglify = require('uglify-js');
var path = require('path');
var exec = require('child_process').exec;
var in_file = path.normalize(__dirname + '../../../infile.js');
var out_file = path.normalize(__dirname + '../../../outfile.min.js');
@matthewhudson
matthewhudson / style.css
Created January 29, 2013 20:13
OSX Lion hides scrollbars while not in use to make it seem more "slick", but at the same time the issue you addressed comes up: people sometimes cannot see whether a <div> has a scroll feature or not.
::-webkit-scrollbar {
-webkit-appearance: none;
width: 7px;
}
::-webkit-scrollbar-thumb {
border-radius: 4px;
background-color: rgba(0,0,0,.5);
-webkit-box-shadow: 0 0 1px rgba(255,255,255,.5);
}
@matthewhudson
matthewhudson / permisions.sh
Created January 8, 2013 21:22
UNIX permissions
# Recursively chmod only directories
find . -type d -exec chmod 755 {} \;
# Similarly, recursively set the execute bit on every directory
chmod -R a+X *
# The +X flag sets the execute bit on directories only
# Recursively chmod only files
find . -type f -exec chmod 644 {} \;
@matthewhudson
matthewhudson / gist:4191461
Created December 2, 2012 22:56
DOM Selector WebPipe Block
var jsdom = require('jsdom');
var fs = require('fs');
var jquery = fs.readFileSync("./jquery.min.js").toString();
var Block = require('node-webpipe').Block;
var block = new Block()
.name("DOM Selector")
.description("Outputs selected content from a HTML DOM.")
.input("url", "string", "The location of the document to inspect.")
.input("selector", "string", "A jQuery-compatible DOM selector.")
@matthewhudson
matthewhudson / functions.php
Created September 4, 2012 13:41 — forked from abecoffman/functions.php
Adds Facebook Graph meta tags to Wordpress blog pages and thumbnail support to your Wordpress theme
<?php
if ( function_exists( 'add_theme_support' ) ) {
add_theme_support( 'post-thumbnails' );
}
function the_facebook_graph_data() {
// setup the default site attributes
$graph;
$graph["site_name"] = "YOUR_SITE_NAME";
@matthewhudson
matthewhudson / metatags.html
Created July 5, 2012 18:27
"Reset" css for UIWebView
<!-- Disable auto-linking of phone numbers. -->
<meta name="format-detection" content="telephone=no">
<!-- Enables the web application runs in full-screen mode. -->
<meta name="apple-mobile-web-app-capable" content="yes">
<!-- Sets the style of the status bar for a web application. -->
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<!-- Sets the initial scale and turns off user scaling. -->
@matthewhudson
matthewhudson / environ.sh
Created July 3, 2012 14:25
osx environment
# Install homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)"
# Install rvm
bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )
rvm install 1.9.2
rvm install jruby
rvm use 1.9.2 --default
@matthewhudson
matthewhudson / README.markdown
Created June 11, 2012 02:42
Application Icon Formats

App Icon Generator

Quickly generate web, mobile and social icons.

Introduction

Your new project needs icons. Different platforms have different icon guidelines. This project seeks to condense those requirements into a single script that handles all the technical guidelines.

Provide the script a single image and it will generate everything you need.

@matthewhudson
matthewhudson / gist:2162865
Created March 22, 2012 19:53
Cocoa NSLog() Frame & Bounds
// The bounds of an UIView is the rectangle, expressed as a location (x,y) and size (width,height) relative to its own coordinate system (0,0).
NSLog(@"bounds.origin.x: %f", thing.bounds.origin.x);
NSLog(@"bounds.origin.y: %f", thing.bounds.origin.y);
NSLog(@"bounds.size.width: %f", thing.bounds.size.width);
NSLog(@"bounds.size.height: %f", thing.bounds.size.height);
// The frame of an UIView is the rectangle, expressed as a location (x,y) and size (width,height) relative to the superview it is contained within.
NSLog(@"frame.origin.x: %f", thing.frame.origin.x);
NSLog(@"frame.origin.y: %f", thing.frame.origin.y);
NSLog(@"frame.size.width: %f", thing.frame.size.width);
@matthewhudson
matthewhudson / gist:2130572
Created March 20, 2012 03:00
Create folder if doesn't exist
// Documents directory
NSString *documentsPath = [NSSearchPathForDirectoriesInDomains(
NSDocumentDirectory,
NSUserDomainMask, YES)
objectAtIndex:0];
NSString *dataPath = [documentsPath stringByAppendingPathComponent:@"folderName"];
// Create folder if does not exist.
if (![[NSFileManager defaultManager] fileExistsAtPath:dataPath]) {