Skip to content

Instantly share code, notes, and snippets.

View pioz's full-sized avatar
🧙‍♂️
[object Object]

Enrico pioz

🧙‍♂️
[object Object]
View GitHub Profile
@pioz
pioz / apache_proxy_pass.conf
Last active September 18, 2020 23:52
Apache Proxy Pass sample config file
<VirtualHost *:80>
ServerName example.com
Redirect permanent / https://example.com/
ErrorLog /var/log/apache2/example-error.log
CustomLog /var/log/apache2/example-access.log combined
ServerSignature Off
</VirtualHost>
@pioz
pioz / convert_db_encoding_to_utf8mb4.sh
Created September 10, 2019 09:57
Convert database charset encoding to utf8mb4 and collation to utf8mb4_unicode_ci
#!/bin/bash
DB="italian_spiderman"
CHARSET="utf8mb4"
COLL="utf8mb4_unicode_ci"
echo $DB
echo "ALTER DATABASE \`$DB\` CHARACTER SET $CHARSET COLLATE $COLL;" | mysql
echo "USE \`$DB\`; SHOW TABLES;" | mysql -s | (
@pioz
pioz / engines.md
Created August 29, 2019 14:48
Using webpacker inside a Rails engine

Using in Rails engines

If the application UI consists of multiple frontend application, you'd probably like to isolate their building too (e.g. if you use different frameworks/versions). Hence we needed our webpack(-er) to be isolated too: separate package.json, dev server, compilation process.

You can do this by adding another Webpacker instance to your application.

This guide describes how to do that using Rails engines.

Step 1: create Rails engine.

@pioz
pioz / background_animated_gradient.css
Created August 9, 2019 13:37
Animate background gradient
background: linear-gradient(235deg, #ff8a00, #da1b60);
background-size: 400% 400%;
-webkit-animation: animateBackgroundGradient 20s ease infinite;
-moz-animation: animateBackgroundGradient 20s ease infinite;
animation: animateBackgroundGradient 20s ease infinite;
@-webkit-keyframes animateBackgroundGradient {
0%{background-position:0% 50%}
50%{background-position:100% 50%}
@pioz
pioz / gist:28668deb702b7a91fcb8fcff66e872b2
Created July 23, 2019 07:58
Delete Timemachine local snapshots
tmutil listlocalsnapshots /
sudo tmutil deletelocalsnapshots 2019-06-09-043259
@pioz
pioz / join_query_benchmark.rb
Last active November 19, 2019 10:52
Benchmark single join vs 2 with pluck
require 'active_record'
require 'activerecord-import'
require 'mysql2'
require 'benchmark'
ActiveRecord::Base.establish_connection(
adapter: 'mysql2',
host: 'localhost',
username: 'root',
database: 'joiner'
@pioz
pioz / 1000.md
Last active October 21, 2018 13:41
Ricetta Millesfoglie

Millesfoglie di Pioz

Ingredienti

  1. 4 rotoli di pasta sfoglia rotondi

  2. Zucchero a velo per spolverare le sfoglie

  3. Zucchero a velo per la copertura

  4. Bignè da farcire

  5. 6 tuorli d'uovo

@pioz
pioz / json-rpc.go
Last active January 11, 2022 16:54
Golang json-rpc sample
package main
import (
"errors"
"fmt"
"log"
"net"
"net/rpc"
"net/rpc/jsonrpc"
)
@pioz
pioz / install_elasticsearch_on_ubuntu.md
Created December 20, 2017 08:42
How to install Elasticsearch 6.x on Ubuntu

How to install Elasticsearch on Ubuntu

Install Java 8

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
@pioz
pioz / string_bench.rb
Last active November 24, 2017 21:22
Benchmark different way to concat strings in Ruby
require 'benchmark/ips'
puts "Ruby #{RUBY_VERSION} at #{Time.now}"
puts
firstname = 'soundarapandian'
middlename = 'rathinasamy'
lastname = 22
Benchmark.ips do |x|