Skip to content

Instantly share code, notes, and snippets.

#!/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

This is a proof-of-concept of a couple of concurrent data structures written in Ruby.

The implementations are heavily commented for those interested. There are benchmarks (with results) included below. The results are interesting, but, as always, take with a grain of salt.

Data structures

AtomicLinkedQueue is a lock-free queue, built on atomic CAS operations.