Skip to content

Instantly share code, notes, and snippets.

View paulspringett's full-sized avatar

Paul Springett paulspringett

  • Leeds, United Kingdom
  • 05:10 (UTC +01:00)
View GitHub Profile
@andyshinn
andyshinn / Dockerfile
Created December 24, 2015 19:07
BusyBox cron container example
FROM gliderlabs/alpine:3.3
COPY myawesomescript /bin/myawesomescript
COPY root /var/spool/cron/crontabs/root
RUN chmod +x /bin/myawesomescript
CMD crond -l 2 -f
@stereoscott
stereoscott / active_admin.rb
Last active March 15, 2020 10:47
Stream CSV exports in ActiveAdmin in Rails 4
# if you want to monkey patch every controller, put this in initializers/active_admin.rb
ActiveAdmin::ResourceController.class_eval do
include ActiveAdmin::CSVStream
end
@subelsky
subelsky / asset.rake
Created March 3, 2013 21:48
Quick rake task to check if assets need to pre-compiled before deployment (since I don't like precompiling during deployment)
namespace :assets do
task :check do
root_dir = File.join(File.dirname(__FILE__),"..","..")
assets_last_modified_at = Dir["#{root_dir}/app/assets/**/**"].map { |p| File.mtime(p) }.sort.last
assets_last_compiled_at = Dir["#{root_dir}/public/assets/**/**"].map { |p| File.mtime(p) }.sort.last
if assets_last_modified_at > assets_last_compiled_at
fail "Assets need to precompiled; last asset modified at #{assets_last_modified_at}"
end
end
============================================================
Pakl's guide to a complete tentd and tentd-admin
and Nginx proxy:80 installation.
============================================================
Oct 7, 2012 -- Version 1.2 (adds missing commands for installing nginx)
History
Oct 7, 2012 -- Version 1.1 (adds missing nodejs repository)
Oct 7, 2021 - 1.0 initial release
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@sj26
sj26 / README.md
Created February 29, 2012 10:38
Subdomains in Rails 3

Subdomains in Rails 3

Are still a nightmare to get tested, etc.

To share sessions across subdomains you need to set the session options during the request so you know what domain you're sharing across. This means we still need to do it with a before_filter, or something similar. It looks like you should be able to set :domain => true in config/initializers/session_store.rb to do this instead but Devise does not support it yet as far as I can see.

Here I'm using subdomains with a custom url_for extension which means from "http://www.smackaho.st" root_path would be "/" while from "http://admin.smackaho.st" root_path would be "http://www.smackaho.st/".

In cucumber this is forced to always qualify the full URL with the subdomain. It also rewrites the port in/out as neccessary to cope with Capybara's server using an alternate port (used by Selenium for javascript testing etc). The project I'm on is still using web_steps (sigh) so I had to touch the "should be on" step definition to cope with

#in development.rb - this avoids the missing constant error which can result on a 2nd and subsequent request
#it can also fix the timezone aware problem expressed at https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/1339-arbase-should-not-be-nuking-its-children-just-because-it-lost-interest#ticket-1339-59
#we use this to ensure that the dev environment (with config.cache_classes=false) remembers to load certain classes
#this isn't an issue in production where config.cache_classes=true
class ClassLoader
def initialize(app)
@app = app
end