This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActiveRecord | |
module ConnectionAdapters | |
class PostgreSQLAdapter < AbstractAdapter | |
class StatementPool < ConnectionAdapters::StatementPool | |
def connection_active? | |
@connection.query 'SELECT 1' | |
true | |
rescue PGError | |
false | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add the following to /etc/hosts: | |
127.0.0.1 local.s3.endpoint local-bucket.local.s3.endpoint | |
# Run the following in your rails console, in order to create a bucket: | |
s3=AWS::S3.new( | |
:access_key_id => 'anything', | |
:secret_access_key => 'anything', | |
:s3_endpoint => 'local.s3.endpoint', | |
:s3_port => 4567, | |
:use_ssl => false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if Rails.env.production? | |
# silence the deprecation warnings on Heroku | |
# Thanks to: https://gist.github.com/2237443 | |
ActiveSupport::Deprecation.behavior = lambda do |msg, stack| | |
unless /vendor\/plugins/ =~ msg | |
ActiveSupport::Deprecation::DEFAULT_BEHAVIORS[:stderr].call(msg,stack) # whichever handlers you want - this is the default | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def images | |
... authenticate | |
... get @images from somewhere | |
... get user_id and brochure_id from somewhere | |
if stale?(:etag => Image.images_key(@images, "#{user_id},#{brochure_id}")) | |
respond_to do |format| | |
format.json { | |
response.headers['Cache-Control'] = 'public, max-age=2592000' # 1 month |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# note the caller ensures that "prefix" consists of something | |
# uniquely identifying the user/brochure combination | |
def images_key(images, prefix = "") | |
key = "#{prefix} " | |
images.each do |im| | |
key += "#{im.file.size} #{im.file_updated_at}" | |
end | |
Digest::MD5.new.hexdigest(key) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Thanks to http://cubiq.org/add-to-home-screen | |
var isSafari = navigator.appVersion.match(/Safari/gi); | |
var isStandalone = navigator.standalone; | |
// Earlier I had been labouring with: | |
var isStandalone = navigator.userAgent.match(/WebKit.*Mobile/) && !navigator.userAgent.match(/Safari/); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- a/jquery.flips.js | |
+++ b/jquery.flips.js | |
@@ -140,7 +140,7 @@ | |
if( this.History.getState().url.queryStringToJSON().page !== page ) { | |
- this.History.pushState( null, null, '?page=' + page ); | |
+ // this.History.pushState( null, null, '?page=' + page ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="flip" class="container"> | |
<div class="loading" style="position: absolute; left: 100px; top: 200px; font-size: 15px;"> | |
<div id="loading">loading...</div> | |
</div> | |
</div> | |
... | |
<script type="text/javascript"> | |
$(function () { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Event < ActiveRecord::Base | |
... | |
has_many :options, :class_name => "EventOption", ... | |
accepts_nested_attributes_for :options | |
... | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= form_for @event, :url => (@event.new_record? ? events_path : event_path(@event)) do |f| %> | |
... | |
<%= f.fields_for :options, @event.options do |f2| %> | |
... | |
<%= f2.text_field :name %> | |
... | |
<$ end %> | |
... | |
<% end %> |
NewerOlder