Skip to content

Instantly share code, notes, and snippets.


Alessandro Fazzi alessandro-fazzi

View GitHub Profile
alessandro-fazzi / .ruby-version
Last active December 12, 2022 22:12
[Study] An alternative approach managing LightService hooks
alessandro-fazzi / main.rb
Created November 23, 2022 15:31
avo-qh/class_variants without the gem
View main.rb
ButtonClasses =, :variants, :defaults, keyword_init: true) do |klass|
def render(**settings)
result = []
# Add the default classes if any provided
result << classes if classes
# Keep the applied variants so we can later apply the defaults
applied_options = []
View closures_in_ruby.rb
# CLOSURES IN RUBY Paul Cantrell
# Email: username "paul", domain name ""
# I recommend executing this file, then reading it alongside its output.
# Alteratively, you can give yourself an unreasonable Ruby test by deleting all
# the comments, then trying to guess the output of the code!
# (Naive HR departments, please do not use that idea as a hiring quiz.)
alessandro-fazzi / Gemfile
Created July 28, 2021 17:46
LightService Organizer with dependency injection
View Gemfile
source ''
gem 'light-service'
gem 'dry-auto_inject'
gem 'pry-byebug'
alessandro-fazzi / cloudSettings
Last active July 25, 2019 09:18
Visual Studio Code Settings Sync Gist
View cloudSettings
alessandro-fazzi / cloudSettings
Last active February 6, 2019 10:52
Visual Studio Code Settings Sync Gist
View cloudSettings
alessandro-fazzi / ping_pong.ex
Created October 27, 2017 16:58
Elixir excercise ping pong server
View ping_pong.ex
defmodule Match do
def start(max_iterations) when is_integer(max_iterations) and max_iterations > 0 do
spawn(__MODULE__, :init, [max_iterations])
def init(max_iterations) do
match = self()
player2 = spawn(Player, :start, [:pong, match])
player1 = spawn(Player, :start, [:ping, match])
View mysql-collation-fixer.php
* @package MySQL_Collation_Fixer
* @version 1.6
Plugin Name: MySQL Collation fixer
Description: Change database tables collation to utf8_general__ci after DB upgrade
Version: 1.0
Author: Federico Parodi - weLaika
alessandro-fazzi / home.html.haml
Last active August 29, 2015 14:09
Wordless router ready for ajax partial rendering
View home.html.haml
.page-item#ascolta= render_partial('music/home')
jQuery.get('/', {ajax: 'video/home'}, function(data, textStatus, xhr) {
alessandro-fazzi / osdetect.php
Created January 31, 2014 11:25
Operative system detect PHP
View osdetect.php
$user_agent = getenv("HTTP_USER_AGENT");
if (strpos($user_agent, "Win") !== FALSE)
$os = "Windows";
else (strpos($user_agent, "Mac") !== FALSE)
$os = "Mac"