Skip to content

Instantly share code, notes, and snippets.

View zavan's full-sized avatar
🏠
Working from home

Felipe Zavan zavan

🏠
Working from home
View GitHub Profile
@zavan
zavan / rails_backup.rb
Last active July 6, 2024 11:55
Poor man's Rails backup
#!/usr/bin/env ruby
require "bundler/inline"
require "logger"
gemfile do
source "https://rubygems.org"
gem "bcrypt_pbkdf"
gem "ed25519"
@zavan
zavan / victor_parse.rb
Last active July 6, 2024 11:57
victor
require 'json'
response = %Q(Local = belo horizonte
Clima atual = Parcialmente nublado 🌤️
Temperatura = +25°C
Umidade = 36%
Vento = ↙11km/h
Lua agora = 🌖
Nascer do sol = 06:31:42
Por do sol = 17:29:23)
@zavan
zavan / index.html
Last active June 4, 2024 18:04
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta content="width=device-width, initial-scale=1.0" name="viewport" />
<title>Test</title>
<meta property="og:site_name" content="Petra Mexican Bistro" />
<meta property="og:type" content="website" />
<meta property="og:url" content="https://www.petramexican.com/" />
dirs = [
"a1",
"a2",
"a3",
"b1",
"b2",
# missing b3
"b4",
"b5",
# missing all c
@zavan
zavan / thiago.rb
Created May 20, 2024 21:10
thiago
dirs = [
'a1',
'a2',
'a3',
'a4',
'b1',
'b2',
'b3',
# c missing
'd1',
@zavan
zavan / readline-pipeline.md
Created February 9, 2024 12:54
Using node Readline.createInterface in a pipeline

pipeline [accepts a function][1] which receives the source as an argument and expects it to return a promise or async iterator, and the Interface object returned by Readline.createInterface [can be used as an async iterator][2], so you can do this:

import { pipeline } from "node:stream";
import { createInterface } from "node:readline";

pipeline(
  process.stdin,
  (input) => createInterface({ input }),
  process.stdout,
@zavan
zavan / index.html
Last active February 27, 2023 10:17
Simple NPM + Vite + PostCSS
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Dummy eSite</title>
<!-- CSS Assets -->
<link rel="stylesheet" href="/src/styles.css">
@zavan
zavan / getGlobalLib.js
Last active November 19, 2022 17:13
Inject and use global script libs dynamically and idempotently (bonus: react custom hook)
const scripts = {};
const defaultOptions = {
async: true,
defer: true,
};
function getGlobalLib(name, url, options = defaultOptions) {
if (scripts[name]) return scripts[name];
@zavan
zavan / setup_mysql.yml
Last active February 3, 2022 14:06
Installing MySQL v5.7 on Ubuntu 20.04 with Ansible
- name: Setup MySQL v5.7
become: yes
block:
- name: Add MySQL apt key
apt_key:
keyserver: pgp.mit.edu
id: 3A79BD29
state: present
- name: Add MySQL apt repo
@zavan
zavan / yt.js
Last active September 9, 2024 14:48
Listening to the YouTube Embed Iframe time change events without polling player.getCurrentTime()
// Load the IFrame Player API code asynchronously.
var tag = document.createElement("script");
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName("script")[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
// Instantiate the Player.
function onYouTubeIframeAPIReady() {
var player = new YT.Player("player", {