Skip to content

Instantly share code, notes, and snippets.

View bhoggard's full-sized avatar

Barry Hoggard bhoggard

  • Tristan Media LLC
  • New York, NY
View GitHub Profile
--- a/vendor/plugins/paperclip/lib/paperclip/storage.rb
+++ b/vendor/plugins/paperclip/lib/paperclip/storage.rb
@@ -243,7 +243,7 @@ module Paperclip
@cloudfiles_options = @options[:cloudfiles_options] || {}
@cf = CloudFiles::Connection.new(@cloudfiles_credentials[:username], @cloudfiles_credentials[:api_key])
@url = ":cf_path_url" unless @url.to_s.match(/^:cf.*url$/)
- @path = options[:path] || ":attachment/:id/:style/:basename.:extension"
+ @path = @options[:path] || ":attachment/:id/:style/:basename.:extension"
end
base.class.interpolations[:cf_path_url] = lambda do |attachment, style|
diff --git a/vendor/plugins/paperclip/lib/paperclip/storage.rb b/vendor/plugins/paperclip/lib/paperclip/storage.rb
index 396962b..cb048e5 100644
--- a/vendor/plugins/paperclip/lib/paperclip/storage.rb
+++ b/vendor/plugins/paperclip/lib/paperclip/storage.rb
@@ -276,7 +276,7 @@ module Paperclip
@path = Paperclip::Attachment.default_options[:path] == @options[:path] ? ":attachment/:id/:style/:basename.:extension" : @option
end
base.class.interpolations[:cf_path_url] = lambda do |attachment, style|
- attachment.cloudfiles_container.object(attachment.path).public_url
+ attachment.cloudfiles_container.object(attachment.path(style)).public_url
@bhoggard
bhoggard / gist:3228946
Created August 1, 2012 17:18
partial for adding additional images
<div class='image'>
<% new_or_existing = image.new_record? ? 'new' : 'existing' %>
<% prefix = "work[#{new_or_existing}_image_attributes][]"%>
<% fields_for prefix, image do |f| %>
<p>
<%= f.label :caption %><br />
<%= f.text_field :caption %>
</p>
<p>
@bhoggard
bhoggard / search_spec.rb
Created October 4, 2012 23:11
Working Mongoid/Sunspot search including without() against a relation
require 'spec_helper'
class MyObject
include Mongoid::Document
include Mongoid::Timestamps
include Mongoid::Paranoia
include Sunspot::Rails::Searchable
field :title, type: String
validates_presence_of :title
attr_accessible :title
@bhoggard
bhoggard / no-asset-cache.rb
Created June 28, 2013 17:41
prevent redis or memcached from storing our assets when controller action caching is turned on
# in application.rb
# prevent Redis from caching assets
config.action_dispatch.rack_cache = nil
@bhoggard
bhoggard / berlin-art-20130801.txt
Created August 1, 2013 08:47
A few Berlin art recommendations
We've spent more time at museums than seeing contemporary art. Highlights:
Nefertiti and the Light of Amarna show at Neues Museum. That museum is also an amazing example of mixing new architecture with old as part of a restoration. The Nefertiti bust isn't hyped. It really is an amazing work of art.
Museum Island in general is pretty amazing. You can buy a 1-day pass good just for it.
A 3-day museum pass can be bought at any of the Museum Island museums, and also gets you into a number of others, including the Neue Nationalgalerie.
The Neue Nationalgalerie (designed by Mies van der Rohe) has a very interesting take on post-war art in the current permanent collection show. It's quite different from the history we see from MoMA.
@bhoggard
bhoggard / berlin-art-20130801.txt
Last active December 20, 2015 12:18
A few Berlin art recommendations
We've spent more time at museums than seeing contemporary art. Highlights:
Nefertiti and the Light of Amarna show at Neues Museum. That museum is also an
amazing example of mixing new architecture with old as part of a restoration.
The Nefertiti bust isn't hyped. It really is an amazing work of art.
Museum Island in general is pretty amazing. You can buy a 1-day pass good
just for it.
A 3-day museum pass can be bought at any of the Museum Island museums,
@bhoggard
bhoggard / api1.go
Created August 31, 2013 23:36
Simple REST API with 2 GETS for testing this ember app https://github.com/bhoggard/ember-simple
package main
import (
"encoding/json"
"fmt"
"log"
"net/http"
)
type Organization struct {
@bhoggard
bhoggard / iam-s3-policy.json
Created September 3, 2013 19:17
IAM Policy to grant access to just one S3 bucket
{
"Statement": [
{
"Action": "s3:*",
"Effect": "Allow",
"Resource": [
"arn:aws:s3:::mybucket",
"arn:aws:s3:::mybucket/*"
]
}
@bhoggard
bhoggard / Gruntfile.js
Created November 1, 2013 21:30
Start of Gruntfile for jshint testing.
module.exports = function(grunt) {
grunt.initConfig({
jshint: {
files: ['Gruntfile.js', 'app/assets/javascripts/pages/**/*.js', 'test/**/*.js'],
options: {
// options here to override JSHint defaults
globals: {
jQuery: true,
console: true,