Skip to content

Instantly share code, notes, and snippets.

View jamesmoriarty's full-sized avatar
🔮
0xc0000005

James Moriarty jamesmoriarty

🔮
0xc0000005
View GitHub Profile
@jamesmoriarty
jamesmoriarty / Vagrantfile
Created September 27, 2014 05:18
Vagrant, Ansible, Rbenv and Ruby on Rails
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.network :forwarded_port, guest: 3000, host: 3000
config.vm.box = "precise"
@bguthrie
bguthrie / libxml_active_resource.rb
Created January 31, 2009 23:28
A patch for ActiveResource that allows it to use LibXML to parse documents. Use to speed up ARes.
require 'libxml'
module LibXML
module XML
module Conversions
module Document
def to_hash
root.to_hash
end
end
# an example Monit configuration file for collectiveidea's fork of delayed_job.
# See: http://stackoverflow.com/questions/1226302/how-to-monitor-delayedjob-with-monit/1285611
#
# To use:
# 1. replace {app_name} and {environment} as appropriate
# 2. copy to your repository under config/delayed_job.monitrc
# 3. add this to your /etc/monit/monitrc:
#
# include /var/www/apps/{app_name}/current/config/*.monitrc
# 4. reload monit when you deploy to pick up any changes to your monitrc files: sudo monit reload
From 36f25bf11b9e61b6361c829534dea2de0cf08acd Mon Sep 17 00:00:00 2001
From: Chris Hapgood <cch1@hapgoods.com>
Date: Mon, 11 Oct 2010 09:42:05 -0400
Subject: [PATCH] Let respond_to do the heavy action cache lifting
In determining the best content type for a response, let respond_to consider
available content types using existing logic. Work hard to ensure that
cached content has an extension to indicate its content type.
---
.../lib/action_controller/caching/actions.rb | 73 ++++++++++----------
@bradleypriest
bradleypriest / arel_scopes.rb
Created September 18, 2011 08:27
Arel Scopes
module ArelScopes
extend ActiveSupport::Concern
module ClassMethods
# Create chainable arel scopes
# Example:
# class Post
# arel_scope :published, lambda { arel_table[:published_at].gteq(Time.now) }
# arel_scope :written_by, lambda { |user| arel_table[:author_id].eq(user.id) }
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
gem 'rails', github: 'rails/rails'
@jjb
jjb / gist:950975
Created May 1, 2011 23:16
Using whenever with capistrano and bundler in multiple environments
We couldn’t find that file to show.
@jamesmoriarty
jamesmoriarty / query.rb
Last active April 29, 2016 19:30
Newrelic Insights Query
require 'net/http'
require 'uri'
require 'json'
module NewRelic
module Insights
class Query
attr_reader :key, :account_id
def initialize(key, account_id)
@bethesque
bethesque / hipster-batch-in-ruby.md
Last active May 2, 2016 07:02
A way to write a hipster batch microservice in Ruby
  1. Identify the steps in the high level process

    eg.

    • Step 1: Download CSV files from box
    • Step 2: Convert CSV to JSON
    • Step 3: Upload JSON and CSV files to S3
  2. Create modules for each of those steps. In our use case, the top level process matches a pattern called "ETL" or "Extract, Transform, Load", so we used those names.