Skip to content

Instantly share code, notes, and snippets.

View svperfecta's full-sized avatar
👾

Brian Corrigan svperfecta

👾
View GitHub Profile
@svperfecta
svperfecta / gist:2853467
Created June 1, 2012 16:43
Rakefile to Generate Emacs CTAGS
# Generate TAGS files with bundler projects. Bundle must be updated, and tags binary
# must be exuberant ctags.
namespace :tags do
namespace :generate do
desc <<-EOT
Generate a new emacs TAGS file for the current project.
Requires exuberant ctags and bundler.
EOT
task :emacs do
@svperfecta
svperfecta / gist:2870878
Created June 4, 2012 21:12
Unicorn Active Connection Monitoring
#!/usr/bin/env ruby
# Copyright: 2011 Opscode, Inc.
# Author: Bryan McLellan <btm@loftninjas.org>
# Modified by: Brian Corrigan 2012
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
@svperfecta
svperfecta / gist:2875910
Created June 5, 2012 15:56
Submitting GIT patches via email
# Add something to my last commit (forgot a comment!)
git commit --amend -m "New commit message"
# Merge my last two commits
git rebase --interactive HEAD~2
# Create the patch file
git format-patch HEAD~..HEAD
@svperfecta
svperfecta / gist:2896918
Created June 8, 2012 17:07
Random Snippets
# Uninstall all ruby gems
gem list | cut -d" " -f1 | xargs gem uninstall -aIx
# Useful SSH Escape Characters
~. Disconnect.
~^Z Background ssh.
~? Display a list of escape characters.
@svperfecta
svperfecta / gist:2901849
Created June 9, 2012 17:17
Fixing Sphinx
# Error
[Sat Jun 9 17:03:13.111 2012] [ 4912] WARNING: rotating index 'swf_fulltext': rename '/data/sphinx/swf_fulltext.sps' to '/data/lib/sphinx/swf_fulltext.old.sps' failed: No such file or directory
[Sat Jun 9 17:03:13.112 2012] [ 4912] WARNING: rotating index 'swf_fulltext': rename to .old failed; using old index
# Fix
touch /data/lib/swf_fulltext.sps
@svperfecta
svperfecta / gist:3686904
Created September 9, 2012 20:04
Useful PHP Stuff
Show where headers are being output:
if (headers_sent($filename, $linenum)) {
echo "Headers already sent in $filename on line $linenum\n";
}
@svperfecta
svperfecta / git stuff
Last active October 10, 2015 12:37
Useful Git Stuff
# Display short hash
git rev-parse --short HEAD
# Delete all merged local branches
git branch --merged | grep -v '^* master$' | grep -v '^ master$' | xargs git branch -d
# Pretty git log (shows branches)
alias gg='git log --oneline --abbrev-commit --all --graph --decorate --color'
# Diff a file against the last change
@svperfecta
svperfecta / gist:5644646
Last active December 17, 2015 17:18
Simple default values for KnockoutJS ViewModels
// Knockout, it's just javascript folks.
var Foo = function(data) {
var that = this;
/*
* ========
* Map Data
* ========
*/
@svperfecta
svperfecta / classpattern.js
Last active December 19, 2015 15:29
Javascript Class Pattern
var Toggler = (function() {
var totalTogglers = 0;
var Toggler = function() {
this.linkSelector = ".detail_toggle";
this.detailSelector = ".detail";
this.hiddenClass = "hidden";
this.hideText = "Hide Details";
this.showText = "Show Details";
};
Toggler.prototype = {
@svperfecta
svperfecta / ruby
Created November 21, 2013 18:48
Ruby Bits
Always install Gems into a local directory:
bundle install --path ruby_modules --binstubs