Skip to content

Instantly share code, notes, and snippets.

@aschiavon91
aschiavon91 / gist:57fdb04df85b8a0dc0dd32c24790c3bb
Created April 5, 2017 18:42
Android AVD Emulator fix for Ubuntu 16.04
#First, install or update libstdc++
apt-get install lib64stdc++6
# Second, enter in lbstdc++ folder stored in Android SDK folder
# something like "/home/user/Android/sdk/emulator/lib64/libstdc++"
cd $HOME/Android/Sdk/emulator/lib64/libstdc++
# Now, backup old files
mv libstdc++.so.6 libstdc++.so.6.bak
mv libstdc++.so.6.x.x libstdc++.so.6.x.x.bak
# Find all soundcards id
$ cat /proc/asound/cards
WILL OUTPUT SOMETHING LIKE:
0 [HDMI ]: HDA-Intel - HDA Intel HDMI
HDA Intel HDMI at 0xc1330000 irq 53
1 [PCH ]: HDA-Intel - HDA Intel PCH
HDA Intel PCH at 0xc1334000 irq 52
# In my case, my primary sound card is HDA Intel PCH which have the id number "1"
@aschiavon91
aschiavon91 / Ecto unload association
Last active June 16, 2025 12:30
[Elixir][Ecto][Phoenix] A simple way to unload preloaded association of an ecto record struct.
defmodule MyApp.Repo do
use Ecto.Repo,
otp_app: :my_app,
adapter: Ecto.Adapters.Postgres
def unload(_, _, cardinality \\ :one)
def unload(struct, fields, cardinality) when is_list(fields) do
Enum.reduce(fields, struct, fn field, struct_acc ->
unload(struct_acc, field, cardinality)
<img data-defer-src="">
(function () {
var Elp = Element.prototype;
var observer = new IntersectionObserver(function (entries, observer) {
entries.forEach(function (entry) {
if (!entry.target || entry.target.tagName.toUpperCase() !== 'IMG') {
return;
@aschiavon91
aschiavon91 / inlets.service
Last active March 30, 2020 02:59
inlets client service
[Unit]
Description=Inlets Client Service
After=network.target
[Service]
Type=simple
Restart=always
RestartSec=1
StartLimitInterval=0
EnvironmentFile=/etc/default/inlets
@aschiavon91
aschiavon91 / inlets.service
Last active March 29, 2020 21:25
inlets server service
[Unit]
Description=Inlets Server Service
After=network.target
[Service]
Type=simple
Restart=always
RestartSec=1
StartLimitInterval=0
EnvironmentFile=/etc/default/inlets
@aschiavon91
aschiavon91 / caddy.service
Last active March 29, 2020 21:41
Caddy service
[Unit]
Description=Caddy HTTP/2 web server
Documentation=https://caddyserver.com/docs
After=network-online.target
Wants=network-online.target
[Service]
Restart=on-failure
StartLimitInterval=86400
StartLimitBurst=5
@aschiavon91
aschiavon91 / script backup
Created May 7, 2020 02:49
mysql + web path bkp script with asset encoded using gpg
#!/bin/bash
readonly BKP_TIME_STAMP=$(date +"%Y-%m-%d")
readonly BKP_PATH_NAME=bkp-$BKP_TIME_STAMP
readonly RECIPIENT_MAIL="rm85297@fiap.com.br"
function check_mysql_config_file() {
if [[ ! -f ./.my.cnf ]]
then
echo "Arquivo configuração do mysql não existe"
document.addEventListener('DOMContentLoaded', () => document.querySelectorAll('.alert').forEach((alert) =>
alert.addEventListener('click', (_) => alert.style.display = "none")));
@aschiavon91
aschiavon91 / my_decoder.ex
Last active November 16, 2020 03:39
decode cloudflare protected email in Elixir
defmodule MyDecoder do
use Bitwise
def decode_email(encoded) do
r =
encoded
|> String.slice(0..1)
|> Integer.parse(16)
|> elem(0)
:lists.seq(2, String.length(encoded) - 2, 2)