Skip to content

Instantly share code, notes, and snippets.

family = {
uncles: ["bob", "joe", "steve"],
sisters: ["jane", "jill", "beth"],
brothers: ["frank","rob","david"],
aunts: ["mary","sally","susan"]
}
require 'pdfkit'
require 'nokogiri'
require 'haml'
# config/initializers/pdfkit.rb
PDFKit.configure do |config|
# Note: Often required for Windows OS configuration
# config.wkhtmltopdf = '/path/to/wkhtmltopdf'
require 'pdfkit'
require 'nokogiri'
require 'haml'
# config/initializers/pdfkit.rb
PDFKit.configure do |config|
# Note: Often required for Windows OS configuration
# config.wkhtmltopdf = '/path/to/wkhtmltopdf'
@jmvallet
jmvallet / store_stylesheet.rb
Created October 4, 2012 12:20 — forked from manuelmeurer/store_stylesheet.rb
How to compile custom Sass stylesheets during runtime
# lib/store_stylesheet.rb
class StoreStylesheet
def initialize(store)
@store = store
end
# The path of the compiled stylesheet, i.e. stores/id-timestamp.css
def stylesheet_file
filename = [
@jmvallet
jmvallet / gist:2170961
Created March 23, 2012 14:08
rbenv install ruby on Ubuntu 11.10
# Development tools:
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get -y install build-essential git-core curl libssl-dev libreadline6 libreadline6-dev zlib1g zlib1g-dev
# Pour passenger
sudo apt-get -y install libcurl4-openssl-dev
# Pour nokogiri
sudo apt-get -y install libxslt-dev libxml2-dev
class PagesController < ApplicationController
before_filter :login_required, :except => [ :show ]
# GET /pages
# GET /pages.xml
def index
@pages = Page.find(:all)
respond_to do |format|
format.html # index.html.erb
var DateHelper = {
timeAgoInWords: function(from) {
return this.distanceOfTimeInWords(new Date(), from);
},
distanceOfTimeInWords: function(to, from) {
var distance_in_seconds = ((to - from) / 1000);
var distance_in_minutes = (distance_in_seconds / 60).floor();
if (distance_in_minutes <= 0) return "less than a minute";
@jmvallet
jmvallet / gist:59272
Created February 6, 2009 07:38 — forked from rails/gist:58761
// cf http://www.37signals.com/svn/posts/1557-javascript-makes-relative-times-compatible-with-caching
var DateHelper = {
// Takes the format of "Jan 15, 2007 15:45:00 GMT" and converts it to a relative time
// Ruby strftime: %b %d, %Y %H:%M:%S GMT
time_ago_in_words_with_parsing: function(from) {
var date = new Date;
date.setTime(Date.parse(from));
return this.time_ago_in_words(date);
},