Skip to content

Instantly share code, notes, and snippets.

View jipiboily's full-sized avatar

JP Boily jipiboily

  • Alma, Quebec, Canada
View GitHub Profile
@jcasimir
jcasimir / exporter.rb
Created February 26, 2012 17:39
Export ActiveRecord Tables to CSV
require 'csv'
class Exporter
DEFAULT_EXPORT_TABLES = [ Invoice, InvoiceItem, Item, Merchant, Transaction, User ]
DESTINATION_FOLDER = "tmp/"
def self.export_tables_to_csv(tables = DEFAULT_EXPORT_TABLES)
tables.each { |klass| export_table_to_csv(klass) }
end
class ApplicationController < ActionController::Base
extend AttributeViewable
end
@jipiboily
jipiboily / _actions.html.erb
Created April 8, 2012 18:12
How to setup a Refinery custom content type and view (aka "page template")
<!-- path: app/views/refinery/admin/pages/_actions.html.erb -->
<!--
You could override this view, if you want to add links to each page type via the admin UI. If you don't you'll have to add a param the the URL.
WARNING: You most probably want to do it cleaner than that and find a way to hook to this view instead of overriding it if at all possible.
-->
<ul>
<li>
<%= render '/refinery/admin/search', :url => refinery.admin_pages_path %>
</li>
git rev-parse HEAD | tr -d '\n' | pbcopy
@hinke
hinke / gist:3823496
Created October 2, 2012 21:43
Fetch headers from build image and do something
get '/travis/:id/status' do |id|
token = "token!!"
http = Net::HTTP.new('magnum.travis-ci.com', 443)
http.use_ssl = true
path = "/Readmill/#{id}.png?token=#{token}"
response = http.head(path, nil)
if response['Content-Disposition'].include?('failing')
@message = "The build failed."
@remi
remi / example.rb
Created December 6, 2012 18:38
Gathering options using a block
# config/initializers/tumbz_init.rb
Tumbz.configure do |config|
config.access_key = "foo"
config.access_secret = "bar"
end
# lib/tumbz.rb
module Tumbz
def self.configure
@options = OpenStruct.new
#!/bin/bash
git checkout master
git pull
git branch --remotes --merged | grep origin > .master_merged
git checkout release-staging
git pull
git branch --remotes --merged | grep origin > .staging_merged
diff .master_merged .staging_merged
rm .master_merged .staging_merged
@Supro
Supro / active_model_serializers_rspec.rb
Last active December 26, 2015 11:09
ActiveModelSerializers example
### spec/serializers/building_spec.rb
require "spec_helper"
describe BuildingSerializer do
include Rails.application.routes.url_helpers
let(:room) { create :room }
let(:building) { room.building }
let(:hash) { BuildingSerializer.new(building).serializable_hash }
@jjb
jjb / gist:950975
Created May 1, 2011 23:16
Using whenever with capistrano and bundler in multiple environments
We couldn’t find that file to show.
@groveriffic
groveriffic / mathlink.rb
Created August 31, 2012 03:33
jruby-mathlink