Skip to content

Instantly share code, notes, and snippets.

@noghartt
noghartt / fix_zsh_corrupt_file.sh
Created July 14, 2020 21:21
A mini script to fix .zsh_history corrupt file
#!/usr/bin/env zsh
mv ~/.zsh_history ~/.zsh_history_bad
strings ~/.zsh_history_bad > ~/.zsh_history
fc -R ~/.zsh_history
rm ~/.zsh_history_bad
@noghartt
noghartt / post.md
Created January 27, 2021 00:11 — forked from vinicius73/post.md
["LÓGICA DE PROGRAMAÇÃO" É BOBAGEM, e explicarei porquê.]

#["LÓGICA DE PROGRAMAÇÃO" É BOBAGEM, e explicarei porquê.]

Se preparem que o texto é longo.

Várias vezes chegam novatos aqui perguntando como começar, e a galera diz "estuda lógica primeiro, depois vai pra linguagem X". Vivo dizendo que é bobagem. Ontem, em particular, falei isso, e vieram várias pessoas por inbox me perguntar porquê (e uma pra me xingar, achando que falei por arrogância).

Pra facilitar, eu vou escrever uma boa explicação de porquê "lógica de programação" é furada, doa a quem doer, e postar na APDA e no fórum da EnergyLabs (para futuras referências, porque esse assunto vai voltar, ctz).

@noghartt
noghartt / church_numerals.js
Created September 30, 2021 03:11
Church Numerals with JavaScript
const TRUE = x => y => x;
const FALSE = x => y => y;
const zero = f => x => x;
const succ = n => f => x => f(n(f)(x));
const plus = m => n => f => x => m(f)(n(f)(x));
const mult = m => n => f => x => m(n(f))(x);
const exp = m => n => n(m);
const pred = n => f => x => n(g => h => h(g(f)))(u => x)(u => u);
@noghartt
noghartt / table.tsx
Created August 5, 2022 15:23
@tanstack/table + @tanstack/virtual@beta + @mui/material v5 | A table with infinite scrolling and virtualized rows
import Paper from '@mui/material/Paper';
import Table from '@mui/material/Table';
import TableBody from '@mui/material/TableBody';
import TableCell from '@mui/material/TableCell';
import TableContainer from '@mui/material/TableContainer';
import TableHead from '@mui/material/TableHead';
import TableRow from '@mui/material/TableRow';
import {
useReactTable,
getCoreRowModel,
@noghartt
noghartt / ts-compiler.ts
Created March 1, 2023 03:02
Some example using TypeScript compiler API
import ts from 'typescript';
import { readFile, writeFile } from 'fs/promises';
const sourceText = await readFile('./input.ts', { encoding: 'utf8' });
const source = ts.createSourceFile('input.ts', sourceText, ts.ScriptTarget.Latest);
const newArticle = ts.factory.createObjectLiteralExpression(
[
ts.factory.createPropertyAssignment(

Books

Links

  • Build your own X, a repo containing a lot of projects teaching how to build cool things, from a database from scratch, 3D stuffs and other cool features
  • tpetricek/Teaching a repo containing study material to things like PL

In this tutorial we're going to build a set of parser combinators.

What is a parser combinator?

We'll answer the above question in 2 steps.

  1. What is a parser?
  2. and, what is a parser combinator?

So first question: What is parser?

@noghartt
noghartt / fetchVersion.js
Created January 5, 2024 17:44
fetchQuery relay toPromise
import { fetchQuery, graphql } from 'relay-runtine';
export const fetchVersion = async (environment) => {
const response = fetchQuery(
environment,
graphql`
query fetchVersionQuery {
version
}
`,
@noghartt
noghartt / cc.md
Last active May 5, 2024 21:28
Resources to learn more about Computer Science and related stuffs