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 with mixins for common queries across descendants: | |
module Descendant | |
# I guess I could use ActiveSupport::Concern here... | |
def self.included(receiver) | |
receiver.extend ClassMethods | |
receiver.send :include, InstanceMethods | |
end | |
module ClassMethods | |
def self.included(receiver) |
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 "application_responder" | |
class ApplicationController < ActionController::Base | |
# ... | |
def self.acts_as_magical | |
around_filter :magic_new, :only => :new | |
around_filter :magic_show, :only => :show | |
around_filter :magic_edit, :only => :edit |
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
# Bits and pieces from my large, multi-file Sinatra app.. just to show structure | |
# ----- | |
# Main base Sinatra app setup | |
module Cio | |
class App < Sinatra::Base | |
configure do | |
# Set global vars | |
set :root, APP_ROOT |
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 'rubygems' | |
require 'mime/types' | |
require 'xmlrpc/client.rb' | |
require 'uri' | |
# WordPressr - WordPress posting client library for Ruby | |
# By Peter Cooper | |
# | |
# LICENSE: | |
# MIT, BSD, whatever. Use the code at your own risk, I'm not |
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
# Script to generate a CSV of all your Twitter followers screen_name, name, url, and description (bio) | |
# Runs fine on OS X: put into a file, and then from a Terminal: ruby whatever.rb to run. | |
require 'json' | |
puts "Enter your Twitter username:" | |
username = gets.chomp | |
puts "Enter your Twitter password:" | |
password = gets.chomp | |
NewerOlder