Skip to content

Instantly share code, notes, and snippets.

@evaporei
evaporei / .generate_cringe_key.sh
Created September 24, 2023 16:09
generate cringe key
#!/bin/bash
# pass name via $1
ssh-keygen -t rsa -b 4096 -f ~/.ssh/$1
@evaporei
evaporei / jack_grammar.txt
Created June 3, 2023 11:27
Jack grammar
--- program structure ---
// a Jack program is a collection of files, each should represent a class like the one below
class = "class" className '{' classVarDec* fnDec* '}' ;
classVarDec = ("static" | "field") type varName (',' varName)* ';' ;
fnDec = ("constructor" | "function" | "method") ("void" | type) fnName '(' paramList ')' fnBody ;
paramList = ( (type varName) (',' type varName)* )? ;
fnBody = '{' varDec* statements '}' ;
varDec = "var" type varName (',' type varName)* ';' ;
type = primitive | className ;
@evaporei
evaporei / artblocks_error.rs
Created January 20, 2022 18:49
ArtBlocks Error
// Cargo.toml dependencies:
// hex = "0.4.3"
// ethabi = "16.0.0"
use ethabi::*;
use ethabi::ParamType::*;
use ethabi::StateMutability::*;
fn main() {
@evaporei
evaporei / xor.rs
Created January 8, 2022 18:40
Xor in Rust cause HDL sucks
struct In {
a: bool,
b: bool,
}
#[derive(Debug, PartialEq)]
struct Out {
out: bool,
}
@evaporei
evaporei / boolean_algebra.js
Last active January 8, 2022 17:22
Boolean functions
const assert = require('assert')
function test(title, fn) {
try {
fn()
console.log(`✅ '${title}' test passed`)
} catch (error) {
console.error(`❌ '${title}' test failed`)
throw error
}
@evaporei
evaporei / contiguous-array-chunks.js
Last active October 11, 2021 14:23
JS contiguous array chunks
const getChunk = (arr, from, size) => {
const clampedFrom = (from + size) > arr.length
// Trying to get chunk bigger than end of array.
// Here we reduce `from` so that the chunk size is always preserved.
? arr.length - size
: from
return arr.slice(clampedFrom, from + size)
}
@evaporei
evaporei / linkedin-accept-invites.js
Created July 24, 2020 14:23
LinkedIn snippet for accepting all invites
document.querySelectorAll('ul.mn-invitation-list button.artdeco-button--secondary').forEach(btn => btn.click())
@evaporei
evaporei / ugly-typescript-monoid.ts
Last active September 13, 2019 19:07
Ugly TypeScript Monoid
class MyNumber extends Number implements Monoid<MyNumber> {
public x: Number;
constructor(x: Number) {
super(x)
this.x = x;
}
toString(): string {
return this.x.toString()
}
@evaporei
evaporei / group-by-without-ramda.js
Created May 28, 2019 23:16
Group by without Ramda
const data = [
{
category: 'action',
value: 'jorgs'
},
{
category: 'comedy',
value: 'lucians'
},
{

Aulas de JS

Tópicos a serem abordados

  • Tipos de variáveis, escopo e closures (var, let, const, escopos function e {})
  • Tipos e coerção (Boolean, null, undefined, Number, String, Object, Symbol e tabela de coerção)
  • this, prototypes e classes
  • Assincronia (event loop, setTimeout, setInterval, setImmediate, process.nextTick, Promise, function*, coroutines e async await)