Skip to content

Instantly share code, notes, and snippets.

🎯
Aiming hard

Bobby Uhlenbrock uhlenbrock

🎯
Aiming hard
Block or report user

Report or block uhlenbrock

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@uhlenbrock
uhlenbrock / Braze > Lambda > S3
Last active Feb 7, 2019
Use Lambda & S3 to save a copy of all sent email via Braze
View Braze > Lambda > S3
Webhook URL: https://<api_gateway_url>/prod/uploadEmail?user_id={{${user_id}}}&template_name=<template_name>
Request Body: (select raw text), paste in entire email HTML
@uhlenbrock
uhlenbrock / aggregate.rb
Created Jun 15, 2017
Aggregate minitest failures in S3
View aggregate.rb
module Minitest
def self.plugin_aggregate_init
reporter << Aggregate.new
end
class Aggregate
attr_accessor :branch
attr_accessor :build
attr_accessor :failed_tests
attr_accessor :timestamp
@uhlenbrock
uhlenbrock / barcode_analyzer.rb
Last active Jun 9, 2017
Read Barcodes with a Dragonfly Analyzer
View barcode_analyzer.rb
class BarcodeAnalyser
def call(app, opts = {})
# OS X: `brew install zbar`
# Ubuntu: `apt-get install zbar-tools`
app.env[:zbar_command] = opts[:zbar_command] || 'zbarimg'
app.define :barcode do
@barcode ||= begin
shell_eval { |path| "#{app.env[:zbar_command]} -q --raw #{path}" }
rescue Dragonfly::Shell::CommandFailed => e
@uhlenbrock
uhlenbrock / dragonfly.rb
Last active Jun 9, 2017
Read EXIF data with a Dragonfly Analyzer
View dragonfly.rb
require 'dragonfly'
require 'exif_analyser'
Dragonfly.app.configure do
plugin ExifAnalyser.new
end
@uhlenbrock
uhlenbrock / init.coffee
Created Mar 13, 2014
Open the last migration created in a rails project
View init.coffee
atom.workspaceView.command 'last-migration', ->
migrate_directory = atom.project.getRootDirectory()
migrate_directory.path = "#{migrate_directory.path}/db/migrate"
last_migration = migrate_directory.getEntriesSync().pop()
atom.open
pathsToOpen: [last_migration.path]
@uhlenbrock
uhlenbrock / init.coffee
Created Mar 13, 2014
Force Atom to load rails grammar over ruby grammar
View init.coffee
path = require 'path'
atom.workspaceView.eachEditorView (editorView) ->
editor = editorView.getEditor()
grammar = switch path.extname(editor.getPath())
when '.rb' then atom.syntax.grammarsByScopeName['source.ruby.rails']
when '.erb' then atom.syntax.grammarsByScopeName['text.html.ruby']
@uhlenbrock
uhlenbrock / sale.rb
Created Oct 30, 2012
Refactor a type implementation
View sale.rb
###---------------------------------------------------- Class Methods
def sale_type
@sale_type ||= Sale.sale_type_ids[ self.sale_type_id - 1 ][0]
end
###---------------------------------------------------- Class Methods
def self.sale_type_ids
View application_controller.rb
require 'lorem'
class ApplicationController < ActionController::Base
layout 'public'
helper_method :lorem
def lorem
@lorem ||= LoremObject.new
end
@uhlenbrock
uhlenbrock / deploy.rb
Created Dec 14, 2011
Precompile assets locally for Capistrano deploy
View deploy.rb
load 'deploy/assets'
namespace :deploy do
namespace :assets do
desc 'Run the precompile task locally and rsync with shared'
task :precompile, :roles => :web, :except => { :no_release => true } do
%x{bundle exec rake assets:precompile}
%x{rsync --recursive --times --rsh=ssh --compress --human-readable --progress public/assets #{user}@#{host}:#{shared_path}}
%x{bundle exec rake assets:clean}
end
@uhlenbrock
uhlenbrock / integration_test_helper.rb
Created Sep 7, 2011
Integration Testing with Capybara & Devise
View integration_test_helper.rb
require 'test_helper'
require 'capybara/rails'
require 'devise/test_helpers'
class ActionController::IntegrationTest
include Capybara::DSL
include Warden::Test::Helpers
self.use_transactional_fixtures = false
You can’t perform that action at this time.