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 String | |
def slugify | |
returning self.downcase.gsub(/'/, '').gsub(/\//, ' ').gsub(/&/, ' and ').gsub(/[^a-z0-9]+/, '-') do |slug| | |
slug.chop! if slug.last == '-' | |
end | |
end | |
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
module ActionController | |
module Routing | |
class RouteSet | |
class Mapper | |
def hush_cms_pages(path) | |
named_route 'hush_cms_page', | |
"#{path}/*path", | |
:controller => HushCMS.configuration['controllers']['pages'], | |
:action => 'show' | |
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
module TMail | |
class Mail | |
def plain_text_body | |
gather_plain_text_parts(self).flatten | |
end | |
private | |
def gather_plain_text_parts(part) | |
returning [] do |message| | |
message << part.body.strip if part.content_type == 'text/plain' |
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
#!/bin/bash | |
# configuration | |
PROJECT_NAME='Foo' | |
PATH_TO_BACKUPS='/backups/foo_database_backups' | |
RECIPIENT_EMAIL='[email protected]' | |
DATABASE_USERNAME='root' | |
DATABASE_PASSWORD='password' | |
DATABASE_DATABASE='database_name' | |
# end of configuration. should not need to edit from this point |
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/ruby | |
require 'rubygems' | |
require 'nokogiri' | |
require 'open-uri' | |
doc = Nokogiri::HTML(open('http://www.sportingpulse.com/comp_info.cgi?a=FIXTURE&compID=107624&c=1-4401-0-0-0')) | |
against = doc.xpath('//*[text()="Owned"]').first.xpath('../../..//b[text()!="Owned"]').first.text | |
time = doc.xpath('//*[text()="Owned"]').first.xpath('../../../td').first.inner_html.gsub(/\302\240/, ' ').gsub('<br>', ', ') | |
puts "Owned play #{against} at #{time}\n\n" |
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
$('#element').plugin(); // calls init | |
$('#element').plugin({ foo: 'bar' }); // calls init and extends the hash into settings | |
$('#element').plugin('doSomething'); // calls init (if it hasn't already been done) and calls doSomething | |
$('#element').plugin('doSomething', { cake: 'delicious' }); // calls init and calls doSomething with the provided argument |
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 | |
# Example usage | |
# DBAnalyzer.rb general-query.log | |
class DBAnalyzer | |
OPERATIONS = %w(SELECT) | |
SHOW_TOP = 10 |
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 TeamBuilder | |
attr_accessor :name | |
attr_accessor :members | |
def initialize(name) | |
self.name = name | |
self.members = [] | |
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
openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout domain.key -out domain.crt |
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
def internal_request(path, params={}) | |
request_env = Rack::MockRequest.env_for(path, params: params.to_query).merge({ | |
'rack.session' => session | |
}) | |
Rails.application.routes.call(request_env).last.body | |
end |
OlderNewer