Skip to content

Instantly share code, notes, and snippets.


Elia Schito elia

View GitHub Profile
elia /
Created Jan 18, 2022 — forked from ctborg/
Enable Airprint for any printer on MacOs (BigSur)
  1. Connect printer, install printer drivers, and enable Printer Sharing.
  2. Open terminal, run: dns-sd -Z _ipp._tcp. You'll see a few lines of repeated text. Look for your printer's name, next to that record you will see a TXT, copy everything after TXT into a notepad.
  3. In that TXT line, you'll see a line like this: "pdl=application/octet-stream,application/pdf,application/postscript,image/jpeg,image/png,image/pwg-raster" Change that, to add ,image/urf. So it'll look like: "pdl=application/octet-stream,application/pdf,application/postscript,image/jpeg,image/png,image/pwg-raster,image/urf"
  4. Now take that entire TXT line, and add it to this: dns-sd -R "name_to_be advertised" _ipp._tcp.,_universal . 631 URF=none pdl=application/pdf,image/urf YOUR_TXT_STRING
  5. Run that line in the terminal, and Airprint should be enabled.
elia /
Last active Mar 29, 2021
Upgrading FactoryBot on Solidus 2.11+

Updating the factories configuration


The way Solidus was loading FactoryBot factories up until v2.11 was a hack that worked against Rails reloading and made them substantially incompatible with Spring and other tools, in addition to being at odds with the installation instruction that could be found in the FactoryBot and FactoryBotRails respective READMEs.

What's wrong with the previous setup?

View .diff
diff --git a/app/backend/beestore/client.rb b/app/backend/beestore/client.rb
index 2e7c8f67d..aa9ccb708 100644
--- a/app/backend/beestore/client.rb
+++ b/app/backend/beestore/client.rb
@@ -380,7 +380,9 @@ module Beestore
# Use this in case you need to restore stocks.
# New 22 Jun 2016.
# Used in VariantAvailabilityRestore (worker, multistock) and Quantifier (multistock in single stock location)
- # stock_locations is an array of stock locations instances.
+ #
elia /
Created Apr 11, 2017
Opal: constants system rewrite (in two parts) #1653

from: opal/opal#1653


commit 447e1b4cb313de4bd416f1184b27fcee8cd5edd8
Author: Elia Schito <>
Date:   Wed Apr 12 00:00:35 2017 +0200
    Establish a constant lookup IPS benchmark
elia / init_conf.rb
Last active Feb 21, 2017
opal -I. main.rb
View init_conf.rb
module InitConf
# how to add a new parameter
# 1. set the default here
# 2. maintain neatjson options to get it sorted here as well
# 3. update controller_command_defnitions to provide the add / edit commands
# 4. update conf_doc_source.rb to provide the documentation and help
# 5. update config-form.rb to attach a type
# 6. update user-interface.js to add the menu entries
def self.init_conf()
result =
View Gemfile
source ''
gem "opal"
View simple_server.rb
require 'opal/deprecations'
# Opal::SimpleServer is a very basic Rack server for Opal assets, it relies on
# Opal::Builder and Ruby corelib/stdlib. It's meant to be used just for local
# development.
# For a more complete implementation see opal-sprockets (Rubygems) or
# opal-webpack (NPM).
# @example (CLI)
View assets-initializer.rb
# Remove when is resolved
unless Rails.env.development?
module SprocketsCachedLoader
def initialize(*)
@expanded_assets_cache = {}
def asset_from_cache(key)
return @expanded_assets_cache[key] if @expanded_assets_cache.key?(key)
View read_proc.rb
class IO
def read
if @eof
`res = self.read_proc(@path)`
@eof = true
@lineno = res.size
elia / tail_logentries.rb
Created Dec 17, 2015
Connect to a Logentries log set and tail logs to the terminal
View tail_logentries.rb
warn "Usage: #{$0} ACCOUNT_KEY LOG_SET LOG_NAME" if ARGV.size != 3
account_key = ARGV[0]
log_set = ARGV[1]
log_name = ARGV[2]
msec = -> t { (t.to_f * 1000).to_i }
now =
require 'thread'