Skip to content

Instantly share code, notes, and snippets.

View bobbytables's full-sized avatar
🔥
Putting out fires

Robert Ross bobbytables

🔥
Putting out fires
View GitHub Profile
alias ta="tmux attach-session -t"
alias tn="tmux new-session -s"
alias tl="tmux list-sessions"
alias tk="tmux kill-session -t"
export EDITOR=subl
source ~/.git-completion.sh
# Aliases!!
alias ls="ls -lsa"
{
"always_show_minimap_viewport": false,
"color_scheme": "Packages/Tomorrow Color Schemes/Tomorrow-Night.tmTheme",
"draw_centered": false,
"font_face": "Ubuntu Mono",
"font_size": 16,
"ignored_packages":
[
"Vintage"
],
@bobbytables
bobbytables / cli_aliases.md
Created February 26, 2013 08:06
Aliases and Profiles

So an alias in your terminal is a shortcut to a command, or command with arguments.

For example, Brendan has an alias for ll (double L) that does the ls -l command. Which as we showed will display a list of files vertically in your terminal instead the hard-to-read horizontal way.

These are extremely handy for when you see yourself doing the same command over and over, just make an alias!

To do so, we're going to add it to your profile file. This file is run everytime you start a new session in your terminal (so starting terminal, or a new tab).

Open up terminal. Type in:

require 'benchmark'
task :db_bench => :environment do
Benchmark.bm do |b|
b.report { 1.upto(10000) { User.first } }
b.report { 1.upto(10000) { User.select([:email, :default_edition_id]).first } }
b.report { 1.upto(10000) { User.first.created_at } }
b.report { 1.upto(10000) { User.select([:created_at, :default_edition_id]).first.created_at } }
gem "capybara", "~> 2.0.1"
gem "database_cleaner", "~> 0.9.1"

# We're using this version until it gets merged in to support Capybara v2
# https://github.com/jonleighton/poltergeist/pull/208
gem "poltergeist", git: "https://github.com/brutuscat/poltergeist.git"
class BobbyTables
  attr_accessor :tied_shoes

  def tied_shoes?
    !!tied_shoes
  end

  def tie_shoes!
 self.tied_shoes = true
@bobbytables
bobbytables / explain.md
Created December 3, 2012 19:49
Problem query explain
+----+-------------+-------+------+------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------+---------+----------------------------------+---------+---------------------------------+
| id | select_type | table | type | possible_keys                                                                                                                            | key                                           | key_len | ref                              | rows    | Extra                           |
+----+-------------+-------+------+------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------+---------+----------------------------------+---------+---------------------------------+
|  1 | SIMPLE      | users | ALL  | NULL                                            
@bobbytables
bobbytables / query.sql
Created December 3, 2012 19:42
Problem query
Here's my query:
SELECT SQL_BUFFER_RESULT SQL_BIG_RESULT users.id, users.email,
COUNT(av.user_id) AS article_views_count,
COUNT(af.id) AS article_favorites_count,
COUNT(lc.user_id) AS link_clicks_count,
COUNT(ai.user_id) AS ad_impressions_count,
COUNT(ac.user_id) AS ad_clicks_count
FROM users
@bobbytables
bobbytables / temporary_table.rb
Created December 1, 2012 01:08
Temporary Table class for creating a join table
class TemporaryTable
attr_reader :name_prefix, :attributes
def initialize(name_prefix, attributes)
@name_prefix = name_prefix
@attributes = attributes
create_temp_table!
end
def table_name
@bobbytables
bobbytables / questions.md
Created November 27, 2012 00:24
Repository Pattern questions

Attempting to find a good way to give a wrapper around AR objects to give them Repository pattern effects.

  • Do validations stay on the ActiveRecord model or do they move to the Repository object?

  • Is delegating attributes / errors / finders to the AR object bad?

    For example: UserRepository.new.errors => Calls user.errors ?

  • When calling associations (User => Comments), does the Repository return CommentRepository objects, or Comment objects?