Skip to content

Instantly share code, notes, and snippets.

@mjtko
mjtko / sprockets-server-monkeypatch-deny_phantomjs_ttf.rb
Created October 24, 2012 14:51
Monkey patch for denying TTF files to PhantomJS under test env
# config/initializers/sprockets-server-monkeypatch-deny_phantomjs_ttf.rb
# Monkey patch under test environment that prevents PhantomJS on OSX
# from crashing when dealing with TTF webfonts.
# Note: depending on your setup, it's likely that the RUBY_PLATFORM
# is not actually relevant for server - it's the UA that crashes.
if Rails.env.test? # && RUBY_PLATFORM =~ /darwin/
module Sprockets::Server
def call_with_env_instance_var(env)
@env = env
@jlindsey
jlindsey / culerity.js
Created June 3, 2010 16:47
Using Cucumber/Capybara/Culerity, a step to wait until all AJAX calls are complete.
// this allows culerity to wait until all ajax requests have finished
jQuery(function($) {
var original_ajax = $.ajax;
var count_down = function(callback) {
return function() {
try {
if(callback) {
callback.apply(this, arguments);
};
} catch(e) {
@twetzel
twetzel / replace_ruby_hash_syntax.md
Last active December 18, 2015 16:49
regular expression to change ruby hash syntax for TextMate | Sublime | etc

Old => New:

Find:
  :(\w+)[\s]+=>[\s]+
Replace:
  $1: 

New => Old:

@caleywoods
caleywoods / application.coffee
Created January 24, 2012 14:57
Backbone JS / Fullcalendar
$ ->
Event = Backbone.Model.extend()
Events = Backbone.Collection.extend({
Model: Event,
url : 'events'
})
EventsView = Backbone.View.extend({
initialize: ->
@mashihua
mashihua / mysql_to_omnigraffle.applescript
Created December 26, 2011 03:01 — forked from guilhermechapiewski/mysql_to_omnigraffle.applescript
AppleScript to dump MySQL tables to OmniGraffle Pro.
(*
Copyright (c) 2008, Christian Mittendorf <christian.mittendorf@googlemail.com>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this
list ofconditions and the following disclaimer. Redistributions in binary form
must reproduce the above copyright notice, this list of conditions and the
@joachimhs
joachimhs / gist:3529609
Created August 30, 2012 14:27
Ember.js rerender on window resize issue
init: function() {
var view = this;
var resizeHandler = function() {
view.rerender();
};
this.set('resizeHandler', resizeHandler);
$(window).bind('resize', this.get('resizeHandler'));
},
@gaurish
gaurish / install_monit.sh
Last active May 18, 2018 10:15
Install Latest Version of Monit on Ubuntu 14.04 LTS Server 64bit(x86_64)
cd ~
wget http://mmonit.com/monit/dist/binary/5.12/monit-5.12-linux-x64.tar.gz
tar zxf monit-5.12-linux-x64.tar.gz
cd monit-5.12/
cp bin/monit /usr/bin/
mkdir /etc/monit
touch /etc/monit/monitrc
chmod 0700 /etc/monit/monitrc
ln -s /etc/monit/monitrc /etc/monitrc
wget https://gist.githubusercontent.com/gaurish/964456aa08c9fa2e43ee/raw/1aa107e62ecaaa2dacfdb61a12f13efb6f15005b/monit -P /etc/init.d/
@s-andringa
s-andringa / Locales.yml
Created September 19, 2012 10:09
Amsrb talk 18 sept - exceptions_app in Rails 3.2
# config/locales/en.yml
en:
exception:
show:
not_found:
title: "Not Found"
description: "The page you were looking for does not exists."
internal_server_error:
title: "Internal Server Error"
@rjz
rjz / cs-jq-plugin-template.coffee
Created September 3, 2012 17:01
Coffeescript jQuery Plugin Class Template
# A class-based template for jQuery plugins in Coffeescript
#
# $('.target').myPlugin({ paramA: 'not-foo' });
# $('.target').myPlugin('myMethod', 'Hello, world');
#
# Check out Alan Hogan's original jQuery plugin template:
# https://github.com/alanhogan/Coffeescript-jQuery-Plugin-Template
#
(($, window) ->

In order to use asset pipeline available for static error pages (like 404.html), a few steps are required

  • Move static pages from /public into /app/assets

    (eg: public/422.html → app/assets/html/422.html.erb)

  • Add html directory to the asset pipeline

  • Update exceptions middleware to understand assets with digests