Skip to content

Instantly share code, notes, and snippets.

View MattHall's full-sized avatar
🤖

Matt Hall MattHall

🤖
View GitHub Profile
@MattHall
MattHall / gist:239464
Created November 20, 2009 12:09
Get info for all DB Tables (MySQL)
SELECT table_name, engine, version, table_collation AS collation, table_rows AS rows FROM information_schema.tables WHERE table_schema = DB_NAME;
[[Reachability reachabilityForLocalWiFi] currentReachabilityStatus] == ReachableViaWiFi
var DerivedClass = Class.create(ParentClass, {
initialize: function($super, param1) {
}
}
module MultiparameterHack
def self.included klass
klass.class_eval do
@date_error_on_attribute = nil
def validate
errors.add_to_base "Invalid Date #{@date_error_on_attribute}" if @date_error_on_attribute
end
undef :execute_callstack_for_multiparameter_attributes
module ErrorsHelper
def error_messages_for(*params)
options = params.extract_options!.symbolize_keys
if object = options.delete(:object)
objects = Array.wrap(object)
else
objects = params.collect {|object_name| instance_variable_get("@#{object_name}") }.compact
end
require 'net/http'
require 'uri'
require 'rubygems'
@auth = {:api_token => 'my token'}
Net::HTTP.start('posterous.com') {|http|
req = Net::HTTP::Get.new("/api/v2/users/me/sites/primary/posts?api_token=#{@auth[:api_token]}")
req.basic_auth 'my email address', 'my password'
response = http.request(req)
require 'spec_helper'
describe NewsletterSubscriber do
describe "validations" do
before(:each) do
NewsletterSubscriber.create(:email => "test@example.com")
end
it { should validate_presence_of(:email) }
it { should validate_uniqueness_of(:email) }
@MattHall
MattHall / Rakefile
Created February 11, 2012 15:44
Rake task for creating new posts in Jekyll
require 'rubygems'
require 'optparse'
require 'yaml'
task :np do
OptionParser.new.parse!
ARGV.shift
title = ARGV.join(' ')
path = "_posts/#{Date.today}-#{title.downcase.gsub(/[^[:alnum:]]+/, '-')}.markdown"
*** [err :: xxx.xxx.xxx.xxx] Invalid gemspec in [/var/apps/myapp-staging/shared/bundle/ruby/1.8/specifications/carrierwave-0.6.0.gemspec]: Illformed requirement ["#<YAML::Syck::DefaultKey:0x11e87478> 1.1.4"]
*** [err :: xxx.xxx.xxx.xxx]
*** [err :: xxx.xxx.xxx.xxx] Invalid gemspec in [/var/apps/myapp-staging/shared/bundle/ruby/1.8/specifications/carrierwave-0.6.0.gemspec]: Illformed requirement ["#<YAML::Syck::DefaultKey:0x11e87478> 1.1.4"]
*** [err :: xxx.xxx.xxx.xxx]
*** [err :: xxx.xxx.xxx.xxx] WARNING: #<ArgumentError: Illformed requirement ["#<YAML::Syck::DefaultKey:0x11e87478> 1.1.4"]>
*** [err :: xxx.xxx.xxx.xxx] # -*- encoding: utf-8 -*-
*** [err :: xxx.xxx.xxx.xxx]
*** [err :: xxx.xxx.xxx.xxx] Gem::Specification.new do |s|
*** [err :: xxx.xxx.xxx.xxx] s.name = %q{carrierwave}
*** [err :: xxx.xxx.xxx.xxx] s.version = "0.6.0"
# Support for Rspec / Capybara subdomain integration testing
# Make sure this file is required by spec_helper.rb
#
# Sample subdomain test:
# it "should test subdomain" do
# switch_to_subdomain("mysubdomain")
# visit root_path
# end
DEFAULT_HOST = "lvh.me"