Skip to content

Instantly share code, notes, and snippets.

View bobthecow's full-sized avatar

Justin Hileman bobthecow

View GitHub Profile
:+1:
:-1:
:airplane:
:art:
:bear:
:beer:
:bike:
:bomb:
:book:
:bulb:
# Pass in the name of the site you wich to create a cert for
domain_name = ARGV[0]
if domain_name == nil
puts "Y U No give me a domain name?"
else
system "openssl genrsa -out #{domain_name}.key 1024"
system "openssl req -new -key #{domain_name}.key -out #{domain_name}.csr -subj '/C=US/ST=NJ/L=Monroe/O=MyCompany/OU=IT/CN=#{domain_name}'"
system "cp #{domain_name}.key #{domain_name}.key.bak"
@rogerrohrbach
rogerrohrbach / nanp_validator.rb
Created June 27, 2011 14:42
Active Model North American Telephone Number validator
# == Active Model North American Telephone Number Validator
# http://en.wikipedia.org/wiki/North_American_Numbering_Plan#Current_system
# [Author] Roger Rohrbach (roger@ecstatic.com)
class NanpValidator < ActiveModel::EachValidator
def self.matcher(require_area_code) # :nodoc:
%r{
(?<country_code> \+1 ){0}
(?<trunk_prefix> 1 ){0}
(?<delimiter> ([-\.]|\ +) ){0}
@onethirtyfive
onethirtyfive / gist:1141150
Created August 12, 2011 00:17
Grape presenters?
# lib/api/presenters/detailed_post.rb
module API
module Presenters
class DetailedPost
include ActiveModel::Serializers::JSON
include ActiveModel::Serializers::Xml
attr_accessor :post
delegate :attributes, :to => :post
@sevennineteen
sevennineteen / gist:1224478
Created September 17, 2011 23:14
Set logger level on Heroku Sinatra app
require "logger"
configure do
LOG = Logger.new(STDOUT)
LOG.level = Logger.const_get ENV['LOG_LEVEL'] || 'DEBUG'
LOG.info 'I am logging something.'
end
@gcollazo
gcollazo / Backbone.sync_csrftoken.js
Created September 25, 2011 14:56
This is what I did to insert the CSRF token in backbone requests. This works with django.
var oldSync = Backbone.sync;
Backbone.sync = function(method, model, options){
options.beforeSend = function(xhr){
xhr.setRequestHeader('X-CSRFToken', CSRF_TOKEN);
};
return oldSync(method, model, options);
};
@fracai
fracai / absolutize_paths.rb
Created January 12, 2012 00:10
nanoc filter to convert relative paths to absolute
# encoding: utf-8
module Nanoc3::Filters
class AbsolutizePaths < Nanoc3::Filter
identifier :absolutize_paths
require 'nanoc3/helpers/link_to'
include Nanoc3::Helpers::LinkTo
@ziadoz
ziadoz / awesome-php.md
Last active April 17, 2024 21:06
Awesome PHP — A curated list of amazingly awesome PHP libraries, resources and shiny things.
@axelav
axelav / gist:1839777
Created February 15, 2012 22:51 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@coreyhaines
coreyhaines / .rspec
Last active April 11, 2024 00:19
Active Record Spec Helper - Loading just active record
--colour
-I app