Skip to content

Instantly share code, notes, and snippets.

View bcaccinolo's full-sized avatar

Benoit Caccinolo bcaccinolo

View GitHub Profile
bcaccinolo / i18n_lookup.rb
Created December 22, 2014 08:08
Rails i18n_lookup
# config/initializers/i18n_lookup.rb
class I18n::Backend::Simple
module Implementation
def lookup(locale, key, scope = [], options = {})
init_translations unless initialized?
keys = I18n.normalize_keys(locale, key, scope, options[:separator])
<type>(<scope>): <subject>
# <type>
# - feat: A new feature
# - fix: A bug fix
bcaccinolo / convert-line.clj
Created December 10, 2020 16:17
My first babashka/clojure script
(def argument (first *command-line-args*))
(->> argument
(#(str/split % #", "))
(map #(str "\"" % "\""))
(str/join ", ")
bcaccinolo /
Last active October 11, 2019 09:42
Yardoc template


Documentation examples

You likely won't use all the available tags (words starting with an @) shown in the bellow examples. These examples are more of a cheat sheet of what you can do and where you can use them.


body = window.document.getElementsByTagName('body')[0];
body.addEventListener('mouseenter', function(ev) {
if( !== 'TD') {
} = "bouya";
}, true);
bcaccinolo /
Created September 14, 2018 07:29 — forked from chetan/
YARD cheatsheet


cribbed from

Templates to remind you of the options and formatting for the different types of objects you might want to document using YARD.


Namespace for classes and modules that handle serving documentation over HTTP

bcaccinolo /
Created September 3, 2018 12:36 — forked from hofmannsven/
My simply MySQL Command Line Cheatsheet
bcaccinolo / gist:51a2ef0d8abc8532b56c23c0c4f5e59c
Created July 26, 2018 10:03 — forked from vsizov/gist:4500870
Automatically reload gems in rails 5 on every request in development
# Source:
# Inside config/environments/development.rb
# Do the following after every request to the server in development mode
ActionDispatch::Callbacks.to_cleanup do
# If the gem's top level module is currently loaded, unload it
if Object.const_defined?(:MyCoolGem)
bcaccinolo /
Created July 26, 2018 08:49 — forked from maxivak/
Load code in libraries in Rails 5

Load lib files in production (Rails 5)

If you have your code defined in classes in lib/ folder you may have problems to load that code in production.

Autoloading is disabled in the production environment by default because of thread safety.

Change config/application.rb:

    config.autoload_paths << Rails.root.join("lib")
 config.eager_load_paths &lt;&lt; Rails.root.join("lib")
bcaccinolo / log.php
Last active February 19, 2018 12:14
log prestashop
if (!function_exists('monolog')) {
function monolog($var) {
$log = (new \Monolog\Logger('name'))->pushHandler(new \Monolog\Handler\ErrorLogHandler());
$log->addInfo("Running controller");
if (!function_exists('filelog')) {