Skip to content

Instantly share code, notes, and snippets.

View lubien's full-sized avatar
💭
Teaching people 🔥🦩 LiveView 🔥🦩

Lubien lubien

💭
Teaching people 🔥🦩 LiveView 🔥🦩
View GitHub Profile
function convertToRoman(inputNum) {
var letters = ['I', 'V', 'X', 'L', 'C', 'D', 'M'];
var digits = String(inputNum).split('').reverse();
var roman = [];
for (var i = 0, length = digits.length; i < length; i++) {
var value = Number(digits[i]);
var splitStart = i * 3 - i;
local AppendLists in
fun {AppendLists L1 L2}
local Aux in
fun {Aux List Acc}
case List of
Head|Tail then {Aux Tail (Head | Acc)}
else Acc
end
end
{Aux {Reverse L1} L2}
@lubien
lubien / pin.ex
Last active November 28, 2016 07:26
defmodule Pinner do
def first do
case 10 do
# `x` sempre dá match porque sendo ele
# uma variável, representa-se que qualquer
# valor arbitrário pode ser aceito no caso
x ->
"x"
10 ->
"10"
@lubien
lubien / stickers-downloader.js
Last active November 21, 2023 03:06
Download all visible telegram stickers images
// How to download telegram sticker images
/*
1. Go to Telegram Web;
2. Open console (F12);
3. Paste the code below in the console and press Enter;
4. Open your stickers menu and make sure you see the sticker pack you want to download (so Telegram will load it).
5. At the console paste and run "downloadStickers()" any time you want to download a pack.
6. [Convert .webm to another format](http://www.freewaregenius.com/convert-webp-image-format-jpg-png-format/);
7. Happy hacking.
@lubien
lubien / template.html
Created February 16, 2017 03:56
Promise races
<h1 id="page">No Page</h1>
<button data-page="Home" data-delay="1000">Home</button>
<button data-page="Users" data-delay="1500">Users</button>
<button data-page="Posts" data-delay="3000">Posts</button>
@lubien
lubien / promise-races-first.js
Created February 16, 2017 03:57
Promise races v1
const $page = document.getElementById('page')
const setPage = title => {
$page.innerText = title
}
const loadPage = (title, time) =>
new Promise(resolve =>
setTimeout(() => resolve(title), time)
)
@lubien
lubien / promise-races-second.js
Created February 16, 2017 03:59
Promise races
const $page = document.getElementById('page')
let currentPage = 'no-page'
const setPage = title => {
if (currentPage !== title) return;
$page.innerText = title
}
const loadPage = (title, time) =>
new Promise(resolve =>
@lubien
lubien / promise-races-third.js
Last active February 16, 2017 04:01
Promise races
const $page = document.getElementById('page')
let currentPage = 0
const setPage = title => {
$page.innerText = title
}
const loadPage = (title, time) =>
new Promise(resolve =>
setTimeout(() => resolve(title), time)
@lubien
lubien / promise-races-fourth.js
Last active February 16, 2017 13:31
Promise races
const $page = document.getElementById('page')
const router = {
listeners: [],
onPageChange(fn) {
this.listeners.push(fn)
}
}
@lubien
lubien / counter-one.js
Last active March 5, 2017 22:06
Teaching some FP to friends
var counter = 0
function count() {
return counter++
}