Skip to content

Instantly share code, notes, and snippets.

View xmjw's full-sized avatar

Michael Wawra xmjw

View GitHub Profile
@xmjw
xmjw / parser.rb
Created June 27, 2018 12:05
Parses HTML from Ofsted Search and converts it to a nice CSV
# Parses results from Ofsted Search into a clean CSV
# Sample data from Ofsted:
# <li>
# <h3 class="search-result__title heading--main">
# <a href="/provider/16/EY546864">Little Pips</a>
# </h3>
# <address class="search-result__address">William Sutton Trust Rotherhithe Estate Office, 30 Plough Way, London, SE16 2LJ</address>
# <strong class="address-distance">0.19 miles</strong>
# <div class="search-result__provider-rating search-result__provider-rating--none">
# <button class="js-toggle-info expander-see-more btn-nostyle">No report yet – Why?</button>
class A
def say_my(name='')
puts "Called with: #{name}"
end
end
class B < A
def say_my(name)
super
end
@xmjw
xmjw / gist:99d8ae0436eb7eb55d4b
Created February 11, 2015 11:09
RSpec Segfault
class MyThing
end
RSpec.shared_examples 'a thing that causes a segfault' do
it 'segfaults' do
expect(true).to eq(true)
end
end
RSpec.describe MyThing do
<HTML>
<H1>Q</H1>
</HTML>
@xmjw
xmjw / demo_app.rb
Created July 16, 2014 17:17
Twilio Demo in Ruby
# Need the Sinatra Library to make a web app!
require 'sinatra'
# This is the URL that can be used for the Voice URL on your Twilio Number
post '/messages' do
content_type 'text/xml'
"<Response>
<Message>This is an SMS reply.</Message>
</Response>"
end

Keybase proof

I hereby claim:

  • I am xmjw on github.
  • I am xmjw (https://keybase.io/xmjw) on keybase.
  • I have a public key whose fingerprint is 741F 4ABC BB34 B93E 3236 AF30 2821 AF5B D66D 5F20

To claim this, I am signing this object:

@xmjw
xmjw / irb.rb
Last active August 29, 2015 13:58
Makers Twilio Stuff
require 'twilio-ruby'
client = Twilio::REST::Client.new "Your twilio SID", "Tour twilio Token"
#Send SMS...
client.account.messages.create(to: "+44 your number", from: "+44a twilio number", body: "the contents of your message")
#Make a call...
client.account.calls.create(to: "+44 your number", from: "+44a twilio number", url: "http://blahblah.ngrok.com/cheese")
@xmjw
xmjw / sms-hue_configure.rb
Last active December 21, 2015 07:18
Illuminating SMS
configure do
set :hue_user, ENV['HUE_USERNAME']
set :hue_ip, ENV['HUE_IP']
set :hue_bulb, ENV['HUE_BULB']
end
@xmjw
xmjw / Call_Handler.rb (Build)
Last active December 20, 2015 01:59
Sample code for Twilio IVR Blog. Demonstrates how to create a run a simple IVR System.
get '/build' do
Step.create_tree
"DONE"
end
@xmjw
xmjw / colourize.rb
Last active October 13, 2015 04:47
Ruby Console Colourisation Methods - now refactored to be 'ruby style'
module Colourize
#We do not want to use method_missing because this is a module, not a class, and it will cause hell for everyone else.
#Foreground colours...
{ black: 30, red: 31, green: 32, yellow: 33, purple: 34, fuscia: 35, blue: 36, bold: 1, grey: 2, underline: 4, blink: 5}.each do |c,v|
define_method("fg_"+c.to_s) { |text| colourize_text v, text }
end
{grey: 7, red: 41, green: 42, yellow: 43, purple: 44, fuscia: 45, blue: 46, white: 47}.each do |c,v|