Skip to content

Instantly share code, notes, and snippets.

:shipit:
Shippin Stuffs 🚀

Peter Schröder phoet

View GitHub Profile
@phoet
phoet / iota.rb
Last active Feb 28, 2019
IOTA for ruby
View iota.rb
# 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 Feb 4, 2019
distinct and include
View example.rb
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 Oct 18, 2018
Generic Retry Helper
View retry.gemspec
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 / bundler_inline_on_heroku.rb
Last active Mar 22, 2017
run a script with bundler/inline on heroku
View bundler_inline_on_heroku.rb
# 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 / keybase.md
Last active Jan 23, 2017
keybase proof
View keybase.md

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 Dec 16, 2016
Helper to have temporary environment variables (ENV), ie for testing.
View temp_env.rb
# 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
@phoet
phoet / README.md
Last active Oct 16, 2016
OSX Noop Keyboard Layout
View README.md

NOOP Keyboard-Layout

Edit with Ukulele like described here.

Needs restart!

@phoet
phoet / artifacts.py
Created Jan 19, 2016 — forked from mat/artifacts.py
Pillow PNG artifacts
View artifacts.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
# This script reproduces the issue with artifacts when
# handling (semi)transparent PNG files:
# https://github.com/python-pillow/Pillow/issues/1449
# Version used:
#
@phoet
phoet / default_start_line.php
Created Mar 18, 2015
single best line of PHP evar
View default_start_line.php
<? goto 💩; die "PHP, die you piece of 💩!"; 💩:
@phoet
phoet / heroku.rake
Created Feb 26, 2015
heroku GC settings generator for rails
View heroku.rake
namespace :heroku do
desc "generate GC settings"
task gc: [:environment] do
# https://discussion.heroku.com/t/tuning-rgengc-2-1-on-heroku/359/6
# http://tmm1.net/ruby21-rgengc/
# http://thorstenball.com/blog/2014/03/12/watching-understanding-ruby-2.1-garbage-collector/
# http://collectiveidea.com/blog/archives/2015/02/19/optimizing-rails-for-memory-usage-part-1-before-you-optimize/
settings = {
RUBY_GC_HEAP_FREE_SLOTS: 600000, # default is 4096,
RUBY_GC_HEAP_GROWTH_FACTOR: 1.25, # default is 1.8,
You can’t perform that action at this time.