Skip to content

Instantly share code, notes, and snippets.

View jesjos's full-sized avatar

Jesper Josefsson jesjos

  • Mariehamn, Åland
View GitHub Profile

Keybase proof

I hereby claim:

  • I am jesjos on github.
  • I am jesjos (https://keybase.io/jesjos) on keybase.
  • I have a public key ASAii6tKy6Vb4PJ_YqEXWhytOiLWTWi_jO_Dh3mNM84WRQo

To claim this, I am signing this object:

Traits of a desired configuration management system

  1. Supports different named environments, e.g “some-customer-production”, “other-customer-test”
  2. Environments should be able the include properties from other environments. E.g. test environments for all customers could include properties shared among all test environments.
  3. All properties can be overridden using environment variables.
  4. Properties can be set using files.
  5. Properties can be inspected. A CLI utility prints the complete configuration for an environment. Bonus: a web interface as well.
  6. The source of a property can be inspected. E.g. the CLI utility prints “KEY=VALUE (some-file.yml)” or “OTHER-KEY=OTHERVALUE (ENV)”
  7. Configuration can be changed at runtime. Apps may still choose to only read the property at startup, but the CMS supports live updates.
  8. Configuration can be wrapped and shipped as a module to be shared between apps
  9. Configuration can be read from CLI scripts, e.g. bash
asrtarst
/opt/jruby/lib/ruby/stdlib/jar_dependencies.rb:207: warning: shadowing outer local variable - group_id
/opt/jruby/lib/ruby/stdlib/jar_dependencies.rb:207: warning: shadowing outer local variable - artifact_id
Using Ext extension for JSON.
/usr/local/bundle/gems/devise-4.0.0/lib/devise.rb:446: warning: (...) interpreted as grouped expression
Exception `NameError' at /usr/local/bundle/gems/activesupport-5.0.0.beta3/lib/active_support/dependencies.rb:569 - uninitialized constant DataMapper
Exception `NameError' at /usr/local/bundle/gems/activesupport-5.0.0.beta3/lib/active_support/dependencies.rb:569 - uninitialized constant Mongoid
Exception `NameError' at /usr/local/bundle/gems/activesupport-5.0.0.beta3/lib/active_support/dependencies.rb:569 - uninitialized constant MongoMapper
/usr/local/bundle/bundler/gems/activerecord-jdbc-adapter-adbbbff1f1a1/lib/arjdbc/jdbc/adapter.rb:754: warning: `*' interpreted as argument prefix
Exception `NameError' at /usr/local/bundle/gems/activesupport-5.0.0.beta3/lib/active_suppo
jruby-9.0.1.0 :001 > [].max_by(:foo)
Java::JavaLang::ClassCastException: org.jruby.RubyEnumerator cannot be cast to org.jruby.RubyArray
from org.jruby.RubyEnumerable.max_by(RubyEnumerable.java:1205)
from org.jruby.RubyEnumerable$INVOKER$s$max_by.call(RubyEnumerable$INVOKER$s$max_by.gen)
from org.jruby.internal.runtime.methods.JavaMethod$JavaMethodZeroOrOneOrNBlock.call(JavaMethod.java:324)
from org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:313)
from org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:163)
from org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:289)
from org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:77)
from org.jruby.ir.interpreter.Interpreter.INTERPRET_EVAL(Interpreter.java:126)
require 'minitest/autorun'
describe 'File.expand_path under windows' do
describe 'when given a path using backslashes' do
before { @unc_path = '\\Machine\Share\resource' }
it 'expands to the correct path when given a UNC network path and a relative path' do
File.expand_path('..', @unc_path).must_equal('//Machine/Share')
end
@jesjos
jesjos / class_vars.rb
Created February 20, 2015 09:38
Class variables
class Foo
@@klass = "class level variable"
@klass_instance = "class instance level variable"
end
class Bar < Foo
end
puts Foo.instance_variables.inspect # => [:@klass_instance]
@jesjos
jesjos / proposal.rb
Last active August 29, 2015 14:13
Proposal for Sandthorn 2.0
# = Example Sandthorn setup
Sandthorn.config do |sand|
sand.snapshot_store = SnapshotStore.new
sand.event_stores = {
default: SequelStore.new(url: "sqlite://my_db", snapshot_store: sand.snapshot_store)
alternative: MongoStore.new(url: "some_url", snapshot_store: sand.snapshot_store)
aux: InMemoryStore.new
}
# This maps aggregates to event stores.
@jesjos
jesjos / korppi.txt
Last active August 29, 2015 13:56
Oranssi Pazuzu - Korppi (lyrics, incomplete)
Häkki aukeaa ja korppi lentää vapauteen // Buren öppnas och korpen flyger ut i frihet
Siiveniskut kietoo savuun ja kylmyteen // Vingens slag kläs i rök och kyla
Olen ikuisesti sinun (…) // Jag är evigt din (…)
Nyt askel unohduksen rotkoon // Nu, ett steg ut i glömskans ravin
Kylmetä minut kuolemattomaksi // Kyl ner mig till odödliget
Tee minusta palveliasi uskollinen // gör mig till din trogne tjänare
Verens osuessa maahaan lintu katselee // När blodet slår i marken, betraktar korpen
Minä saan kaiken mitä unissa luvattiin // Jag får allt som lovades i drömmarna
# config/routes.rb
namespace :admin do
resources :boats
resources :stuff
end
# app/controllers/admin_controller.rb
# This controller just refactors all shared logic for admin-namespaced controllers
class AdminController < ApplicationController
# If multiple models: