This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActiveRecord | |
class Base | |
def to_yaml_with_nil_handling(opts = {}) | |
# detect and remove any belongs_to association proxies | |
self.class.reflect_on_all_associations.find_all { |a| a.macro == :belongs_to }.each do |a| | |
ivar = "@#{a.name}" | |
remove_instance_variable(ivar) if instance_variable_defined?(ivar) && instance_variable_get(ivar).class.nil? | |
end | |
to_yaml_without_nil_handling(opts) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActiveRecord | |
class Base | |
def to_yaml_with_association_pruning(opts = {}) | |
# detect and remove any cached associations | |
self.class.reflect_on_all_associations.each do |a| | |
ivar = "@#{a.name}" | |
remove_instance_variable(ivar) if instance_variable_defined?(ivar) | |
end | |
to_yaml_without_association_pruning(opts) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# | |
# check google serp for multiple sites using provided queries | |
# | |
require 'rubygems' | |
require 'mechanize' | |
SITES = [ | |
'moneyworks.ca', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Install ImageMagick on Snow Leopard: by kain, improved by mislav and samsoffes | |
# http://www.icoretech.org/2009/08/install-imagemagick-in-leopard-snow-leopard/ | |
# Work with 64bit kernel mode | |
set -e | |
PREFIX=/usr/local | |
# Passenger users: amend your Apache global configuration with the following directive | |
# SetEnv PATH /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'openssl' | |
def gen_key(name) | |
key = OpenSSL::PKey::RSA.new 1048 | |
file = File.new(name, "w") | |
file.write(key) | |
file.close | |
end | |
def get_key(name) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# CLOSURES IN RUBY Paul Cantrell http://innig.net | |
# Email: username "cantrell", domain name "pobox.com" | |
# I recommend executing this file, then reading it alongside its output. | |
# | |
# Alteratively, you can give yourself a sort of Ruby test by deleting all the comments, | |
# then trying to guess the output of the code! | |
# A closure is a block of code which meets three criteria: | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'faraday' | |
require 'faraday_middleware' | |
cas = Faraday.new(:url => 'http://cas.dev') do |faraday| | |
faraday.request :url_encoded | |
faraday.response :logger | |
faraday.response :xml, :content_type => /\bxml$/ | |
faraday.adapter Faraday.default_adapter |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'openssl' | |
require 'base64' | |
require 'builder' | |
require 'securerandom' | |
require 'faker' | |
tests = %i(rsa) | |
I18n.enforce_available_locales = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# DOMAIN='example.com' | |
# PASSWORD='my secure pass phrase goes here' | |
# | |
# KEYFILE = "#{DOMAIN}.key" | |
# CSRFILE = "#{DOMAIN}.csr" | |
# | |
################################################################################ | |
# create a new key | |
# key = OpenSSL::PKey::RSA.new 2048 | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'base64' | |
require 'encryptor' | |
require 'builder' | |
# private_key = OpenSSL::PKey::RSA.new(2048) | |
# public_key = private_key.public_key | |
# test data from TST | |
# key = Base64.decode64("NxQLMrUXaSKZYm0Ef3Ab1siRevbOxF5HLpvCKXPdZh4=") |
OlderNewer