This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
####################################################### | |
# Add this to app/controllers/application_controller.rb | |
####################################################### | |
def render_json_response(type, hash) | |
unless [ :ok, :redirect, :error ].include?(type) | |
raise "Invalid json response type: #{type}" | |
end | |
# To keep the structure consistent, we'll build the json | |
# structure with the default properties. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'minitest/unit' | |
require 'minitest/spec' | |
require 'rubygems' | |
require 'ansi' | |
class MiniTest::Unit | |
include ANSI::Code | |
PADDING_SIZE = 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RewriteEngine On | |
RewriteCond %{SCRIPT_FILENAME} !-d | |
RewriteCond %{SCRIPT_FILENAME} !-f | |
RewriteRule .* index.php [L] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# corresponding rails action that handles the js_message call. Note the format.jsm calls in the | |
# respond_to block | |
def create | |
@task = Task.new(params[:task]) | |
respond_to do |format| | |
if @task.save | |
format.html { redirect_to(tasks_path, :notice => 'Task was successfully created.') } | |
format.jsm do | |
render_js_message(:ok, :html => "it saved!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git status -s | awk '{print $2}' | sed 's/\(.*\)/rsync -cav \1 [email protected]:~\/\1/' | sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create a context block like rspec. | |
# | |
# Inspired by: | |
# - MiniTest::Spec | |
# - Chris Wanstrath's https://gist.github.com/25455 | |
# | |
# Examples: | |
# | |
# class UserTest < ActiveSupport::TestCase | |
# context "Auth" do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lsof -i TCP:80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# This script is run as the 'hadoop' user - which means any commands | |
# that create/update privileged areas must use sudo. | |
# Print out every command executed in this script. | |
set -x | |
# Exit this script if any of the commands below fail. | |
set -e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
case $1 in | |
start) | |
PID=$(start statsd | awk '{print $4}'); | |
echo $PID > /var/run/statsd.pid; | |
;; | |
stop) | |
kill `cat /var/run/statsd.pid` ;; | |
*) |
OlderNewer