Skip to content

Instantly share code, notes, and snippets.

View andyjeffries's full-sized avatar

Andy Jeffries andyjeffries

View GitHub Profile
@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}"`

The following articles were sent after a conversation I had about the fact that people need 8-10 glasses of water per day. I had read that this wasn’t the case it was a single scientist a long while ago and pretty much every scientist since then that’s studied it has found it to be crap. Below are the references I found. Note, I’m not saying that you shouldn’t drink that much water if you want to, but that if you don’t want to you shouldn’t have to.

_After an extensive search in 2002 for the origins of what is commonly referred to as the “8 × 8” guideline and areview of associated health claims, hereports finding no scientific evidence supporting the notion that healthy individuals need to consume large quantities of water. In 2008 Dan Negoianu and Stanley Goldfarb reviewed the evidence for the Journal of the American Society of Nephrology. They came to a similar conclusion: “There is no clear evidence of benefit from drinking increased amounts of water.”…come from a variety of sources—including coffee,