Skip to content

Instantly share code, notes, and snippets.

View andyzei's full-sized avatar

Andy Zeigler andyzei

View GitHub Profile
@andyzei
andyzei / selectively_optimistically_lockable.rb
Created May 28, 2015 21:58
SelectivelyOptimisticallyLockable for Rails 4+. Like the other gist, but doesn't override #update, which no longer exists. Also, it supports attribute lists in skip_optimistic_locking.
# Allows filtering out attributes that increment the ActiveRecord optimistic lock version, e.g. updated_at, or
# other attributes that will not cause a conflict issue.
module SelectivelyOptimisticallyLockable
extend ActiveSupport::Concern
private
def locking_enabled?
self.changed.any? {|att| !self.class.skips_optimistic_locking?(att) }
@owainlewis
owainlewis / deploy.rb
Last active January 2, 2016 05:49
Capistrano config for client site
set :application, ''
set :repo_url, 'git@yoursite.git'
set :deploy_to, '/var/www/sitename'
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
set :keep_releases, 5
set :sudo, true
set :rbenv_type, :user
set :rbenv_ruby, '2.0.0-p353'
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active March 16, 2026 20:09
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@shunchu
shunchu / convert-seconds-into-hh-mm-ss-in-ruby.rb
Created July 25, 2012 07:58
Convert seconds into HH:MM:SS in Ruby
t = 236 # seconds
Time.at(t).utc.strftime("%H:%M:%S")
=> "00:03:56"
# Reference
# http://stackoverflow.com/questions/3963930/ruby-rails-how-to-convert-seconds-to-time
@jgeurts
jgeurts / install-graphite-ubuntu-12.04.sh
Created July 14, 2012 16:36 — forked from tkoeppen/install-graphite-ubuntu-10.04.sh
Install Graphite 0.9.10 on Ubuntu 12.04
####################################
# BASIC REQUIREMENTS
# http://graphite.wikidot.com/installation
# http://geek.michaelgrace.org/2011/09/how-to-install-graphite-on-ubuntu/
# Last tested & updated 10/13/2011
####################################
cd
sudo apt-get update
sudo apt-get upgrade
@chalmerj
chalmerj / gist:1492384
Created December 18, 2011 04:39
Init script for Graphite carbon-cache
#! /bin/sh
### BEGIN INIT INFO
# Provides: carbon-cache
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: carbon-cache init script
# Description: An init script for Graphite's carbon-cache daemon.
### END INIT INFO