Skip to content

Instantly share code, notes, and snippets.

View timboisvert's full-sized avatar

Tim Boisvert timboisvert

View GitHub Profile
@timboisvert
timboisvert / gist:6958193
Created October 13, 2013 04:31
Disable JS, CSS, Helper, Views on rails generate
# config/application.rb
module KittenFactory
class Application < Rails::Application
# Disable generation of helpers, javascripts, css, and view specs
config.generators do |generate|
generate.helper false
generate.assets false
generate.view_specs false
end
@timboisvert
timboisvert / cookies.js
Last active December 22, 2015 06:18
A reusable set of cookie-related functions for JS. No need to use jQuery for something as simple as cookie management.
var cookies = (function(){
return {
create: function(name, value, days) {
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
var expires = "; expires=" + date.toGMTString();
} else {
@timboisvert
timboisvert / gist:6166528
Last active December 20, 2015 17:09
Ink file picker
require "open-uri"
class PhotosController < ApplicationController
def update
photo = Photo.find(params[:id])
# Open the url that's been returned by Filepicker.
# Then remove the pic from params so it doesn't get updated
# via update_attributes, which will cause a validation error
if params[:photo][:pic_selected] == "true" && params[:photo][:pic] != '/default_images/original/missing.png'
url = params[:photo][:pic]