Skip to content

Instantly share code, notes, and snippets.

View cpetschnig's full-sized avatar

Christoph Petschnig cpetschnig

  • powercloud GmbH
  • Leipzig, Germany
  • 05:07 (UTC +02:00)
View GitHub Profile

Keybase proof

I hereby claim:

  • I am cpetschnig on github.
  • I am cpetschnig (https://keybase.io/cpetschnig) on keybase.
  • I have a public key whose fingerprint is 9C87 90ED 6ACD 9EF8 DE5C 06D8 B28E 2784 2E6B F4AD

To claim this, I am signing this object:

@cpetschnig
cpetschnig / calender.rb
Created January 4, 2016 12:16
Creates a structure for your custom spreadsheet calender
# encoding: UTF-8
require 'active_support/all'
MONTHS = %w(Januar Februar März April Mai Juni Juli August September Oktober November Dezember)
DAYS = %w(So Mo Di Mi Do Fr Sa)
year = 2016
months = (1..12).map do |month|
@cpetschnig
cpetschnig / rack_api_logger.rb
Created February 25, 2015 09:41
Log more information about API request in your Rails application
# Put the following line into the config section in config/application.rb:
#
# config.middleware.use RackAPILogger
class RackAPILogger
def initialize(app)
@app = app
end
def call(env)
@cpetschnig
cpetschnig / gist:71d1323dda3276d55414
Created January 7, 2015 16:45
Configuration concept
module MyEngine
class Engine < ::Rails::Engine
# Autoload from the lib directory
config.autoload_paths << File.expand_path('../../', __FILE__)
config.my_engine = MyEngine::Configuration.new
# default configuration
config.my_engine.foo.class_for_bar = MyEngine::Bar
@cpetschnig
cpetschnig / gist:c2dfbc7a4890635bd362
Created December 16, 2014 08:00
Git tag operations
# fetch remote tags:
$ git fetch --tags origin
# list all remote tags:
$ git ls-remote --tags
# list all major version tags:
$ git ls-remote --tags | grep -oe "refs/tags[^\^]*" | uniq | grep -E "v2[0-9][0-9][0-9]-[0-9][0-9]$"
# delete all non-version tags:
@cpetschnig
cpetschnig / gist:3952049
Created October 25, 2012 11:15
Proposal for better structure of seeds in Rails engines
Engine
======
File structure:
EngineFoo
- app
- db
- seeds.rb
@cpetschnig
cpetschnig / gist:3069758
Created July 8, 2012 07:19
Ubuntu system requirements for Ruby
sudo apt-get install git curl build-essential bison openssl libreadline6 libreadline6-dev zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev libffi-dev tk-dev
require 'looksee'
Looksee.styles.each_key { |key| Looksee.styles[key] = "%s" }
@cpetschnig
cpetschnig / detailed_logger.rb
Created June 6, 2012 11:29
Show the source of your Rails log messages. Put this file in your config/initializers directory.
require 'active_support/buffered_logger'
class ActiveSupport::BufferedLogger
def add(severity, message = nil, progname = nil, &block)
add_debugging_details(severity)
@log.add(severity, message, progname, &block)
end
private
@cpetschnig
cpetschnig / i18n_lookup.rb
Created January 11, 2012 13:32
Log failed I18n lookups in Rails
class I18n::Backend::Simple
module Implementation
protected
def lookup(locale, key, scope = [], options = {})
init_translations unless initialized?
keys = I18n.normalize_keys(locale, key, scope, options[:separator])
keys.inject(translations) do |result, _key|