Skip to content

Instantly share code, notes, and snippets.

View andyjeffries's full-sized avatar

Andy Jeffries andyjeffries

View GitHub Profile
@andyjeffries
andyjeffries / example.rb
Created May 6, 2015 08:32
Example ARC for Abel
require "faraday"
class Customer < ActiveRestClient::Base
base_url "http://requestb.in"
ActiveRestClient::Base.faraday_config do |faraday|
faraday.adapter(:net_http)
faraday.options.timeout = 20
faraday.headers['User-Agent'] = "ActiveRestClient/#{ActiveRestClient::VERSION}"
end
@andyjeffries
andyjeffries / Gemfile
Created June 16, 2014 09:26
Rails 4.1 Default Files
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.1'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# Use Uglifier as compressor for JavaScript assets
@andyjeffries
andyjeffries / user.rb
Created May 3, 2014 11:06
ARC before_filter example for David Tolsma
class User < ActiveRestClient::Base
before_filter do |name, request|
request.headers["Authorization"] = request.get_params[:authorization]
end
get :find, "/users/:id"
end
@andyjeffries
andyjeffries / hash.rb
Created January 24, 2014 11:35
Full HTML page (with asset) hashing
#!/usr/bin/env ruby
require 'tmpdir'
require 'digest/sha1'
hash = ""
Dir.mktmpdir do |dir|
`cd #{dir} && wget -E -H -k -K -q -p #{ARGV[0]}`
Dir["#{dir}/**/*"].each do |filename|
unless File.directory?(filename)
# puts filename
{
"name" : "John"
}
@andyjeffries
andyjeffries / output.json
Created August 28, 2013 14:39
Sample JSON output for technical test
[
{"team": "Liverpool FC", "points": 88},
{"team": "Manchester Utd", "points": 77}
]
» CustomerManagementRenewal.find_simple_offer("413AIJ")
HTTPI GET request to cmr-integration-lb.which.co.uk (httpclient)
SOAP request: https://cmr-integration-lb.which.co.uk/marketing-services
SOAPAction: "", Content-Type: text/xml;charset=UTF-8, Content-Length: 400
<?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="which-cmr-1.0" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Body><tns:findSimpleOffer><simpleOfferQuery><advertCode>413AIJ</advertCode><channel>WEB</channel></simpleOfferQuery></tns:findSimpleOffer></env:Body></env:Envelope>
HTTPI POST request to cmr-integration-lb.which.co.uk (httpclient)
SOAP response (status 200)
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:findSimpleOfferResponse xmlns:ns2="which-cmr-1.0"><campaignedOffers><campaignedOffer><campaignId>1110</campaignId><campaignName>5KY975</campaignName><offerId>1655</offerId><off

Asset Compilation Options

The Problem

The problem at the moment stems from the fact that the frontend assets are developed in this style:

.foo {
  background: url(../img/bar.png);   /* Sometimes ../images/ */
}
@andyjeffries
andyjeffries / gist:2006182
Created March 9, 2012 11:38
messagepack vs yajl
11:34 ~ $ irb
1.9.2p290 :001 > require 'rubygems'
=> false
1.9.2p290 :002 > require 'json'
=> true
1.9.2p290 :003 > require 'msgpack'
=> true
1.9.2p290 :004 > f = File.read('test.json'); nil # f is our calendar data
=> nil
1.9.2p290 :005 > h = JSON.parse(f); nil
@andyjeffries
andyjeffries / psg
Created August 19, 2011 10:41
Process Grepper and Killer for Mac OS X
#!/usr/bin/env ruby
kill = false
name = ARGV[0]
if (name == "-k")
kill = true
name = ARGV[1]
end
if name
ps = `ps axwu|grep -i [#{name[0..0]}]#{name[1..1000]}|grep -v " #{Process.pid}"`