Skip to content

Instantly share code, notes, and snippets.

View toolmantim's full-sized avatar
:shipit:
🎉

Tim Lucas toolmantim

:shipit:
🎉
View GitHub Profile
@toolmantim
toolmantim / snippet.js
Last active December 15, 2015 06:39 — forked from pschyska/main.js
// Configure accordingly
window._crashmat = {key:'abc123'};
// Capture errors
(function(w, cm, woe) {
w.onerror = function(e,f,l,c) {
cm.e = cm.e || []; cm.e.push([e,f,l,c]);
if (woe) woe(e,f,l,c);
};
})(window, window._crashmat, window.onerror);
@toolmantim
toolmantim / all_links_render_test.rb
Created March 7, 2013 05:55
A simple Rails 3/4 integration test that spiders your application's links, checking that none return a 500 or 404
@toolmantim
toolmantim / application.html.erb
Created February 16, 2013 11:26
Pre-fetching your Rails asset hostname using dns-prefetch in your application's layout file
<!DOCTYPE html>
<html>
<head>
<title>App title</title>
<% if ActionController::Base.asset_host %>
<link rel="dns-prefetch" href="//<%= ActionController::Base.asset_host %>" />
<% end %>
@toolmantim
toolmantim / brunch_uglify.coffee
Last active December 13, 2015 18:58
Various configurations to ensure newlines are preserved in minified Javascript files. Fork it and add another language/framework/compressor combination!
# Brunch - http://brunch.io/
#
# Using uglify-js-brunch - https://github.com/brunch/uglify-js-brunch
#
# Use the following settings in your Brunch configuration file
exports.config =
plugins:
uglify:
output:
@toolmantim
toolmantim / application.html.erb
Created February 15, 2013 03:50
An example Rails helper and application layout snippet for Crashmat user configuration.
<!DOCTYPE html>
<html>
<head>
<title>My App</title>
<script>
window.Crashmat = {
key: "[your key]",
user: <%= raw crashmat_user.to_json.gsub("</", "<\\/") %>
};
@toolmantim
toolmantim / development.rb
Last active December 13, 2015 18:48
Filtering asset requests from the development log using Rails 3.2
# Add the following configuration to your config/environments/development.rb file
#
# This will set the Rails to log to STDOUT (insetad of log/development.log) as well
# as tag all assets request log lines with [assets]
#
# You can then pipe it into grep to filter out the asset lines
#
# tail -f log/development.rb | grep -v '\[assets\]'
#
# If you log to STDOUT rather than log/development.rb then you can:
@toolmantim
toolmantim / Procfile
Last active December 12, 2015 09:39
@ddollar's foreman Ruby gem is handy for booting a single app's processes, but you can also use foreman as a booter for mutiple foreman apps! Handy if you have apps that work together in a service-oriented way and you're sick of booting them one-at-a-time (or you're using a harness shell script).
app_1: foreman start --root app_1 --port 3000 --env app_1/.env
app_2: foreman start --root app_2 --port 3100 --env app_2/.env
app_3: foreman start --root app_3 --port 3200 --env app_3/.env
@toolmantim
toolmantim / upload_to_s3
Last active December 12, 2015 08:59
A command line tool for uploading a file to a S3 and printing the private, expiring URL to STDOUT. Stick it in your ~/bin, chmod u+x and upload like it's 1999.
#!/usr/bin/env ruby
#
# Uploads a file to a S3 and prints a private, expiring URL to STDOUT
#
# Requirements: aws-s3 gem
if ARGV.length != 3
abort "Usage: #{$0} FILE BUCKET EXPIRY_IN_SECONDS"
end
@toolmantim
toolmantim / mail_preview.rb
Last active December 12, 2015 00:18
Here's a sketch of my ideal gem for designing, auditing and cross-browser testing HTML emails in Rails applications. This could be built upon the work of the existing 37signals/mail_view.
# Gemfile
group :development do
gem 'mail_preview'
end
# config/initializers/mail_preview.rb
MailPreview.configure do |c|
c.litmus subdomain: "company",
@toolmantim
toolmantim / app.rb
Created January 18, 2013 07:51
Configuring sinatra asset-pack to retain line numbers
require 'sinatra'
require 'sinatra/assetpack'
assets do
js :app, '/app.js', ['js/*.js']
js_compression :uglify,
# Add new lines
beautify: true,
# Don't add indentation
beautify_options: {indent_level: 0}