Skip to content

Instantly share code, notes, and snippets.

View scottmatthewman's full-sized avatar
🏳️‍🌈

Scott Matthewman scottmatthewman

🏳️‍🌈
View GitHub Profile
@jehiah
jehiah / bitly.rb
Created February 25, 2011 04:46 — forked from richardtifelt/bitly.rb
# Bit.ly API implementation - thanks to Richard Johansso http://gist.github.com/112191
require 'httparty'
class Api::Bitly
include HTTParty
base_uri 'api.bit.ly'
format :json
# Usage: Bitly.shorten("http://example.com")
def self.shorten(url)
@matherton
matherton / Update Eventbrite form
Created September 23, 2011 10:20
Simple Eventbrite create venue and event form
<html>
<head>
<title>Event creation form</title>
</head>
<!-- All strings - These are mandatory fields title, start_date, end_date, timezone. The description is optional but guess we would require -->
<body>
<!-- A form to create an event and passes it's variables to event_creator.php -->
<form method="post" action="event_creator.php">
<fieldset>
@scottmatthewman
scottmatthewman / example_view.html.erb
Created December 13, 2011 10:58
Add a helper to aid prototyping using Placehold.it images
<%= placeholder_image(728, 90, name: 'IAB Leaderboard ad', background_color: 'ccc') %>
@mscoutermarsh
mscoutermarsh / application.rb
Created December 15, 2012 18:35
CORS - rails/grape
# Add this to your application.rb
config.middleware.use Rack::Cors do
allow do
origins '*'
# location of your API
resource '/api/*', :headers => :any, :methods => [:get, :post, :options, :put]
end
end
@mudge
mudge / en.rb
Last active September 5, 2023 09:32
Using date ordinals in Rails through an I18n time format.
# This goes in config/locales/en.rb (*not* en.yml)
{
:en => {
:time => {
:formats => {
:full => lambda { |time, _| "%H:%M | %A, #{time.day.ordinalize} %B %Y" }
}
}
}
}
@Najaf
Najaf / mechanize-cheat-sheet.rb
Last active October 15, 2019 11:17
Mechanize Cheat Sheet, take a look at the real documentation here: http://mechanize.rubyforge.org/
# Initialize Mechanize Agent
agent = Mechanize.new
# Visit a web page
agent.get 'http://localhost:3000/'
# get the url of the current page
agent.page.uri #=> http://localhost:3000
# agent remembers the scheme + host, so no need to supply it when navigating somewhere else
// wanted a version where i could just use reduce but without building a Frame object ...
// expands rolls to include bonus values, e.g.
func testExpandRolls() {
let game = BowlingGame()
game.roll(5,4, 10, 5,5, 6,5)
var expanded = game.expandRolls()
XCTAssertEqualObjects(expanded, [5,4, 10,5,5, 5,5,6, 6,5], "expanded")
}
@RonJeffries
RonJeffries / payroll playground 1
Last active October 14, 2015 16:39
A Swift Playground for payroll. I have my reasons ...
// Swift playground experimenting with payroll.
// (I have my reasons.)
println("Hello")
import Foundation
// This stuff sets rounding to two places after decimal
var mode = NSRoundingMode.RoundPlain