Skip to content

Instantly share code, notes, and snippets.

View danielpietzsch's full-sized avatar

Daniel Pietzsch danielpietzsch

View GitHub Profile
danielpietzsch /
Created August 6, 2013 11:09
Tail a (Rails) log file for DB updates
tail -f log/development.log |grep 'INSERT INTO\|UPDATE\|DELETE FROM'
(500px) Request phase initiated.
Started GET "/auth/500px" for at 2012-04-29 10:37:56 +1200
danielpietzsch / controller.rb
Created May 24, 2011 05:53
Controller index view with pagination and AJAX search
def index
@instance =[:search], :include => :associated_model).paginate(:page => params[:page])
respond_to do |format|
danielpietzsch / buttons.css
Created May 23, 2011 05:34
CSS Button blueprint
input[type=button] {
background-color: #2066B1;
border: 1px solid #3D3D3D;
color: #EEE;
padding: 0px 10px;
margin-right: 10px;
font-size: 0.85em;
-moz-border-radius: 3px;
danielpietzsch / deploy.rb
Created March 10, 2011 22:50
Deploy a specific or the current Git branch by default using Capistrano
# parses out the current branch you're on. See:
current_branch = `git branch`.match(/\* (\S+)\s/m)[1]
# use the branch specified as a param, then use the current branch. If all fails use master branch
set :branch, ENV['branch'] || current_branch || "master" # you can use the 'branch' parameter on deployment to specify the branch you wish to deploy
danielpietzsch / environment.rb
Created September 15, 2010 00:49
Put this in environment.rb and use the constant to display the version number wherever you like
APP_VERSION = `git describe --always`.strip unless defined? APP_VERSION
danielpietzsch / _revision_number.html.erb
Created May 18, 2010 23:26
A view partial you can include to display the first 8 chars of the deployed git commit. Capistrano creates the REVISION file. Maybe you need to adjust the relative path here, depending on where you store this partial.
<% number = + "/../../../REVISION").strip[0..7] if File.exists?(File.dirname(__FILE__) + "/../../../REVISION") %>
Commit: <%= number || "CURRENT" %>
danielpietzsch / table_alignment.css
Created April 19, 2010 04:35
How to align a HTML table inside a div
/* Align a table right inside a div element */
/* Adjust accordingly for centering the table */
div.contains_table {
text-align: right;
div.contains_table table {
margin-right: 0;
margin-left: auto;
danielpietzsch / load_config.rb
Created April 10, 2010 05:06
How to create your own global settings in Rails
# directory: config/initializers/
# only loads the values of the current environment
GLOBAL_VAR = YAML.load_file("#{Rails.root}/config/settings.yml")[Rails.env]