Skip to content

Instantly share code, notes, and snippets.

Todos.tasksController = SC.ArrayController.create(
SC.CollectionViewDelegate,
/** @scope Todos.tasksController.prototype */ {
summary: function() {
var len = this.get("length"), ret;
if (len && len > 0) {
ret = len === 1 ? "1 tasks" : "%@ tasks".fmt(len);
} else {
server {
location / {
if (-f $document_root/system/maintenance.html) {
return 503;
}
try_files $uri $uri/index.html @proxy;
}
maintainer "Outright, Inc"
maintainer_email "ops@outright.com"
license "Apache 2.0"
description "Installs/Configures metrics"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc'))
version "0.1"
%w{nodejs mongodb god}.each do |d|
depends d
end
class Model < ActiveRecord::Base
default_scope order("title desc")
scope :with_city, lambda { |city| where("city = ?", city) }
def self.search
# How do I do this? Need to remove a relation
self.scoped.remove(self.default_scoping).all
end
end
Model.with_city('San Francisco').search # What I want -> select * from models where city = 'San Francisco'
@bcurren
bcurren / redis_pubsub_demo.rb
Created May 3, 2011 21:19 — forked from pietern/redis_pubsub_demo.rb
Updated redis pubsub with cramp
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
conn = ...
broadcastAddr *net.UDPAddr, request *http.Request = makeSearchRequest(st, mx)
err = request.Write(func Write(p []byte) (n int, err error) {
return conn.WriteTo(p, broadcastAddr)
})