Skip to content

Instantly share code, notes, and snippets.

View mikehale's full-sized avatar

Michael Hale mikehale

  • RoleModel Software
  • Holly Springs, NC
View GitHub Profile
def set_cache_control
if (request.head? || request.get?) && @page.cache?
expires_in self.class.cache_timeout, :public => true, :private => false
else
expires_in nil, :private => true, "no-cache" => true
headers['ETag'] = ''
end
end
page = Page.find(params[:page_id])
page.request, page.response = request, response
render :text => page.render
@mikehale
mikehale / site_controller.rb
Created July 1, 2009 19:18
Make radiant pages re-validate against the cache
SiteController.class_eval do
def show_page
url = params[:url]
if Array === url
url = url.join('/')
else
url = url.to_s
end
if @page = find_page(url)
@mikehale
mikehale / default.rb
Created July 10, 2009 01:26
ruby_enterprise cookbook
ruby_enterprise_edition Mash.new unless attribute?("ruby_enterprise_edition")
ruby_enterprise_edition[:version] = '20090520' unless ruby_enterprise_edition.has_key?(:version)
ruby_enterprise_edition[:install_path] = '/opt/ruby-enterprise' unless ruby_enterprise_edition.has_key?(:install_path)
ruby_enterprise_edition[:url] = "http://github.com/FooBarWidget/rubyenterpriseedition/tarball/release-#{ruby_enterprise_edition[:version]}"
ruby_enterprise_edition[:cow_friendly] = %Q[#{ruby_enterprise_edition[:install_path]}/bin/ruby -e "exit 1 unless GC.respond_to?(:copy_on_write_friendly=)"]

Did you follow this gist, wallowing in its awesomeness, only to realize your Visual Voicemail stopped working? You just need to reset your carrier settings file, and you’ll get to keep tethering and get your Visual Voicemail back!

  1. Connect your iPhone and fire up iTunes. Option-click on the Restore button like you did before.
  2. Navigate to your-username | Library | iTunes | iPhone Carrier Support
  3. Click on the file in there to reset your carrier settings.
@mikehale
mikehale / kernel_module.rb
Created September 4, 2009 18:55
A chef definition for installing kernel modules on ubuntu/debian.
# A chef definition for installing kernel modules on ubuntu/debian.
define :kernel_module, :action => :install do
if params[:action] == :install
bash "modprobe #{params[:name]}" do
code "modprobe #{params[:name]}"
not_if "lsmod |grep #{params[:name]}"
end
bash "install #{params[:name]} in /etc/modules" do
require 'autotest/growl'
require 'redgreen/autotest'
require 'autotest/fsevent'
# Autotest::Growl::clear_terminal = true
Autotest::Growl::remote_notification = true #networked growl, to work-around disappearing notifications
Autotest.add_hook :initialize do |at|
%w{.git .svn .hg .DS_Store ._* log vendor}.each {|exception|at.add_exception(exception)}
end
(function($) {
$.fn.ellipsis = function(enableUpdating) {
function supportsOverflowProperty() {
var s = document.documentElement.style;
return ('textOverflow' in s || 'OTextOverflow' in s);
}
function updateText(originalString, scratchElement, length) {
var text = originalString.substr(0, length);
scratchElement.html(text + "…");
@mikehale
mikehale / jquery.copyable.js
Created January 21, 2010 21:11
A jquery API for ZeroClipBoard
/*
Requirements:
This script requires the jquery.includeMany plugin and ZeroClipboard.
Example:
$("#elementToClickOn").copyable(function(e, clip) {
clip.setText($("#elementWithText").html());
});
#!/usr/bin/env ruby
################################################################################
#
# Copyright (C) 2006 Peter J Jones ([email protected])
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to