Skip to content

Instantly share code, notes, and snippets.

@LCShen
LCShen / callbacks.rb
Created June 20, 2017 08:17
Callback logging
# With thanks to https://github.com/optoro/activerecord-callback_notification for original inspiration
if Rails.env.development?
module ActiveRecord
module CallbackNotifications
extend ActiveSupport::Concern
module ClassMethods
def notify_all_callbacks
# Make sure all models are loaded before trying to enumerate
@LCShen
LCShen / mdb.rb
Created May 10, 2017 09:05 — forked from ecleel/mdb.rb
Ruby MS Access adapter
require 'rubygems'
require 'win32ole'
require 'csv'
mdb_file="c:/Sites/labs/50q.bok"
class AccessDb
attr_accessor :mdb, :connection, :data, :fields, :catalog
def initialize(mdb=nil)
@LCShen
LCShen / msaccess_adapter.rb
Created April 18, 2017 14:05 — forked from dcparker/msaccess_adapter.rb
msaccess_adapter.rb for an older version of ActiveRecord
require 'active_record/connection_adapters/abstract_adapter'
require 'bigdecimal'
require 'bigdecimal/util'
# msaccess_adapter.rb -- ActiveRecord adapter for Microsoft Access Db
#
# "Adapted" from the sqlserver_adapter.rb for Microsoft SQL Sever:
# Author: Joey Gibson <joey@joeygibson.com>
#
@LCShen
LCShen / legacy.markdown
Created March 22, 2017 15:27 — forked from jcasimir/legacy.markdown
Legacy Databases

Legacy Databases

Not every application starts from scratch, sometime you have to deal with a legacy database. Walking the Rails golden path makes life easy, and there's a perception that stepping off that path is incredibly painful.

It's not true. If your database is well designed and but doesn't follow the Rails naming conventions, it's easy to make them play nicely together. However, if your database structure is crap to begin with, then there's only so much Rails can do for you. ActiveRecord is a mapper between the database and objects, but it's not a DBA-in-a-Box.

Theory

In a green-field app, ActiveRecord and the Database fit right together:

@LCShen
LCShen / dabblet.css
Created March 10, 2017 14:12 — forked from ryanj/dabblet.css
A Sample CSS upgrade for Eventbrite's default event pages
/**
* A Sample CSS upgrade for Eventbrite's default event pages
*/
/*-----------------------------------------------------------------
Theme: No Compromises
By: The Eventbrite Design Team
To use this theme follow these five easy steps.
1) Login to your Eventbrite account. If you don't have one visit
@LCShen
LCShen / railscasts.rb
Created January 31, 2017 00:46 — forked from samqiu/railscasts.rb
Download free Railscast video
#!/usr/bin/ruby
require 'rss'
# Usage
# $ ./railscasts.rb http://railscasts.com/subscriptions/YOURRAILSCASTRSS/\/
# episodes.rss
# OR
# $ ./railscasts.rb
p 'Downloading rss index'