Skip to content

Instantly share code, notes, and snippets.

View TheNicholasNick's full-sized avatar

Nicholas Nick TheNicholasNick

View GitHub Profile
// MAP
function(doc) {
if(doc["couchrest-type"] == "Quote" && doc.user_id && doc.updated_at && doc.created_at
&& doc.drivers["0"]["last_name"] && doc.drivers["0"]["first_name"]
&& doc.vehicle["year"] && doc.vehicle["make"] && doc.vehicle["family"]
&& doc.result["dollars"]["total"]
&& doc.updated_at && doc.created_at) {
emit(
doc.user_id
,{
@TheNicholasNick
TheNicholasNick / extjs_load_radio.js
Created April 24, 2009 09:47
ExtJS load radiogroup values
new Ext.form.FormPanel({
items: [{
xtype: "radiogroup"
,fieldLabel: "Gender"
,allowBlank: false
,items: [{
boxLabel: "Yes"
,name: "person-gender_rb"
,id: "person-gender_rb-true"
,inputValue: "true"
xml.instruct!
xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do
xml.title Blog.title
xml.id Blog.url_base
xml.updated @posts.first.created_at.iso8601 if @posts.any?
xml.author { xml.name Blog.author }
@posts.each do |post|
xml.entry do
xml.title post.title
@TheNicholasNick
TheNicholasNick / relax.js
Created April 2, 2009 23:56
CouchDB Map/Reduce Example
// Data
[
{"_id":"pvg:IHC09A","_rev":"1-3881006720","nvic":"IHC09A","family":"159","couchrest-type":"GRD::Pvg","make":"ALFA ROMEO"},
{"_id":"pvg:IJU09A","_rev":"1-243536901","nvic":"IJU09A","family":"147","couchrest-type":"GRD::Pvg","make":"ALFA ROMEO"},
{"_id":"pvg:IJV09A","_rev":"1-3794903136","nvic":"IJV09A","family":"147","couchrest-type":"GRD::Pvg","make":"ALFA ROMEO"},
{"_id":"pvg:IJY09A","_rev":"1-1301614913","nvic":"IJY09A","family":"147","couchrest-type":"GRD::Pvg","make":"ALFA ROMEO"},
{"_id":"pvg:J3X09A","_rev":"1-1398113861","nvic":"J3X09A","family":"V8","couchrest-type":"GRD::Pvg","make":"ASTON MARTIN"}
]
// Map
$ rake --trace install >> rake_install_fails 2>&1
(in /opt/rubinius)
** Invoke vm/.depends.mf (first_time, not_needed)
** Invoke vm/external_libs/libmpa/libptr_array.a (first_time, not_needed)
** Invoke vm/external_libs/libcchash/libcchash.a (first_time, not_needed)
** Invoke vm/external_libs/libmquark/libmquark.a (first_time, not_needed)
** Invoke vm/external_libs/libtommath/libtommath.a (first_time, not_needed)
** Invoke vm/external_libs/libbstring/libbstring.a (first_time, not_needed)
** Invoke vm/external_libs/libgdtoa/libgdtoa.a (first_time, not_needed)
zn01 rubinius # ln -s /opt/rubinius/bin/rbx /usr/bin/rbx
zn01 rubinius # rbx -v
rubinius 0.11.0-dev (ruby 1.8.6) (82e2017bd 12/31/2009) [x86_64-unknown-linux-gnu]
zn01 rubinius # cd /opt/src/rubygems-1.3.1
zn01 rubygems-1.3.1 # rbx setup.rb
mkdir -p /opt/rubinius/lib/rubinius/0.11
mkdir -p /opt/rubinius/bin
mkdir -p /opt/rubinius/lib/rubinius/0.11/rbconfig
install -c -m 0644 rbconfig/datadir.rb /opt/rubinius/lib/rubinius/0.11/rbconfig/datadir.rb
mkdir -p /opt/rubinius/lib/rubinius/0.11/rubygems
stage_sites@box01 ~/test $ bin/merb
An exception has occurred:
Bounds of object exceeded:
type: Tuple, bytes: 304, accessed: 47
(ObjectBoundsExceededError)
Backtrace:
Compiler::Utils.compile_feature at kernel/compiler/compile.rb:145
Compiler::Utils.single_load at kernel/compiler/compile.rb:207
Compiler::Utils.unified_load {} at kernel/compiler/compile.rb:131
irb(main):008:0> i.dt1app = "qw"
=> "qw"
irb(main):009:0> i
=> #<I90Rfprsn krpkyp=1 nam3np=nil nam1np=nil krpnip=nil kemadp=nil krfgrp=nil krfgsp=nil krfidp=nil krpasp=nil dt1app=nil dtaccp=nil dtermp=nil krftyp=nil iddatp=nil idtimp=nil usrpfp=nil krckyp=nil krfkyp=nil>
irb(main):010:0>
class Content < Application
# GET /content
def index
render
end
end
class BaseModel < CouchRest::ExtendedDocument
# I like nil instead of Exceptions when resources can not be found.
def self.get(id)
begin
super
rescue RestClient::ResourceNotFound
nil
end
end