users = User.arel_table
comments = Comment.arel_table
#select users with comments
User.join(
users.joins(comments).on(
users[:id].eq(comments[: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
<header> | |
<span class="logo">Gizmosan</span> | |
<nav class="site-nav"> | |
<a href="#">TVs</a> | |
<a href="#">Tablets</a> | |
<a href="#">PCs</a> | |
<form> | |
<input type="search" results=5 placeholder="search..." /> | |
<button>Search</button> | |
</form> |
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
if [ -r $HOME/.rbenvrc ]; | |
then | |
source $HOME/.rbenvrc | |
fi | |
if [ -r $HOME/.app_vars ]; | |
then | |
source $HOME/.app_vars | |
fi |
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
Mixin = require './mixin.coffee' | |
Module = require './module.coffee' | |
class Logger extends Mixin | |
yo = (msg) -> console.log msg | |
class_log: yo | |
@log: yo | |
class MyLogger extends Module | |
@extends Logger |
I hereby claim:
- I am wycleffsean on github.
- I am sean_carey (https://keybase.io/sean_carey) on keybase.
- I have a public key ASDMtr0za7DM5LVpJAR2Y5cvKrT-vz9MESI7MstPnInMIAo
To claim this, I am signing this object:
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
namespace :db do | |
task dump_seeds: :environment do | |
Rails.application.eager_load! | |
path = 'db/fixtures/gen/%s.rb' | |
ObjectSpace.each_object(Class) | |
.select{|c| c < ActiveRecord::Base && !c.abstract_class? } | |
.each do |c| | |
# skip if it's a view | |
next if c.new.readonly? | |
next unless c.attribute_names.include?('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
require 'securerandom' | |
require 'pp' | |
Ex = Struct.new(:a,:b,:c,:d) | |
module Enumerable | |
def group(&block) | |
groups = Hash.new | |
each do |item| | |
matches = [] |
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
AllCops: | |
Exclude: | |
- 'spec/dummy/**/*' | |
- 'tmp/**/*' | |
Lint/HandleExceptions: | |
Exclude: | |
- 'spec/support/database.rb' | |
Style/TrailingCommaInArguments: | |
Enabled: false | |
Metrics/BlockLength: |
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
require 'fiber' | |
require 'concurrent' # gem install concurrent-ruby | |
Thread.abort_on_exception = true | |
class Async | |
def self.perform(&block) | |
instance = new | |
instance.instance_eval(&block) | |
until instance.dispatched.value.zero? do | |
unless instance.yields.empty? |
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
namespace :accio do | |
desc "Drop/restore database from Heroku backup" | |
task :db do | |
Rake::Task['accio:download_backup'].invoke | |
Rake::Task['accio:restore_backup'].invoke | |
end | |
desc "Download database dump from Heroku" | |
task :download_backup => [:logger_no_env, '~/.netrc'] do |t, args| | |
return Rails.logger.error('curl not installed') unless \ |
OlderNewer