Skip to content

Instantly share code, notes, and snippets.

View fellix's full-sized avatar

Rafael Felix fellix

View GitHub Profile
@fellix
fellix / gist:803379
Created January 30, 2011 23:03
discus error
/home/suerafa/.rvm/gems/ruby-1.9.2-p136@1_9_2_gemset/gems/json-1.5.1/lib/json/common.rb:66: [BUG] unknown type 0x22 (0xc given)
ruby 1.9.2p136 (2010-12-25 revision 30365) [x86_64-linux]
-- control frame ----------
c:0053 p:---- s:0173 b:0173 l:000172 d:000172 CFUNC :initialize
c:0052 p:---- s:0171 b:0171 l:000170 d:000170 CFUNC :new
c:0051 p:0099 s:0168 b:0166 l:000165 d:000165 METHOD /home/suerafa/.rvm/gems/ruby-1.9.2-p136@1_9_2_gemset/gems/json-1.5.1/lib/json/common.rb:66
c:0050 p:0208 s:0157 b:0156 l:000155 d:000155 CLASS /home/suerafa/.rvm/gems/ruby-1.9.2-p136@1_9_2_gemset/gems/json-1.5.1/lib/json/ext.rb:24
c:0049 p:0011 s:0154 b:0154 l:000153 d:000153 CLASS /home/suerafa/.rvm/gems/ruby-1.9.2-p136@1_9_2_gemset/gems/json-1.5.1/lib/json/ext.rb:6
c:0048 p:0021 s:0152 b:0152 l:000151 d:000151 TOP /home/suerafa/.rvm/gems/ruby-1.9.2-p136@1_9_2_gemset/gems/json-1.5.1/lib/json/ext.rb:3
def show
@post = Post.find params[:id]
end
def self.find_by_url(friendly_id)
result = self.joins("JOIN slugs ON slugs.sluggable_id = posts.id and slugs.sluggable_type = 'Post'").where("slugs.name = ?", friendly_id).first
raise ActiveRecord::RecordNotFound unless result
result
end
@fellix
fellix / gist:1031301
Created June 17, 2011 12:14
JSON Export
File.open( 'a.json', 'w') { |f| f.write Imovel.all.to_json(:include => {:videos => { :except => :updated_at }, :fotos => {:methods => :public_filename} }) }
@fellix
fellix / Gemfile
Created July 6, 2011 12:10
JasmineRice
group :development, :test do
gem 'rspec-rails'
gem 'shoulda'
gem 'jasmine'
gem "jasminerice"
end
@fellix
fellix / backbome model.js
Created July 19, 2011 13:12
backbone sample
window.Album = Backbone.Model.extend({
url: function(){
return this.id ? '/collection/'+this.album_collection_id+'/album/'+this.id : '/collection/'+this.album_collection_id+'/albums';
},
defaults: { album: {
album_collection_id: 0,
title: "nothing",
artist: "nobody",
image: "",
price: 0.0,
@fellix
fellix / collections.js
Created July 19, 2011 13:18
backbone sample
window.AlbumsCollection = Backbone.Collection.extend({
model: Album,
initialize: function(collection_id){
this.url = '/collection/'+collection_id+"/albums";
}
});
@fellix
fellix / router.js
Created July 19, 2011 13:24
backbone sample
var AlbumController = Backbone.Router.extend({
routes: {
"collection/:album_collection_id/album/:id" : "show",
},
initialize: function(options) {
},
show: function(album_collection_id, id){
var albums = new SingleAlbumCollection(album_collection_id, id);
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="content-type" />
<title>Home</title>
</head>
<body class="lift:content_id=main">
<div id="main" class="lift:surround?with=default;at=content">
<div>
Hi, I'm a page that contains the time:
@fellix
fellix / user.rb
Created August 29, 2011 15:08
Has Secure Password
# Schema: User(name:string, password_digest:string, password_salt:string)
class User < ActiveRecord::Base
has_secure_password
end
user = User.new(:name => "david", :password => "", :password_confirmation => "nomatch")
user.save # => false, password required
user.password = "mUc3m00RsqyRe"
user.save # => false, confirmation doesn't match
user.password_confirmation = "mUc3m00RsqyRe"