This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
brew install postgresql | |
sudo ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents | |
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist | |
createuser -d -P admin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{!< default}} | |
{{> header}} | |
<main class="main_pixel headline" role="main"> | |
{{#foreach posts}} | |
<article class="article_pixel" role="article" itemscope itemtype="http://schema.org/Article"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
render json: { | |
item: { | |
name: item.name, | |
kind: item.kind, | |
details_en: item.details_en | |
}, | |
rating: item.ratings.where(user_id: @current_user.id) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
irb(main):028:0* User.collection | |
=> #<Moped::Collection:0x007fcb8dafed20 @database=#<Moped::Database:0x007fcb8dafeeb0 @session=<Moped::Session seeds=[<Moped::Node resolved_address="54.74.247.101:63879">] database=gemfeeddb>, @name="gemfeeddb">, @name="users"> | |
irb(main):029:0> User.collection.remove | |
NoMethodError: undefined method `remove' for #<Moped::Collection:0x007fcb8db07678> | |
from (irb):29 | |
from /Users/borjagvo/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.1.4/lib/rails/commands/console.rb:90:in `start' | |
from /Users/borjagvo/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.1.4/lib/rails/commands/console.rb:9:in `start' | |
from /Users/borjagvo/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.1.4/lib/rails/commands/commands_tasks.rb:69:in `console' | |
from /Users/borjagvo/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.1.4/lib/rails/commands/commands_tasks.rb:40:in `run_command!' | |
from /Users/borjagvo/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.1.4/lib/rail |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= form_for @user, url: admin_user_path(@user) do |f| %> | |
<%= f.label :name %> | |
<%= f.text_field :name %> | |
<br> | |
<%= f.label :email %> | |
<%= f.text_field :email %> | |
<br> | |
<%= f.label :roles %> | |
<%= f.fields_for :roles do |roles_fb| %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
olds = Item.order_by(id: 1).skip(new_batch*10000).limit(10000).not_in(id: set) | |
olds.each do |doc| | |
... | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.ratings.find().forEach(function(doc){ | |
var item = db.items.find({_id: doc.item_id}) | |
var ry = item.detail.ry | |
}) | |
ITEM |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TEST.JS | |
db.createCollection("test_index") | |
db.test_index.ensureIndex({"t.n":"text"}) | |
var mydocs = [ | |
{t: [{language: "english", n: "Mother 1"},{language: "spanish", n: "Madre 1"}]}, | |
{t: [{language: "english", n: "Spreme 1"},{language: "spanish", n: "Edificio 1"}]} | |
] | |
db.test_index.insert(mydocs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User | |
include Mongoid::Document | |
has_many :wishlists, class_name: "Item" | |
end | |
In rails s: | |
>> u = User.first | |
>> u.wishlists.push(Item.first) |
OlderNewer