Skip to content

Instantly share code, notes, and snippets.

View jbrown's full-sized avatar

Justin Brown jbrown

View GitHub Profile
@rtomayko
rtomayko / Tests Is Wrong
Created January 28, 2009 20:50
Why "require 'rubygems'" In Your Library/App/Tests Is Wrong
In response to all the responses to:
http://twitter.com/rtomayko/status/1155906157
You should never do this in a source file included with your library,
app, or tests:
require 'rubygems'
The system I use to manage my $LOAD_PATH is not your library/app/tests
require File.dirname(__FILE__) + '/../spec_helper'
describe AccountController do
as_any_user :get => :show do
it { should assign_to(:user, :with => @current_user)}
it { should respond_with(:success) }
end
as_any_user :get => :edit do
it { should assign_to(:user, :with => @current_user)}
class AppBuilder < Rails::AppBuilder
include Thor::Actions
include Thor::Shell
def test
append_test_gems
rspec
cucumber
jasmine
end
# Removing leftover leases and persistent rules
echo "cleaning up dhcp leases"
rm /var/lib/dhcp3/*
# Make sure Udev doesn't block our network
# http://6.ptmc.org/?p=164
echo "cleaning up udev rules"
DIR_PATH=`readlink -f "/etc/udev/rules.d/70-persistent-net.rules"` # get rid of symlinks and get abs path
rm -rf /etc/udev/rules.d/70-persistent-net.rules
if [[ ! -d "${DIR_PATH}" ]] ; then # now you're testing
@subelsky
subelsky / Gemfile
Created July 28, 2011 14:17
Getting SSL, Capybara, Rails 3, and Devise to work together
gem "rack-ssl", "1.3.2"
# when Capybara issue 409 or 422 get resolved, you can switch back to the official
# capybara gem
# https://github.com/jnicklas/capybara/pull/409
# https://github.com/jnicklas/capybara/pull/422
gem "capybara", git: "https://github.com/mcolyer/capybara.git", branch: "fix-ssl-redirects"
@JoeyButler
JoeyButler / chat.html
Created October 24, 2011 00:14
Simple Chat app
<!DOCTYPE html>
<html>
<head>
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js'></script>
<script>
$(document).ready(function(){
function debug(str){ $("#debug").append("<p>"+str+"</p>"); };
if(typeof WebSocket === 'undefined') {
alert("Your browser does not support websockets.")
}
@myobie
myobie / mountain-lion-brew-setup.markdown
Created February 18, 2012 20:14
Get Mountain Lion and Homebrew to Be Happy

Get Mountain Lion and Homebrew to Be Happy

1) Install XCode 4.4 into /Applications

Get it from the App Store.

2) Install Command Line Tools

In XCode's Preferences > Downloads you can install command line tools.

@anthonyshort
anthonyshort / _media-queries.scss
Created March 13, 2012 10:37
Media Queries in Sass
// Media Queries in Sass 3.2
//
// These mixins make media queries a breeze with Sass.
// The media queries from mobile up until desktop all
// trigger at different points along the way
//
// And important point to remember is that and width
// over the portrait width is considered to be part of the
// landscape width. This allows us to capture widths of devices
// that might not fit the dimensions exactly. This means the break
@jrochkind
jrochkind / gist:2161449
Created March 22, 2012 18:40
A Capistrano Rails Guide

A Capistrano Rails Guide

by Jonathan Rochkind, http://bibwild.wordpress.com

why cap?

Capistrano automates pushing out a new version of your application to a deployment location.

I've been writing and deploying Rails apps for a while, but I avoided using Capistrano until recently. I've got a pretty simple one-host deployment, and even though everyone said Capistrano was great, every time I tried to get started I just got snowed under not being able to figure out exactly what I wanted to do, and figured I wasn't having that much trouble doing it "manually".

@Warry
Warry / Article.md
Created December 11, 2012 00:11
How to make faster scroll effects?

How to make faster scroll effects?

  • Avoid too many reflows (the browser to recalculate everything)
  • Use advanced CSS3 for graphic card rendering
  • Precalculate sizes and positions

Beware of reflows

The reflow appens as many times as there are frames per seconds. It recalculate all positions that change in order to diplay them. Basically, when you scroll you execute a function where you move things between two reflows. But there are functions that triggers reflows such as jQuery offset, scroll... So there are two things to take care about when you dynamically change objects in javascript to avoid too many reflows: