Skip to content

Instantly share code, notes, and snippets.

View pboling's full-sized avatar
🏓
Ping me if you need me!

Peter Boling pboling

🏓
Ping me if you need me!
View GitHub Profile
@pboling
pboling / hash_delegate.rb
Created February 9, 2024 15:37 — forked from eric-hemasystems/hash_delegate.rb
Rails `delegate to:` for hashes
module HashDelegate
# Like `delegate :foo, to: :bar` only for hashes instead
# of objects. So these are the same:
#
# def foo
# bar[:foo]
# end
#
# hash_delegate :foo, to: :bar
task :generate_engine do
# Get name sent from console
name = ENV['name'].downcase
# Store useful paths
engine_path = "engines/#{name}"
dummy_path = 'spec/dummy'
lib_files_path = 'lib/tasks/files'
dummy_relative_path = "#{engine_path}/#{dummy_path}"
@pboling
pboling / rails_single_file.rb
Last active December 1, 2018 16:16 — forked from clupprich/rails_single_file.rb
Rails app w/ tests in a single file
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
source "https://rubygems.org"
@pboling
pboling / plpgsql.rake
Last active October 12, 2015 18:56 — forked from rietta/plpgsql.rake
Are you using PostgreSQL and don't want to make your app run as PostgreSQL super user, then add this custom rake task to your `lib/tasks` folder and be happy.
#
# PostgreSQL writes two optional commands to the database schema
# file, called db/structure.sql, that can only be run as a root
# database user. These are not needed actually, so comment them
# out automatically
#
# CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
# COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
#
namespace :db do
# Download all repos for an organization
ORG_NAME=trumaker
curl -s https://api.github.com/orgs/$ORG_NAME/repos?per_page=200 | ruby -rubygems -e 'require "json"; JSON.load(STDIN.read).each { |repo| %x[git clone #{repo["ssh_url"]} ]}'
# Download all repos for a user
USER_NAME=pboling
curl -s https://api.github.com/users/$USER_NAME/repos?per_page=200 | ruby -rubygems -e 'require "json"; JSON.load(STDIN.read).each { |repo| %x[git clone #{repo["ssh_url"]} ]}'
@pboling
pboling / api_logger.rb
Last active August 29, 2015 14:13 — forked from dblock/api_logger.rb
require 'ext/grape_middleware_logger'
module TrumakerAPI
module Middleware
class ApiLogger < Grape::Middleware::Logger
def after
logger.info "[api] Requested#{request_log}" if !request_log.blank?
if Rails.env.development?
response_body = JSON.parse(response.body.first)