Oct 16 2010
- 04/10/2011 - Updated application.js and application.rb thanks to @rebo's comments
In this article, I will walk through some simple steps to get a [demo app][2] up and running with [Backbone.js][3] and [Sinatra][4] on [Heroku][5].
| # MongoMapper "embedded document delete" plugin | |
| # By Peter Cooper | |
| # | |
| # Got embedded documents you want to delete? You can delete them as if the | |
| # embedded document collection were an array, but then there's no way to get | |
| # a callback (as far as I could tell). This plugin gives you a call back | |
| # (if you want it) and gives a nicer syntax to deleting embedded docs. | |
| # | |
| # Example: | |
| # |
| def is_ajax_request? | |
| if respond_to? :content_type | |
| if request.xhr? | |
| true | |
| else | |
| false | |
| end | |
| else | |
| false | |
| end |
| # /usr/bin/env ruby | |
| puts <<-EOF | |
| Clone Yer GitHub Repos, Fast! - v0.2.1 - 4/13/2011 | |
| http://benalman.com/ | |
| For when you're on a new computer and need all your stuff, fast! | |
| EOF | |
| copyright = <<-EOF |
| require 'cgi' | |
| require 'digest/md5' | |
| require 'net/https' | |
| require 'uri' | |
| module Jekyll | |
| class GistTag < Liquid::Tag | |
| def initialize(tag_name, text, token) | |
| super | |
| @text = text |
| class SatoshiVersion | |
| # ... | |
| def to_s | |
| components = @version_components.dup | |
| components.delete_at(3) if components[3] == 0 | |
| components.join(".") | |
| end | |
| alias_method :to_str, :to_s |
| emotion :+1: :-1: :clap: :heart: :sparkles: :v: :zzz: | |
| icon :new: :ok: :cool: :vs: :tm: :warning: :wheelchair: :zap: :art: :bomb: :bulb: :key: :lock: :memo: :mag: | |
| item :book: :gift: :moneybag: :mega: :scissors: :hammer: | |
| device :computer: :iphone: :calling: :email: | |
| human :cop: :runner: :feet: :fist: :punch: :lipstick: :tophat: | |
| food :beer: :cake: :smoking: | |
| behicle :airplane: :bike: :bus: :ski: :taxi: :train: | |
| animal :bear: :fish: :octocat: | |
| nature :fire: :leaves: :star: :sunny: |
| $('#products').append('<%= j render(@products) %>'); | |
| <% if @products.next_page %> | |
| $('.pagination').replaceWith('<%= j will_paginate(@products) %>'); | |
| <% else %> | |
| $('.pagination').remove(); | |
| <% end %> |
| source "https://rubygems.org" | |
| gem 'sprockets' | |
| gem 'sprockets-sass' | |
| gem 'sass' | |
| gem 'compass' | |
| gem 'bootstrap-sass' | |
| gem 'handlebars_assets' | |
| gem 'coffee-script' |
Dear Rubyists,
I just lost a contract because of my code in a Rails project.
The specific code in question is related to a "posting a comment" feature. Here are the details:
In this project, "posting a comment" does not simply entail inserting a row into the database. It involves a procedure to yes, insert a row, but also detect its language, check for spam, send emails, and "share" it to Twitter and Facebook. I believe this algorithm should be encapsulated. I do not believe it belongs in a controller or a model. I do not believe Active Record callbacks should be used.
The "senior developer", whom is the stake holder's right hand man, said this: