Skip to content

Instantly share code, notes, and snippets.

View lxsmnsyc's full-sized avatar
🤖
I'm not a robot

Alexis H. Munsayac lxsmnsyc

🤖
I'm not a robot
View GitHub Profile
@lxsmnsyc
lxsmnsyc / brainfuck-type.ts
Created November 30, 2020 07:12
Brainfuck-to-JS Compiler using only TypeScript's type system
type Collect<T, O extends string, C extends string, S extends string, R extends any[] = []> =
T extends `${C}${infer Rest}`
? Collect<Rest, Rest, C, S, [any, ...R]>
: `${S}(${R['length']});${Compile<O>}`;
type Compile<T> =
T extends `+${infer Rest}`
? Collect<T, Rest, '+', 'c'>
:
T extends `-${infer Rest}`
@lxsmnsyc
lxsmnsyc / index.md
Last active January 4, 2021 10:28
demo-1

Preferred CSS/Design

Tailwind

Pros

  • When customizing stick to the design system
  • Small learning curve
  • They have component-based design in mind
  • Upcoming NextJS, built-in Tailwind
@lxsmnsyc
lxsmnsyc / introspection.graphql
Created April 29, 2021 05:37
Introspection Query for GraphQL
query IntrospectionQuery {
__schema {
queryType {
name
}
mutationType {
name
}
subscriptionType {
name
/**
* @license
* MIT License
*
* Copyright (c) 2020 Alexis Munsayac
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@lxsmnsyc
lxsmnsyc / example.ts
Last active September 3, 2021 04:34
createSWRResource
interface SWROptions {
revalidateOnVisibility?: boolean;
revalidateOnNetwork?: boolean;
revalidateOnFocus?: boolean;
}
function createSWRResource<T>(
data: Resource<T>,
refetch: () => void,
options: SWROptions,
@lxsmnsyc
lxsmnsyc / serializer.js
Created February 4, 2023 15:43
JS serializer
function serialize(source) {
const refs = [];
const assignments = [];
function checkRef(current) {
const index = refs.indexOf(current);
if (index === -1) {
refs.push(current)
return { first: true, index: refs.length - 1};
}
@lxsmnsyc
lxsmnsyc / minesweeper.lua
Created April 28, 2023 05:58
Minesweeper in LOVE
local random = math.random
local function newMap(width, height, mines)
local map, symbol, hide = {}, {}, {}
for x = 1, width do
map[x] = {}
symbol[x] = {}
hide[x] = {}
for y = 1, height do