Skip to content

Instantly share code, notes, and snippets.

View appositum's full-sized avatar
💭
🐝

ezra ramon appositum

💭
🐝
View GitHub Profile
<!doctype html>
<!-- This is just a very slightly modified tracking.js demo: https://trackingjs.com/examples/face_camera.html -->
<html>
<head>
<meta charset="utf-8">
<script src="https://cdnjs.cloudflare.com/ajax/libs/tracking.js/1.1.3/tracking-min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tracking.js/1.1.3/data/face-min.js"></script>
<style>
video, canvas {
margin-left: 100px;
@anabastos
anabastos / lambdazinhs.js
Last active April 1, 2024 23:48
meus churchezinhos
/*
ChUrChEsZiNhUs
baseado na palestra : https://www.youtube.com/watch?v=VpzhH9CXOy0
*/
const ID = x => x
const TRUE = x => y => x
TRUE("0")("1") // 0
@VictorTaelin
VictorTaelin / promises.md
Last active April 23, 2022 15:18
promises de novo

(edit: clique aqui para um fork desse texto melhor editado, feito pelo Kewerson Hugo; não vou mexer no original pq deu resultado, e eu gostaria de observar se isso pode ser parcialmente atribuido ao seu estilo)

o pq de funcões assíncronas

funcoes de javascript quase sempre são assincronas. isso acontece porque js lida muito com coisas como http requests, leitura de disco... operacoes que levam muito tempo. imagina se seu programa travasse toda vez que vc fizesse um request http? pra evitar isso, o request é feito em background, o programa continua rodando, e depois o resultado é enviado pra vc num callback

request("www.google.com", function callback(resultado) { ... })
@VictorTaelin
VictorTaelin / promise_monad.md
Last active May 10, 2024 04:22
async/await is just the do-notation of the Promise monad

async/await is just the do-notation of the Promise monad

CertSimple just wrote a blog post arguing ES2017's async/await was the best thing to happen with JavaScript. I wholeheartedly agree.

In short, one of the (few?) good things about JavaScript used to be how well it handled asynchronous requests. This was mostly thanks to its Scheme-inherited implementation of functions and closures. That, though, was also one of its worst faults, because it led to the "callback hell", an seemingly unavoidable pattern that made highly asynchronous JS code almost unreadable. Many solutions attempted to solve that, but most failed. Promises almost did it, but failed too. Finally, async/await is here and, combined with Promises, it solves the problem for good. On this post, I'll explain why that is the case and trace a link between promises, async/await, the do-notation and monads.

First, let's illustrate the 3 styles by implementing

@robotlolita
robotlolita / oop.md
Last active May 24, 2023 21:23
O que é OOP? Por que Java não deve ser considerado uma linguagem com um bom suporte para esse paradigma?

Objeto é a noção de uma entidade que é definida inteiramente pelo seu comportamento. E esse comportamento é dinâmicamente selecionado. Em outras palavras, eu "peço" um objeto para "andar," e como ele vai fazer isso é inteiramente definido pelo objeto.

O exemplo:

objeto.anda()

Captura bem essa idéia. Eu tenho uma mensagem "anda," mas eu não consigo dizer o que essa função faz direto do meu código, porque isso depende no comportamento dinâmico da execução do programa (em uma linguagem estáticamente tipada você consegue optimizar isso, mas o raciocínio do código continua o mesmo).

@branneman
branneman / better-nodejs-require-paths.md
Last active June 29, 2024 16:00
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions