This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# faux-wget.rb : example of performing wget-style mirroring | |
require 'nokogiri' | |
require 'net/http' | |
require 'fileutils' | |
require 'uri' | |
require 'pp' | |
=begin rdoc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rest-client' | |
require 'ap' | |
response = RestClient.get 'https://ip-ranges.amazonaws.com/ip-ranges.json', accept: :json | |
hash = JSON.parse(response.body) | |
regions = hash['prefixes'] | |
ranges = [] | |
regions.each do |region| | |
ranges << region['ip_prefix'] if region['region'] == 'eu-west-1' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
["46.51.128.0/18", | |
"46.51.192.0/20", | |
"46.137.0.0/17", | |
"46.137.128.0/18", | |
"52.16.0.0/15", | |
"52.18.0.0/15", | |
"52.30.0.0/15", | |
"52.48.0.0/14", | |
"52.92.40.0/21", | |
"52.93.0.0/24", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Query CCR database | |
Get bills on cases for AGFS scheme 10 with a caclulation date > 2/1/2015 | |
*/ | |
select | |
c.id, | |
s.psty_highest_level, | |
b.bity_bill_type, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :db do | |
task :pop => :environment do | |
include FactoryGirl::Syntax::Methods | |
Person.where('surname like ?', 'Me%').map(&:destroy) | |
names = [ | |
%w{ Nicky Meadhurst }, | |
%w{ Nicola Meadhurst }, | |
%w{ Nicky Medhurst }, | |
%w{ Nicola Medhurst }, | |
%w{ Jane Meadhurst }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# use as DbCounter.new.run | |
class DbRrecordCounter | |
def initialize | |
@conn = ActiveRecord::Base.connection | |
end | |
def run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rails.application.routes.routes.each do |route| | |
d = route.defaults | |
next unless d.key?(:controller) | |
next if d[:internal] == true | |
puts "#{d[:controller]}/#{d[:action]}" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Person < ApplicationRecord | |
validates_with PersonValidator | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class OysterCardsController < ApplicationController | |
def index | |
@cards = OysterCard.order(balance: :desc) | |
end | |
def show | |
end | |
def swipe_out |
OlderNewer