Skip to content

Instantly share code, notes, and snippets.

View grafikchaos's full-sized avatar

Josh J. grafikchaos

View GitHub Profile

Deploy Rails app to digitalocean with nginx, unicorn, capistrano & postgres

Create droplet of your liking (ubuntu 12.10 x32)

ssh to root in terminal with your server ip

ssh root@123.123.123.123

Add ssh fingerprint and enter password provided in email

// Post repeat directive for logging the rendering time
angular.module('myApp').directive('postRepeatDirective',
['$timeout',
function($timeout) {
return function(scope) {
if (scope.$first)
window.a = new Date(); // window.a can be updated anywhere if to reset counter at some action if ng-repeat is not getting started from $first
if (scope.$last)
$timeout(function(){
console.log("## DOM rendering list took: " + (new Date() - window.a) + " ms");
# Install `dnsmasq` and configure for *.dev domains
$ brew install dnsmasq
$ vim /usr/local/etc/dnsmasq.conf
# Reload configuration and clear cache
$ sudo launchctl unload /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
$ sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
$ dscacheutil -flushcache
@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);
@grafikchaos
grafikchaos / WordPress Contact Form 7 - defining WPCF7_PLUGIN_NAME correctly patch
Created July 27, 2011 21:50
Patch for correctly naming the WPCF7_PLUGIN_NAME constant using the basename() function
diff --git a/wp-content/plugins/contact-form-7/wp-contact-form-7.php b/wp-content/plugins/contact-form-7/wp-contact-form-7.php
index ea9427f..b8549e2 100644
--- a/wp-content/plugins/contact-form-7/wp-contact-form-7.php
+++ b/wp-content/plugins/contact-form-7/wp-contact-form-7.php
@@ -30,8 +30,9 @@ define( 'WPCF7_VERSION', '2.4.6' );
if ( ! defined( 'WPCF7_PLUGIN_BASENAME' ) )
define( 'WPCF7_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
-if ( ! defined( 'WPCF7_PLUGIN_NAME' ) )
- define( 'WPCF7_PLUGIN_NAME', trim( dirname( WPCF7_PLUGIN_BASENAME ), '/' ) );
@grafikchaos
grafikchaos / WordPress plugin_basename patch
Created July 28, 2011 15:49
patch for WordPress plugin_basename() to correctly handle local files and symlinked files
EDIT: removed the first patch b/c it wasn't completely correct. Below is the complete patch that should be applied.
diff --git a/wp-includes/plugin.php b/wp-includes/plugin.php
index 5bc475d..5b5e693 100644
--- a/wp-includes/plugin.php
+++ b/wp-includes/plugin.php
@@ -568,10 +568,12 @@ function plugin_basename($file) {
$mu_plugin_dir = preg_replace('|/+|','/', $mu_plugin_dir); // remove any duplicate slash
@grafikchaos
grafikchaos / gist:1165560
Created August 23, 2011 15:54 — forked from petemcw/gist:1165317
Command-line Magic

Regular Expressions

Not only useful in programming, regular expressions can make complex tasks easy in many different scenarios. Here is a great site for testing your regex:

http://rubular.com

General Shell

Run the previous command again

@grafikchaos
grafikchaos / tell vim to STFU about not having permission to save a file
Created August 23, 2011 16:50
Save files in vim even if you forgot to edit as root
:w !sudo tee %
@grafikchaos
grafikchaos / gist:1622609
Created January 16, 2012 19:50
Cucumber + Spork env.rb
require 'rubygems'
require 'spork'
Spork.prefork do
require 'simplecov'
# SimpleCov.start 'rails'
require 'cucumber/rails'
require 'factory_girl/step_definitions'
require 'email_spec'