Skip to content

Instantly share code, notes, and snippets.

@Bivek
Bivek / gist:4386945
Created December 27, 2012 09:43
Transaction complete callback
{"task_id"=>"ZpN0lCQqbH",
"status"=>"Complete",
"started_at"=>"2012-12-24 20:38:17 -0800",
"completed_at"=>"2012-12-24 20:40:57 -0800",
"resources"=>
"[
{
\"image_url\":\"http://upload.wikimedia.org/wikipedia/commons/1/19/Tanzanian_Animals.jpg\",
\"TextInput1\":\"Zebra\",
\"extras\":{
#!/bin/bash
# Requirements: sed, grep, curl, pkill
# User configuration
LOCAL_INSTALL="/usr/lib/sublime-text-2" # Must be user-writable
REPO="dev" # "dev" for dev releases, or "2" for beta releases
TARGET_BUILD="Linux 32 bit" # can be one of "Windows", "Windows 64 bit", "OS X", "Linux 32 bit", "Linux 64 bit"
# Check if sublime text is running
@Bivek
Bivek / .rspec
Created September 3, 2013 09:21 — forked from coreyhaines/.rspec
--colour
-I app
# inspired by http://blog.leshill.org/blog/2011/10/23/fast-specs.html
# to get specs running without rails (faster) do
# SKIP_RAILS=yes time bundle exec rspec
# or
# SKIP_RAILS=yes time bundle exec guard
# spec_helper
module FactoryGirlAdditions
# create instance without running callbacks and validations
def insert(*args)
record = FactoryGirl.build(*args)
def record.run_callbacks(*args, &block)
if block_given?
block.arity.zero? ? yield : yield(self)
end
end
record.save!
# This custom matcher can be used to test state machine
#
# Examples
#
# it { should have_event(:status, :event_name, [:state1, :state2] => [:state3, :state4]) }
# it { should have_event(:status, :event_name, {
# :state1 => :state3,
# :state1 => :state4,
# :state3 => :state3,
# :state2 => :state4
# This custom matcher can be used to test state machine
#
# Examples
#
# it { should have_event(:status, :event_name, [:state1, :state2] => [:state3, :state4]) }
# it { should have_event(:status, :event_name, {
# :state1 => :state3,
# :state1 => :state4,
# :state3 => :state3,
# :state2 => :state4
---
# ^^^ YAML documents must begin with the document separator "---"
#
#### Example docblock, I like to put a descriptive comment at the top of my
#### playbooks.
#
# Overview: Playbook to bootstrap a new host for configuration management.
# Applies to: production
# Description:
# Ensures that a host is configured for management with Ansible.
#!/bin/sh
# Script to perform consistency checks on replicated MySQL databases
#
# (c) Alex Williams - 2009 - www.alexwilliams.ca
#
# v0.1
#
# Options:
# -c Check for inconsistent slaves
class ApiLogger < Grape::Middleware::Base
def before
Rails.logger.info "[api] Requested: #{request_log_data.to_json}\n" +
"[api] #{response_log_data[:description]} #{response_log_data[:source_file]}:#{response_log_data[:source_line]}"
end
private
def request_log_data