- Marshaling AR objects: dangerous if internal structure of AR object changes with Rails change
- Is it ok for users to see slightly older data?
- Initializer that loads yaml file that loads different connections per Rails environtment
### | |
# lolquery is an fresh new take on SQL DSLs. NEVER WRITE SQL AGAIN! Using | |
# amazing lolquery technology, you too will never have to write another SQL | |
# statement again! | |
# | |
# Check out this simple example of using lolquery. Bask in it's simplicity, | |
# it's expressiveness, but most importantly, it's lack of writing SQL! | |
# | |
# <3 <3 <3 <3 <3 |
# for some reason active record doesn't include a simple way to serialize to | |
# cache. this simple trick will take you far | |
# | |
# usage: | |
# | |
# user = User.find(id) | |
# | |
# key = "user-#{ user.id }" | |
# | |
# Rails.cache.write(key, user.to_cache) |
Just install this in your apps like so:
gem 'test-spec-mini', :git => 'git://gist.github.com/1806986.git', :require => 'mini'
# Run command(s) over SSH | |
run() { | |
ssh deploy@${HOST} -t $* || exit 1 | |
} | |
# Transfer all the specified files/directories to working directory | |
upload() { | |
tar czf - $* | ssh deploy@${HOST} tar xzf - -C /etc/chef || exit 1 | |
} |
Installing rbx-2.0.0-dev with Ruby 1.9 support using rbenv can be a tad tricky. This is what I did to get up and running, you'll need another version of ruby already installed as well as rake.
The basic outline:
<?xml version="1.0" encoding="UTF-8"?> | |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>com.example</groupId> | |
<artifactId>my-project</artifactId> | |
<version>0.0.1-SNAPSHOT</version> | |
<dependencies> | |
<!-- none yet --> |
Chances are your head's spinning right now. That accusation of bias caught you off guard, you got kind of defensive, and now all hell has broken loose. You're feeling attacked on all sides. You're a good person at heart, and having all these people treat you like the antichrist is pretty upsetting.
You need to say something, but you're probably not in the best headspace to write copy right now. So to help you along, here's my 100% guaranteed-or-you-money-back scandal defusement apology template:
# A chainable Either monad for Ruby | |
# | |
# Examples | |
# | |
# Either.right('s') >> proc { |s| Either.right(s + '-1') } >> proc { |s| Either.right(s + '-2') } | |
# #=> #<Either @left=nil, @right="s-1-2"> | |
# | |
# Either.right('s') >> proc { |s| Either.left('error!') } >> proc { |s| Either.right(s + '-2') } | |
# #=> #<Either @left='error!', @right=nil> | |
# |
# MOTIVATION: As rails apps are growing, people are noticing the drawbacks | |
# of the ActiveRecord pattern. Several apps I have seen, and several | |
# developers I have spoken to are looking towards other patterns for object | |
# persistence. The major drawback with ActiveRecord is that the notion | |
# of the domain object is conflated with what it means to store/retrieve | |
# it in any given format (like sql, json, key/value, etc). | |
# | |
# This is an attempt to codify the Repository pattern in a way that would | |
# feel comfortable to beginner and seasoned Ruby developers alike. | |
# |