Skip to content

Instantly share code, notes, and snippets.

View dhrrgn's full-sized avatar
🦙

Dan Horrigan dhrrgn

🦙
  • OH, USA
  • 21:53 (UTC -04:00)
View GitHub Profile
<?php
class Controller_Blog extends Controller {
/**
* This is a simple example, the class does not exist. There are much more
* things you would be able to do, this is just an example.
*
* Yes, I know this is all (kind of) currently possible, but this encapsulates
* the response and allows for nice things like advanced response caching.
@dhrrgn
dhrrgn / init.rb
Created April 1, 2011 00:19
A simple initialization script to create vhosts.
#!/usr/bin/env ruby
# USAGE: sudo ./init.rb project_name path/to/web/root
# NOTE: This file must be run with root privileges (sudo).
# You must also give it exec permissions: chmod +x init.rb
# This should include the trailing slash
DEFAULT_ROOT = '/Users/dan/Sites/'
VHOST_FOLDER = '/etc/apache2/sites/'
@dhrrgn
dhrrgn / pow_port.rb
Created April 8, 2011 20:08
Quickly and easily change the port that Pow is running on. This allows you too run Apache and Pow side-by-side (on different ports of course).
#!/usr/bin/env ruby
# Pow Port
#
# Quickly and easily change the port that Pow is running on. This allows
# you too run Apache and Pow side-by-side (on different ports of course).
#
# WARNING: This will OVERWRITE your ~/.powconfig file. If you have custom
# configurations in there, please back it up first.
#
@dhrrgn
dhrrgn / pow_port.rb
Created April 8, 2011 21:20
Quickly and easily change the port that Pow is running on. This allows you too run Apache and Pow side-by-side (on different ports of course).
#!/usr/bin/env ruby
# Pow Port
#
# Quickly and easily change the port that Pow is running on. This allows
# you too run Apache and Pow side-by-side (on different ports of course).
#
# WARNING: This will OVERWRITE your ~/.powconfig file. If you have custom
# configurations in there, please back it up first.
#
@dhrrgn
dhrrgn / timed_file_store.rb
Created April 10, 2011 00:49
Simple time based file caching
# Time based file caching
#
# This allows you too set a lifetime on File Based caches
# This is a modified version of a class I found here:
# http://blog.ubrio.us/ruby/ruby-rails/simple-rails-time-based-fragment-caching-with-file-store/
#
# - Save this file somewhere (e.g. lib/timed_file_store.rb)
# - Include it (e.g. in config/application.rb)
#
# Example Usage:
@dhrrgn
dhrrgn / article.rb
Created April 12, 2011 00:32
A nifty little Article model for Markdown file based articles
# You need to set the Article.path to where your files are located.
# I do this in my application_controller.rb
Article.path = File.join(Rails.root, 'articles')
class Article
attr_reader :title, :tags, :mtime, :slug, :filename
def self.path=(path)
@@path = path
end
@dhrrgn
dhrrgn / my_string.rb
Created April 12, 2011 00:35
Just a simple method to turn a slug into a human readable title
class String
def to_human_title
self.gsub(/[-_]/, " ").split(' ').map {|w| w.capitalize }.join(' ')
end
end
@dhrrgn
dhrrgn / .box
Created April 20, 2011 16:33
A Fuel .box file for PagodaBox
################################################
## GENERAL SETTINGS
################################################
shared_writable_dirs: [/fuel/app/cache, /fuel/app/logs]
local_writable_dirs: [/fuel/app/tmp]
################################################
## WEB SPECIFIC SETTINGS
################################################
document_root: /public
@dhrrgn
dhrrgn / .gitconfig
Last active September 25, 2015 14:38
An awesome .gitconfig file with some niceties.
[user]
name = Your Name
email = [email protected]
[core]
autocrlf = input
[color]
status = auto
diff = auto
branch = auto
[alias]
@dhrrgn
dhrrgn / TestClass.php
Created April 28, 2011 05:22
A lightweight, fast Annotations parser for PHP, extends PHP's Reflection classes.
<?php
/**
* TestClass
*
* This is just a test class for the Annotated\ReflectionClass
* to use.
*
* Foo::bar();
*