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
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 } }
@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:

{
"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"
],
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"
@bobbytables
bobbytables / rdio_volume_hack.js
Created May 21, 2014 17:02
This makes the Rdio volume slider larger so the ticks of volume control change the setting slightly less.
$('div.volume_wrapper').css({width: '150px'}).find('.Volume').css({width: '150px'})
Hardware Overview:
Model Name: MacBook Pro
Model Identifier: MacBookPro11,3
Processor Name: Intel Core i7
Processor Speed: 2.6 GHz
Number of Processors: 1
Total Number of Cores: 4
L2 Cache (per Core): 256 KB
L3 Cache: 6 MB
@bobbytables
bobbytables / json_generation_benches.rb
Last active August 29, 2015 14:07
Kartograph for JSON generation is fast.
require 'benchmark/ips'
require 'active_support/core_ext'
require 'jbuilder'
require 'kartograph'
require 'active_model_serializers'
require 'pry'
User = Struct.new(:id, :name, :email) do
def read_attribute_for_serialization(attribute)
send(attribute)
syntax = "proto3";
message Error {
string message = 1;
int32 error_code = 20;
}
message Application {
string id = 1;
string type = 2;
@bobbytables
bobbytables / build.sh
Created February 18, 2017 15:49
Protocol Buffer build script for multiple folders
#!/usr/bin/env bash
# This script is meant to build and compile every protocolbuffer for each
# service declared in this repository (as defined by sub-directories).
# It compiles using docker containers based on Namely's protoc image
# seen here: https://github.com/namely/docker-protoc
set -e
REPOPATH=${REPOPATH-/opt/protolangs}
CURRENT_BRANCH=${CIRCLE_BRANCH-"branch-not-available"}
@bobbytables
bobbytables / brace.yml
Created October 6, 2017 00:18
A sample file of what a brace rule set could look like
version: 1
environment:
- name: LISTEN_ADDRESS
value: "localhost:8080"
usage: "This is the address that the application listens on"
- name: HEALTH_ADDRESS
value: "localhost:8080/healthz"
usage: "This is the endpoint for health checks performed by kubernetes"
- name: DATABASE_URL
value: "postgres://postgres:5432"