Skip to content

Instantly share code, notes, and snippets.

View Shoghy's full-sized avatar

Shoghy Martinez Shoghy

  • Santiago De Los Caballeros, Dominican Republic
View GitHub Profile
@Shoghy
Shoghy / option.ts
Created June 11, 2024 19:09
Imitando los enum Option y Result de Rust
enum EType {
Some,
None,
}
export class Option<T> {
private value!: T;
private type: EType;
private constructor(type: EType) {
@Shoghy
Shoghy / modular.rs
Created May 4, 2024 20:10
Modular exponentiation
fn modadd(a: u64, b: u64, module: u64) -> u64{
if a >= module{
return a%module;
}else if b >= module{
return b%module;
}
if a > module - b{
return a - (module - b);
}else if b > module - a {
return b - (module - a);
@Shoghy
Shoghy / catcher.ts
Last active July 22, 2024 04:36
A typescript try/catch with type aware catchs.
export type Func<P extends Array<unknown>, R> = (...args: P) => R;
interface JSTypes{
string: string
number: number
bigint: bigint
boolean: boolean
symbol: symbol
undefined: undefined
object: object
@Shoghy
Shoghy / HandleInertiaRequests.php
Created March 12, 2024 13:57
How to use VueJS with Laravel 7
<?php
namespace App\Http\Middleware;
use Illuminate\Http\Request;
use Inertia\Middleware;
class HandleInertiaRequests extends Middleware
{
/**
@Shoghy
Shoghy / file_getter.js
Created February 26, 2024 15:40
A function to get all files on a folder and its subfolders recursively without using function recursion
import fs from "fs";
/**
* @param {Array<T>} arr
* @param {number} index
* @returns {Array<T>}
* @template T
*/
function RemoveIndexOfArray(arr, index){
const copyOfArray = [... arr];
@Shoghy
Shoghy / BetterStr.php
Last active February 16, 2024 11:47
A PHP class that saves a string and implements string methods
<?php
/**
* @property-read int $length
*/
class BetterStr{
protected string $value = "";
public function get_value(){
return $this->value;
}