Skip to content

Instantly share code, notes, and snippets.

@toxaq
toxaq / gist:10085811
Last active August 29, 2015 13:58
Upgrading OpenSsl on Rackspace
#Check version, needs to be: 1.0.1-4ubuntu5.12
apt-cache policy openssl
#Backup source list
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
# Change your mirrors, Rackspace is out of date
sudo sed -i 's/mirror.rackspace.com/us.archive.ubuntu.com/g' /etc/apt/sources.list
#Update your packages
sudo apt-get update
#Install the latest version
sudo apt-get install openssl=1.0.1-4ubuntu5.12
@toxaq
toxaq / routes.rb
Created October 31, 2013 11:39
Rails route dumping
<% Rails.application.routes.routes.map do |route| %>
<%
path = route.path.spec.to_s
next if path.starts_with? '/admin'
controller = route.defaults[:controller].to_s
action = route.defaults[:action].to_s
is_permitted = permitted_to? action.to_sym, controller.sub(/\//, '_').to_sym
%>
<tr><%#<td><%= route.name </td>%>
<td><%= path %></td>
@toxaq
toxaq / table_builder.rb
Created October 30, 2013 21:32
Table helper code, can't remember where this came from. Not used any more but was helpful. Clever name.
module TableHelper
def table_for(objects, *args)
raise ArgumentError, "Missing block" unless block_given?
options = args.last.is_a?(Hash) ? args.pop : {}
html_options = options[:html]
builder = options[:builder] || TableBuilder
content_tag(:table, html_options) do
yield builder.new(objects || [], self, options)
@toxaq
toxaq / calendar_helper.rb
Created October 30, 2013 21:02
Calendar builder helper
module CalendarHelper
# Generates a calendar (as a table) for an array of objects placing each of them on the corresponding date.
#
# **TODO: fully document this method, the current documentation is far from done.**
#
# @param [Hash] options extra options
#
# :row_header if true, each row will have an extra cell at the beginning, as a row header. A typical usage would be
# to output week numbers. When the block is called, it will get the date that would normally be passed to the
# first day of the week (to give you some context) and a nil list of objects (and that's how you recognize it as