This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
de: | |
activemodel: | |
errors: | |
messages: | |
distinctness: "müssen unterschiedlich sein" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# config/initializers/i18n_translate_with_references.rb | |
# | |
module I18n | |
class << self | |
alias_method :original_translate, :translate | |
def translate(*args) | |
regexp = /\A~>(.*)\Z/ # e.g. ~> some.other.key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module InheritedHandler | |
def inherited(subclass) | |
subclass.instance_eval do | |
alias :original_new :new | |
def self.inherited(subsubclass) | |
subsubclass.extend(InheritedHandler) | |
end | |
def self.new(*args, &block) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ApplicationHelper | |
# https://coderwall.com/p/ftbmsa (Render template if exists in Rails) | |
def try_to_render(partial_path, options = {}) | |
fallback = options.delete(:fallback_to) | |
prefixes = partial_path.split("/")[0..-2].presence || controller._prefixes | |
partial_name = partial_path.split("/").last | |
if lookup_context.exists?(partial_name, prefixes, true) # "true" is crucial ! | |
render partial_path, options | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# e.g. inside app/views/records/show.html.erb use | |
# | |
# <%= render_relative "./record/title" %> | |
# | |
# to render app/views/records/show/record/title | |
module App::ApplicationHelper | |
def render_relative(relative_partial_path, locals = {}, &block) | |
calling_file_directory = @virtual_path.split("/")[0..-2].join("/") | |
partial_path = File.join(calling_file_directory, relative_partial_path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding: utf-8 -*- | |
require File.expand_path('../lib/example/version', __FILE__) | |
Gem::Specification.new do |gem| | |
gem.authors = ["John Doe"] | |
gem.email = ["john_doe@example.org"] | |
gem.description = %q{Write a gem description} | |
gem.summary = %q{Write a gem summary} | |
gem.homepage = "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# assets/javascript/Component.js.coffee | |
define -> | |
class | |
methodEverybodyShouldHave: -> | |
# ... | |
# assets/javascript/SeatPlan/InputDataSanitizer.js.coffee | |
define -> | |
class | |
sanitize: (data) -> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The idea is, to have models adhere to a convention, which stats, that there has to be a field "searchable_tokens", | |
which includes searchable tokens. Now, we can simply have a (virtual) model/table `search_results`, which can be | |
unioned with "casted selects" of each model we want to search. The casted selects make the columns of each model to fit | |
into the schema of the search result. | |
Mixed with ActiveRecord's polymorphic associations, the result is an ActiveRecord relation with elements, which points to | |
their respective subject. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo mkdir /etc/systemd/system/docker.service.d | |
sudo bash -c 'cat <<EOF > /etc/systemd/system/docker.service.d/overlay.conf | |
[Service] | |
ExecStart= | |
ExecStart=/usr/bin/docker daemon -H fd:// --storage-driver=overlay | |
EOF' | |
sudo systemctl daemon-reload | |
sudo systemctl restart docker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "ffi" | |
module MRI | |
extend FFI::Library | |
ffi_lib [FFI::CURRENT_PROCESS, "ruby"] | |
attach_function :rb_str_resize, :rb_str_resize, [:pointer, :long], :pointer | |
def self.sizeof(type) | |
Class.new(FFI::Struct) do |
OlderNewer