Skip to content

Instantly share code, notes, and snippets.

View phoet's full-sized avatar
:shipit:
Shippin Stuffs 🚀

Peter Schröder phoet

:shipit:
Shippin Stuffs 🚀
View GitHub Profile
@phoet
phoet / renderer.rb
Last active June 19, 2023 08:59
helps finding which partial to look at in rails4
if Rails.env.development?
module My
module PartialRenderer
def render(context, options, block)
msg = "rendering '#{options[:partial]}' with locals '#{(options[:locals] || {}).keys}'"
"<!-- start #{msg}-->\n#{super(context, options, block)}\n<!-- end #{msg}-->\n".html_safe
end
end
end
@phoet
phoet / gist:6021600
Created July 17, 2013 15:23
deutsche blacklist
[
"schiss",
"schiß",
"schlamm",
"schlampe",
"schleim",
"schließm",
"schlitz",
"schlong",
"schluck",
@phoet
phoet / example.rb
Last active November 18, 2020 12:31
translate bug
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler is required. Please update your Bundler"
raise e
end
gemfile(true) do
source "https://rubygems.org"
gem "rails", "~> 6.0.3"
@phoet
phoet / bundler_inline_on_heroku.rb
Last active July 3, 2020 13:04
run a script with bundler/inline on heroku
# heroku expects all gems to be vendored.
# bundler/inline has some quirks that don't play nice with it
# so the best alternative is to just do a fresh install every time, dyno time is cheap!
require 'bundler'
require 'bundler/inline'
if ENV['DYNO']
# on heroku, we don't care about their bundler config!
# alternatively, you could `rm -rf /app/.bundle` the bundler config before loading it
@phoet
phoet / example.rb
Last active July 29, 2019 14:58
group by with first
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler is required. Please update your Bundler"
raise e
end
gemfile(true) do
source "https://rubygems.org"
gem "rails", '6.0.0.rc2'
@phoet
phoet / iota.rb
Last active February 28, 2019 09:47
IOTA for ruby
# inspired by https://github.com/golang/go/wiki/Iota
module IOTA
class Counter
def initialize(start, increment, max)
@start = start
@times = 0
@increment = increment
@max = max
end
@phoet
phoet / example.rb
Created February 4, 2019 11:18
distinct and include
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"
gem "rails", '6.0.0.beta1'
@phoet
phoet / retry.gemspec
Last active October 18, 2018 07:37
Generic Retry Helper
Gem::Specification.new do |s|
s.name = 'retry'
s.version = '0.0.1'
s.platform = Gem::Platform::RUBY
s.author = 'Peter Schröder'
s.email = 'phoetmail@googlemail.com'
s.license = 'MIT'
s.homepage = 'https://gist.github.com/phoet/92767354f7d78a9f8e2985bc29df88c4'
s.description = s.summary = 'retry helper as a gist'
@phoet
phoet / keybase.md
Last active January 23, 2017 20:34
keybase proof

Keybase proof

I hereby claim:

  • I am phoet on github.
  • I am phoet (https://keybase.io/phoet) on keybase.
  • I have a public key whose fingerprint is 7B53 845B DBA6 25B2 FE4F FA16 09FA 59FF FDB3 84F6

To claim this, I am signing this object:

@phoet
phoet / temp_env.rb
Created December 16, 2016 15:52
Helper to have temporary environment variables (ENV), ie for testing.
# In order to make testing of environment variables easier,
# you can use this helper to temporarily change the ENV to something you expect.
#
# As an example:
#
# Imagine you have some ENV variable that changes based on the current runtime environment.
#
# def user_id
# ENV['TEST_USER_ID'].present? ? ENV['TEST_USER_ID'] : session[:user_id]
# end