Skip to content

Instantly share code, notes, and snippets.

@fnichol
fnichol / README.md
Created March 12, 2011 20:52
Download a cacert.pem for RailsInstaller

Why?

There is a long standing issue in Ruby where the net/http library by default does not check the validity of an SSL certificate during a TLS handshake. Rather than deal with the underlying problem (a missing certificate authority, a self-signed certificate, etc.) one tends to see bad hacks everywhere. This can lead to problems down the road.

From what I can see the OpenSSL library that Rails Installer delivers has no certificate authorities defined. So, let's go fetch some from the curl website. And since this is for ruby, why don't we download and install the file with a ruby script?

Installation

The Ruby Way! (Fun)

@mattmccray
mattmccray / render.js
Created November 1, 2010 19:44
Based on ICanHaz, this supports both Mustache.js and Handlebars.js
// Based on ICanHaz (http://github.com/andyet/ICanHaz.js/blob/master/ICanHaz.js)
// This version supports Mustache and Handlebars
// By M@ McCray
;var render = (function($, engine){
var cache = {},
methods = {};
$(function(){
$('script[type="text/html"]').each(function () {
var name = $(this).attr('id'),
class Object
def if_present?(&blk)
return self unless present?
if blk.arity == -1
instance_eval(&blk)
else
blk.call(self)
end
self
# This relates to the issue described at:
# https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/4709
class String
def %(args)
if args.kind_of?(Hash)
dup.gsub(INTERPOLATION_PATTERN_WITH_ESCAPE) do |match|
if match == '%%'
'%'
else
@lwille
lwille / application_helper.rb
Created March 4, 2010 22:46
Single DB query tree generation with awesome_nested_set
module ApplicationHelper
# Mixin for tree generation based on a nested set, just place this in your application_helper.rb
module TreeMethods
attr_accessor :child_nodes
attr_accessor :parent_node
def after_initialize
@child_nodes = []
@parent_node = nil
end
def recursive_tree nodes=nil, level=0