Skip to content

Instantly share code, notes, and snippets.

View balgarath's full-sized avatar

Ralph Edge balgarath

View GitHub Profile
@balgarath
balgarath / gist:5088722
Created March 5, 2013 08:05
Chef Knife SSH Rackspace solution to Net::SSH::HostKeyMismatch
You'll get this w/ rackspace cloud when an IP in your cloud gets re-used(if you deleted a server, and then later create a server that gets assigned the old one's IP). You can disable this error by adding the following to .ssh/config, however be aware of the security considerations here...namely, if Rackspace DNS is compromised, you won't have any warning if the hostname gets pointed to a different computer.
Host *static.cloud-ips.com
StrictHostKeyChecking no
UserKnownHostsFile=/dev/null
flash.each_pair do |key, value|
puts key #notice, warning, etc
puts value #message of the flash
end
@balgarath
balgarath / reserved_words.rb
Created September 28, 2011 16:49
reserved_words.rb
module ReservedWords
RESERVED = YAML.load_file(File.join(Rails.root, "config", "reserved_words.yml"))
def self.usernames
@usernames ||= begin
reserved = []
Rails.application.routes.routes.each do |r|
reserved += r.path.gsub(/(\(.*\)|:)/, '').split('/')
end
tags = text.match(/#([a-z]|[A-Z]|[0-9]|\-|\_)+/g);
text = text.replace(new RegExp("#{tag}(?![A-Za-z0-9\-\_])", "g"), "<a class = 'tag' href = '#{@tagUrl(tag.substring(1))}'>#{tag}</a>") for tag in tags if tags
@balgarath
balgarath / url-regex.js
Created May 5, 2011 17:39
Regex to grab URLs out of a string
regex = /(^|\s)((https?:\/\/)?((\.?[\w-])+)(\.(COM|NET|ORG|GOV|ASIA|IN|INFO|UK|US|JOBS|FR|LY|BIZ|AC|AD|AE|AERO|AF|AG|AI|AL|AM|AN|AO|AQ|AR|ARPA|AS|AT|AU|AW|AX|AZ|BA|BB|BD|BE|BF|BG|BH|BI|BJ|BM|BN|BO|BR|BS|BT|BV|BW|BY|BZ|CA|CAT|CC|CD|CF|CG|CH|CI|CK|CL|CM|CN|CO|COOP|CR|CU|CV|CX|CY|CZ|DE|DJ|DK|DM|DO|DZ|EC|EDU|EE|EG|ER|ES|ET|EU|FI|FJ|FK|FM|FO|GA|GB|GD|GE|GF|GG|GH|GI|GL|GM|GN|GP|GQ|GR|GS|GT|GU|GW|GY|HK|HM|HN|HR|HT|HU|ID|IE|IL|IM|INT|IO|IQ|IR|IS|IT|JE|JM|JO|JP|KE|KG|KH|KI|KM|KN|KP|KR|KW|KY|KZ|LA|LB|LC|LI|LK|LR|LS|LT|LU|LV|MA|MC|MD|ME|MG|MH|MIL|MK|ML|MM|MN|MO|MOBI|MP|MQ|MR|MS|MT|MU|MUSEUM|MV|MW|MX|MY|MZ|NA|NAME|NC|NE|NF|NG|NI|NL|NO|NP|NR|NU|NZ|OM|PA|PE|PF|PG|PH|PK|PL|PM|PN|PR|PRO|PS|PT|PW|PY|QA|RE|RO|RS|RU|RW|SA|SB|SC|SD|SE|SG|SH|SI|SJ|SK|SL|SM|SN|SO|SR|ST|SU|SV|SY|SZ|TC|TD|TEL|TF|TG|TH|TJ|TK|TL|TM|TN|TO|TP|TR|TRAVEL|TT|TV|TW|TZ|UA|UG|UY|UZ|VA|VC|VE|VG|VI|VN|VU|WF|WS|YE|YT|ZA|ZM|ZW))(((:\d+)|#|\/|\?)(\S*)|\b))/gi;
www:
requirements:
- faye
- jade
##formtastic_datepicker_interface
module Formtastic
module DatePicker
protected
def datepicker_input(method, options = {})
format = options[:format] || ActiveSupport::CoreExtensions::Date::Conversions::DATE_FORMATS[:default] || '%d %b %Y'
string_input(method, datepicker_options(format, object.send(method)).merge(options))
end
##put this in your helper
# Passes the authenticity token for use in javascript
def yield_authenticity_token
if protect_against_forgery?
<<JAVASCRIPT
<script type='text/javascript'>
//<![CDATA[
window._auth_token_name = "#{request_forgery_protection_token}";
window._auth_token = "#{form_authenticity_token}";
$(document).ready(function() {
$("a").click(function() {h