Skip to content

Instantly share code, notes, and snippets.

View nordringrayhide's full-sized avatar

Nodrin Grayhide nordringrayhide

  • home
  • Worldwide
View GitHub Profile
class Feed < ActiveRecord::Base
has_many :items, :order => "published_at desc", :dependent => :delete_all
has_many :feed_errors
# This is problematic because on update, the feed_url can be changed. It can
# be changed to the feed_url of another feed. TODO Figure out a way to
# automatically merge two feeds in this case.
# validates_uniqueness_of :feed_url
validates_presence_of :feed_url
@hubgit
hubgit / facebook-login.sh
Created February 17, 2010 14:08
Login to Facebook using cURL
#!/bin/bash
# If it redirects to http://www.facebook.com/login.php at the end, wait a few minutes and try again
EMAIL='YOUR_EMAIL' # edit this
PASS='YOUR_PASSWORD' # edit this
COOKIES='cookies.txt'
USER_AGENT='Firefox/3.5'
# Then in your features you'll only need to call the `login_as` or `logout`
# methods. More info here: http://wiki.github.com/hassox/warden/testing
feature "Home page" do
background do
@user = User.create(...) # Or use fixtures, factories or whatever, even a
# stub user
login_as @user
visit home_page
@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)

@nordringrayhide
nordringrayhide / watchr-runner.rb
Created August 9, 2011 06:23 — forked from rud/watchr-runner.rb
watchr for rspec
if __FILE__ == $0
puts "Run with: watchr #{__FILE__}. \n\nRequired gems: watchr rev"
exit 1
end
# --------------------------------------------------
# Convenience Methods
# --------------------------------------------------
def run(cmd)
puts(cmd)
@isaacbowen
isaacbowen / will_paginate.rb
Created August 30, 2011 21:37
extends will_paginate to play well with Twitter's Bootstrap
# config/initializers/will_paginate.rb
module WillPaginate
module ActionView
def will_paginate(collection = nil, options = {})
options[:renderer] ||= BootstrapLinkRenderer
super.try :html_safe
end
class BootstrapLinkRenderer < LinkRenderer
@xeron
xeron / haproxy.cnf
Created September 21, 2011 16:50 — forked from asabirov/haproxy.cnf
haproxy.cnf
global
log 127.0.0.1 local0
log 127.0.0.1 local0 notice
maxconn 4096
nbproc 1
pidfile /var/run/haproxy.pid
user haproxy
group haproxy
@manuelvanrijn
manuelvanrijn / database.rake
Created January 19, 2012 14:54
Retrieve and convert PostgreSQL database to SQLite database (with ssh)
require 'fileutils'
namespace :db do
desc 'pull the production PostgreSQL database into the development SQLite'
task :pull do
Rake::Task['db:download_pg_dump'].invoke
Rake::Task['db:optimze_pg_dump_for_sqlite'].invoke
Rake::Task['db:recreate_with_dump'].invoke
end
@fetep
fetep / config
Created March 6, 2012 14:45
sample logstash config for rails log line
input {
stdin {
type => rails
}
}
filter {
grok {
type => "rails"
pattern => "Completed %{GREEDYDATA:operation} in %{NUMBER:time:int}ms"
@finack
finack / application.rb
Created March 17, 2012 06:18
Example Chef Deploy Revision for Rails 3+
app = node[:rails][:app]
rails_base app[:name] do
ruby_ver app[:ruby_ver]
gemset app[:gemset]
end
%w{config log pids cached-copy bundle system}.each do |dir|
directory "#{app[:app_root]}/shared/#{dir}" do
owner app[:deploy_user]