Skip to content

Instantly share code, notes, and snippets.

View grafikchaos's full-sized avatar

Josh J. grafikchaos

View GitHub Profile
@koraktor
koraktor / git-create-empty-branch.sh
Created March 26, 2009 08:04
Git: Creating an empty branch
git stash # Stash changes if any
git symbolic-ref HEAD refs/heads/${NEW_BRANCH} # Change head to a new, non-existing ref
git rm -rf . # Delete files from version control and working directory
rm -r . # Delete files from file system
git commit --allow-empty -m "Created new branch ${NEW_BRANCH}" # Commit changes in the new branch
@danmackinlay
danmackinlay / supervisord.sh
Created August 27, 2009 07:07
an init.d script for supervisord
#! /bin/sh
### BEGIN INIT INFO
# Provides: supervisord
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Example initscript
# Description: This file should be used to construct scripts to be
# placed in /etc/init.d.
@netzpirat
netzpirat / env.rb
Created November 18, 2009 19:22
Cucumber ActiveResource faking
require 'fakeweb'
require 'fake_resource'
ActiveResource::Base.send :include, ActiveResource::FakeResource
Before do
FakeWeb.allow_net_connect = false
end
After do |scenario|
ActiveResource::FakeResource.clean
#! /bin/sh
### BEGIN INIT INFO
# Provides: supervisord
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Example initscript
# Description: This file should be used to construct scripts to be
# placed in /etc/init.d.
#!/bin/bash
#
# supervisord This scripts turns supervisord on
#
# Author: Mike McGrath <mmcgrath@redhat.com> (based off yumupdatesd)
#
# chkconfig: - 95 04
#
# description: supervisor is a process control utility. It has a web based
# xmlrpc interface as well as a few other nifty features.
class CucumberExternalResqueWorker
DEFAULT_STARTUP_TIMEOUT = 1.minute
COUNTER_KEY = "cucumber:counter"
class << self
attr_accessor :pid, :startup_timeout
def start
# Call from a Cucumber support file so it is run on startup
return unless Rails.env.cucumber?
@grafikchaos
grafikchaos / Git update-index --assume-unchanged
Created June 15, 2011 14:28
Ignore uncommitted changes in tracked files with Git
# == IGNORE LOCAL CHANGES
# ignore local changes to repository files or directories
git update-index --assume-unchanged path/to/file/or/directory
# -- ALIAS
# or you can alias it in your ~/.gitconfig
[alias]
au = update-index --assume-unchanged
# == UN-IGNORE LOCAL CHANGES
@grafikchaos
grafikchaos / php error reporting
Created June 30, 2011 21:19
PHP Error Reporting for local development and debugging
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
@watson
watson / ability.rb
Created October 5, 2011 09:50
Active Admin CanCan integration with shared front/backend User model and multi-level autherization
# app/models/ability.rb
# All front end users are authorized using this class
class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new
can :read, :all
@randym
randym / getting_barred.rb
Created April 24, 2012 23:16
Axlxs: Writing Excel With Ruby - Conditional Formatting
require 'axlsx'
p = Axlsx::Package.new
p.workbook do |wb|
# define your regular styles
styles = wb.styles
title = styles.add_style :sz => 15, :b => true, :u => true
default = styles.add_style :border => Axlsx::STYLE_THIN_BORDER
header = styles.add_style :bg_color => '00', :fg_color => 'FF', :b => true
money = styles.add_style :format_code => '#,###,##0', :border => Axlsx::STYLE_THIN_BORDER
percent = styles.add_style :num_fmt => Axlsx::NUM_FMT_PERCENT, :border => Axlsx::STYLE_THIN_BORDER