Skip to content

Instantly share code, notes, and snippets.

View UltiRequiem's full-sized avatar

Eliaz Bobadilla UltiRequiem

View GitHub Profile
@UltiRequiem
UltiRequiem / pizza.ts
Created June 14, 2022 01:13
TypeScript Array Type Guards explicados en dos minutos
interface Pizza {
type: "pizza";
slices: number;
}
interface Hamburger {
type: "hamburger";
vegetarian: boolean;
}
export class NestedError<ErrorLike extends Error> extends Error {
private nestedError: ErrorLike;
constructor(config: { message?: string; nestedError: ErrorLike }) {
const { message = "", nestedError } = config;
super(message);
this.nestedError = nestedError;
@UltiRequiem
UltiRequiem / denoRun.ts
Last active March 30, 2022 16:49
Run a deno subcommand
export function denoRun(args: string[], options: Partial<Deno.RunOptions> = {}) {
return Deno.run({
cmd: ["deno", ...args],
stdout: "null",
stderr: "null",
...options,
});
}
@UltiRequiem
UltiRequiem / lint.ts
Created March 30, 2022 16:23
Check and Lint deno code format
#!/usr/bin/env -S deno run --allow-run
const checkFormatprocess = Deno.run({
cmd: ["deno", "fmt", "--check", "."],
stdout: "null",
stderr: "null",
});
const lintProcess = Deno.run({
cmd: ["deno", "lint", "."],
@UltiRequiem
UltiRequiem / brainfuck.cpp
Created February 25, 2022 16:56
A simple, not completly working Brain F**ck compiler on C++ | When did I learn C++???
#include <fstream>
#include <iostream>
#define SOURCE_SIZE 10000
#define MEMORY_SIZE 30000
using std::cout;
using std::endl;
void bf_execute(char *src, int *mem, int loop) {
@UltiRequiem
UltiRequiem / over_complicated.py
Created February 14, 2022 20:38
centaui_prime
VALID_VOWELS = ["A", "E", "I", "O", "U", "a", "e", "i", "o", "u"]
consonants = "bcdfghjklmnpqrstvwxz" + "BCDFGHJKLMNPQRSTVWXZ"
def is_vowel(string):
return string in VALID_VOWELS
RULERS = {"vowels": "Alice", "consonants": "Bob", "y": "nobody"}
@UltiRequiem
UltiRequiem / main.rs
Created February 7, 2022 20:39
get env vars rust
use std::env;
const DEFAULT_PORT: u16 = 3000;
const DEFAULT_SERVER_MODE: &str = "DEV";
fn main() {
let server_port = env::var("SERVER_PORT").unwrap_or(DEFAULT_PORT.to_string());
let server_mode = env::var("SERVER_MODE").unwrap_or(DEFAULT_SERVER_MODE.to_string());
println!(
package main
import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"log"
const size = 10.0;
const clr = 0.0;
const ps = 0.0;
rust
.then((canvas) => {
var nodes = document.getElementsByTagName("button");
for (var i = 0; i < nodes.length; i++) {
nodes[i].addEventListener(
@UltiRequiem
UltiRequiem / swc_tsx.rs
Created January 27, 2022 00:56
Got swc working for tsx, pogs
use std::{path::Path, sync::Arc};
use swc::{
self,
config::{JscConfig, Options},
};
use swc_common::{
errors::{ColorConfig, Handler},
SourceMap,
};