Skip to content

Instantly share code, notes, and snippets.

View cblunt's full-sized avatar
👨‍💻
Coding

Chris Blunt cblunt

👨‍💻
Coding
View GitHub Profile
@cblunt
cblunt / spec_support.rb
Created February 27, 2012 13:36
Handy helper methods for RSpecs, e.g. logging in as a user.
# spec/support/spec_support.rb
def login_as(user = nil)
user ||= Factory.create(:user)
session[:user_id] = user.id
end
def current_user
User.find(session[:user_id])
rescue
@cblunt
cblunt / codebase-import-tickets.rb
Created February 8, 2013 12:56
A simple Ruby script to bulk import a list of tickets into CodeBase (http://codebasehq.com). Depends on the codebase_api gem.
require 'rubygems'
# 1. Without Bundler
# $ gem install activesupport codebase_api
require 'active_support/core_ext/string'
require 'codebase_api'
# 2. With a Bundler Gemfile:
# # ./Gemfile
# gem 'codebase_api'
@cblunt
cblunt / freeagent_api_notes.md
Last active December 17, 2015 23:29
Notes from working with the FreeAgent API

Sample

{ "expense":
  {
    "user":"https://api.freeagent.com/v2/users/93049",
    "category":"https://api.freeagent.com/v2/categories/249",
    "dated_on":"2013-05-08",
    "gross_value":"-100.0", # Note required if a mileage expense
    "sales_tax_rate":"20.0",

"description":"TEST expense from API",

@cblunt
cblunt / README.md
Last active December 23, 2015 12:19
A simple widget for Dashing (http://http://shopify.github.io/dashing) to retrieve open and overdue invoices from FreeAgent and display their total value.

Description

A simple Dashing job to display the total value of open/overdue invoices from FreeAgent.

Dependencies

An app id/secret and access token setup via FreeAgent Developer.

Freeagent Api Gem

Add it to dashing's gemfile:

@cblunt
cblunt / rails_app_template.rb
Last active July 18, 2016 04:21
Rails 4 App Template
# Creates a new Rails 4 application configured with
# Slim, PostgreSQL, TestUnit (minitest), FactoryGirl, SimpleCov, Capybara, Capistrano ...
#
# Based on template generated at http://railswizard.org/
# USAGE
# $ rails new APP_NAME -JTm rails_app_template.rb
# Will be specified by default Gemfile
# gem 'rails', '4.2.0'
@cblunt
cblunt / myapp
Last active November 26, 2016 22:57
Rails app init.d script for passenger-standalone
#!/bin/bash
### BEGIN INIT INFO
# Provides: myapp passenger in standalone
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# X-Interactive: true
# Short-Description: Start/stop myapp.com web site
### END INIT INFO
#PATH=/sbin:/usr/sbin:/bin:/usr/bin
@cblunt
cblunt / docker-compose.1.yml
Last active August 7, 2018 12:54
Linking Containers across Multiple Docker Compose Projects
version: '3.2'
networks:
default:
external:
name: my_net # Needs to be manually created using docker network create
services:
nginx:
image: jwilder/nginx-proxy
@cblunt
cblunt / tag_list_issue.rb
Last active October 25, 2018 10:32
Bug when versioning tag_list using paper-trail (10.0) and acts as taggable on (6.0)
# frozen_string_literal: true
# Use this template to report PaperTrail bugs.
# Please include only the minimum code necessary to reproduce your issue.
require 'bundler/inline'
gemfile(true) do
ruby '2.5.3'
source 'https://rubygems.org'
gem 'activerecord', '5.2.1'
@cblunt
cblunt / application_helper_spec.rb
Created November 27, 2011 15:36
Testing content_for Helper Methods with RSpec
# Solution from http://www.jamiepenney.co.nz/2011/09/23/testing-content_for-in-rails-3-x-helpers-with-rspec/
describe ApplicationHelper do
describe "title" do
it "should return an h2 tag with the given title" do
helper.title("Lorem Ipsum")
helper.content_for(:page_title).should eql "<h2>Lorem Ipsum</h2>"
end
it "should return the supplied block if a block was given" do
class MainActivity extends Activity {
// mEntries in this case is just an ArrayList store
private ArrayList<String> mEntries;
// ...
// Fetch method
private void fetch(RequestQueue requestQueue) {
JsonArrayRequest request = new JsonArrayRequest("http://example.com/feed.json",
new Response.Listener<JSONArray>() {