Skip to content

Instantly share code, notes, and snippets.

View Grohden's full-sized avatar
:shipit:
*tec tec tec noises*

Gabriel Rohden Grohden

:shipit:
*tec tec tec noises*
View GitHub Profile
@Grohden
Grohden / index.ts
Last active January 21, 2024 00:16
My "port" fo the Vibrant lib for react native
import VibrantCore from '@vibrant/core';
import { pipeline } from './pipeline.ts';
import { ReactNativeImage } from './react-native-image.ts';
export const Vibrant = VibrantCore;
// Don't forget to add this to your app root:
// useEffect(() => {
@Grohden
Grohden / format-to-atex.js
Last active March 25, 2023 18:45
Transform a tab (?) format into an AlphaTex (for AlphaTab)
// this heavily uses ramda
// this was done quickly to just make it work, its variale names essentialy do not have correct names
// this does not generate duration information
// you can just past it in ramda and it will run
// https://ramdajs.com/repl
// take the result and feed it into the alphaTab
module Prelude
class Functor
def initialize(value)
@value = value
end
# All implementers must satisfy
# (a -> b) -> f a -> f b
def fmap
self.class.new(yield @value)
@Grohden
Grohden / lookahead.md
Created June 23, 2022 20:43
GQL ruby gem lookahead extra

The [lookahead][1] feature is exposed through an [extra][2]:

field :organizations, [Organization], extras: [:lookahead]

By declaring the lookahead extra we can use it to know which fields the client is asking for (through selects?):

def organizations(lookahead:)
@Grohden
Grohden / main.dart
Last active June 3, 2022 18:21
Dart currying
void main() {
final sum2 = curry2((int a, int b) => a + b);
final sum3 = curry3((int a, int b, int c) => a + b + c);
print(sum2(1));
print(sum2(1)(2));
print(sum3(1));
print(sum3(1)(2));
print(sum3(1)(2)(3));
@Grohden
Grohden / cuchi_morse.rb
Created March 17, 2022 04:12
morse code but with paulo cuchi
# frozen_string_literal: true
dot = 'cuchi'
dash = 'paulo'
# our tree is based on this image
# https://upload.wikimedia.org/wikipedia/commons/thumb/1/19/Morse-code-tree.svg/1280px-Morse-code-tree.svg.png
$morse_tree = {
dot => {
char: 'e',
@Grohden
Grohden / pad_csv.js
Created February 25, 2022 18:45
Script to pad CSV columns (for readability)
const fs = require('fs');
const filterMap = (list, map) => {
const mapped = [];
for (let i = 0; i < list.length; i++) {
const transformed = map(list[i]);
if (transformed) {
mapped.push(transformed);
}
@Grohden
Grohden / barrel-file-info.js
Created November 23, 2021 19:27
Script that resolves all exports + paths from TS barrel files, meant to be used with babel-transform-imports
const fs = require('fs');
const path = require('path');
const ts = require('typescript');
/**
* Parses a barrel (index) file, extracts all it's export
* names and returns an object that maps
* a import name to the path + some meta infos.
*
@Grohden
Grohden / first-one.ts
Last active October 21, 2021 16:50
Collection of typescript type system issues or bugs that don't get caught by it.
type Foo = {
// Assigning undefined here is wrong.
// this value either HAVE A KEY WITH VALUE or DON'T HAVE A KEY
[key: string]: { foo: string }
// const foo: Foo = { key: undefined }
// 'key' in foo // true, but should never be the case, because if there's a key, there's a value.
}
// note: the only case where the index signature might be correctly represented
// is when we use a proxy, that way we can guarantee that we always return something
@Grohden
Grohden / short-cut-fusion.js
Last active October 6, 2021 14:40
simple impl of shortcut fusion(also called: deflorestation, stream fusion) using javascript generators
function* map(morphism, itr) {
let value;
while(value = itr.next().value) {
yield morphism(value);
}
}
function* filter(predicate, itr) {
let value;