Skip to content

Instantly share code, notes, and snippets.

@mattlenz
mattlenz / abn_lookup.sh
Created April 3, 2013 01:43
ABN Lookup
curl --data "abn=23414472095" http://www.cheapdomains.com.au/register/abracadabra_lookup.php
# Response:
# {"n":null,"s":null,"type":"single","data":{"name":"LENZ, MATTHEW ","trading_name":"<input type=\"text\" size=\"25\" name=\"trading_name[]\" id=\"trading_name_0\" class=\"\" value=\"Half Design and Development\" \/>","has_trading_name":1,"number":"ABN 23414472095","type":"Sole Trader","domain_name":""}}
@mattlenz
mattlenz / clearfix.css
Created February 11, 2013 05:09
Modern clearfix
.clearfix:before, .clearfix:after {
content: ' ';
display: table;
}
.clearfix:after, .wrapper:after {
clear: both;
}
@mattlenz
mattlenz / jquery.transitionend.coffee
Created September 14, 2012 01:14
Cross-browser CSS transitionEnd & animationEnd
$.fn.transitionEnd = (callback) ->
$(@).one 'transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', callback
$.fn.animationEnd = (callback) ->
$(@).one 'animationend webkitAnimationEnd oAnimationEnd MSAnimationEnd', callback
@mattlenz
mattlenz / image_with_color.rb
Created August 20, 2012 23:27
Solid-color (stretchable) UIImage generator for RubyMotion
# require 'bubble-wrap'
class UIImage
def self.imageWithColor(color)
if color.is_a?(String)
color = color.to_color
end
rect = CGRectMake(0, 0, 1, 1)
@mattlenz
mattlenz / gist:3391345
Created August 19, 2012 03:02
Recognize single and double tap gestures in RubyMotion
doubleTapRecognizer = self.whenTapped do |recognizer|
recognizer.numberOfTapsRequired = 2
recognizer.delaysTouchesBegan = true
p "Double tap"
end
singleTapRecognizer = self.whenTapped do |recognizer|
recognizer.numberOfTapsRequired = 1
recognizer.delaysTouchesBegan = true
@mattlenz
mattlenz / user.rb
Last active October 8, 2015 19:08
Memoize dragonfly image dimensions
class User < ActiveRecord::Base
image_accessor :avatar
serialize :avatar_geometries, Hash
def avatar_dimensions(geometry)
unless avatar_geometries.has_key?(geometry)
thumb = avatar.thumb(geometry)
avatar_geometries[geometry] = {
@mattlenz
mattlenz / links.coffee
Created August 12, 2012 02:37
Open external links in new window
@mattlenz
mattlenz / gist:3280970
Created August 7, 2012 03:05
Test send HTML email
mutt -e 'set content_type="text/html"' [email protected] -s "HTML Email Test" < message.html
@mattlenz
mattlenz / markdown_handler.rb
Created July 27, 2012 01:03
Rails Markdown (Kramdown) Template Handler
# config/initializers/markdown_handler.rb
module MarkdownHandler
def self.erb
@erb ||= ActionView::Template.registered_template_handler(:erb)
end
def self.call(template)
compiled_source = erb.call(template)
"Kramdown::Document.new(begin;#{compiled_source};end, auto_ids: false).to_html"
@mattlenz
mattlenz / Gemfile
Last active October 7, 2015 10:07
Tiny static-site Rack server
source :rubygems
gem 'rack'