Skip to content

Instantly share code, notes, and snippets.

View matiasmoya's full-sized avatar

Matt Hinczuk matiasmoya

View GitHub Profile
require 'spec_helper'
describe "Artists to releases relationship" do
before(:all) do
@kanye = FactoryGirl.create(:artist, :name => 'Kanye West')
@jz = FactoryGirl.create(:artist, :name => 'Jay Z')
@watch_the_throne = FactoryGirl.create(:release, :name => 'Watch the Throne')
@dropout = FactoryGirl.create(:release, :name => 'The College Dropout')
end
@matiasmoya
matiasmoya / index.html
Created June 17, 2014 00:26
Primera web de Pablo Bovi
<!DOCTYPE html>
<html>
<head>
<title> TyC SPOTS</title>
<meta charset="utf-8" />
</head>
<body bgcolor="#426669">
<h1 style="text-align:center; colour: blue;">TyC SPORTS</h1>
@matiasmoya
matiasmoya / seed.rb
Created January 28, 2015 20:47
Seeds with prompts
puts "**** Please enter the desired email for the Administrator ****"
email = STDIN.gets.chomp
puts "**** Please enter the desired password for the Administrator ****"
password = STDIN.gets.chomp
admin = Admin.new(:email => email, :password => password)
if admin.save
@matiasmoya
matiasmoya / gist:49a6a706f0046b738d6e
Created January 28, 2015 21:13
Rails model errors
= form_for @certificate
- if @certificate.errors.any?
ul.error-list
- @certificate.errrors.each do |error|
li.error-item #{error}
@matiasmoya
matiasmoya / amazon_sync.rb
Created February 2, 2015 18:51
Vacuum - Amazon Product Advertising API
require 'vacuum'
class AmazonSync
def test
@request = Vacuum.new
@request.configure(
aws_access_key_id: ENV['AMAZON_ACCESS_KEY'],
aws_secret_access_key: ENV['AMAZON_SECRET_ACCESS_KEY'],
associate_tag: ENV['AMAZON_ASSOCIATE_TAG']
)
@matiasmoya
matiasmoya / Sender.rb
Created February 3, 2015 15:48
Send confirmation email callback w/devise. Confirmable module with allow login without confirmation
def confirmation_email(user)
@user = user
@token = user.confirmation_token
mail(to: @user.email, subject: 'Please confirm your account')
end
@matiasmoya
matiasmoya / index.html
Last active August 29, 2015 14:18
Social icons
<ul class="social">
<li><a href="#" class="fb">Facebook</a></li>
<li><a href="#" class="tw">Twitter</a></li>
<li><a href="#" class="google">Google+</a></li>
<li><a href="#" class="insta">Instagram</a></li>
<li><a href="#" class="skype">Skype</a></li>
<li><a href="#" class="vimeo">Vimeo</a></li>
</ul>
@matiasmoya
matiasmoya / facebook.js.coffee
Created April 8, 2015 18:35
facebook login async
jQuery ->
$('body').prepend('<div id="fb-root"></div>')
$.ajax
url: "#{window.location.protocol}//connect.facebook.net/en_US/all.js"
dataType: 'script'
cache: true
window.fbAsyncInit = ->
class DeviseSessionsController < Devise::SessionsController
clear_respond_to
respond_to :json
end
Product
has_many reviews
...
positives = Product.includes(:reviews).select("COUNT(reviews.rating) AS cta").having("cta > 3")
...
def self.positves
includes(:reviews).select("id", "COUNT(reviews.rating) AS cta").having("cta > 3")
end
...
Product.where(:id.nin => positives.pluck(:id))