Skip to content

Instantly share code, notes, and snippets.

@errorstudio
errorstudio / proj.rb
Last active December 12, 2015 01:38
Homebrew Recipe to install Proj version 4.7.0 (which is required for the Proj4rb gem on OSX)
require 'formula'
class ProjDatumgrid < Formula
url 'http://download.osgeo.org/proj/proj-datumgrid-1.5.zip'
sha1 '4429ba1a8c764d5c0e6724d868f6874f452f7440'
end
class Proj < Formula
url 'http://download.osgeo.org/proj/proj-4.7.0.tar.gz'
homepage 'http://trac.osgeo.org/proj/'
@errorstudio
errorstudio / gist:3762192
Created September 21, 2012 15:31
standard image picker partial for Refinery
<%= render :partial => "/refinery/admin/image_picker", :locals => {
:f => f,
:field => :image_id,
:image => f.object.image,
:toggle_image_display => false
} %>
@errorstudio
errorstudio / gist:3668852
Created September 7, 2012 19:24
Add a summary field to translated Refinery News Items
class AddSummaryToNewsItems < ActiveRecord::Migration
def up
Refinery::News::Item.drop_translation_table! #waaaah
Refinery::News::Item.create_translation_table!({
:title => :string, :summary => :text, :body => :text},
{
:migrate_data => true
})
end
@errorstudio
errorstudio / _locale_nav.html.erb
Created August 30, 2012 16:38
Refinery CMS: a list of all frontend locales with links
<ul>
<% Refinery::I18n.config.frontend_locales.each do |locale| %>
<li>
<%= link_to "/#{locale + request.path}", {:title => Refinery::I18n.locales[l]} do%>
<span><%= Refinery::I18n.locales[l] %></span>
<% end -%>
</li>
<% end %>
</ul>
@errorstudio
errorstudio / i18n.rb
Created August 24, 2012 12:42
Refinery CMS - how to override refinery-i18n's find_or_set_locale method
# encoding: utf-8
Refinery::I18n.configure do |config|
config.enabled = true
config.default_locale = :en
config.current_locale = :en
config.default_frontend_locale = :en
@errorstudio
errorstudio / http_stats.sh
Created October 31, 2011 10:41
HTTP stats - code, download time, number of assets and pageweight
#!/bin/bash
#A little shell script which uses wget to download
#all the requisites for a page, and returns the amount
#of time, the 'weight' of the page in K and the number
#of files, along with the HTTP code of the original request
#requires curl, bc, wget (version 1.13), awk and bash.
#expects the url (including http://) to be passed from STDIN