Skip to content

Instantly share code, notes, and snippets.

View gmotzespina's full-sized avatar
🏠
Working from home

Guillermo Martínez gmotzespina

🏠
Working from home
View GitHub Profile
@gmotzespina
gmotzespina / share_dialog_chips.tsx
Last active July 5, 2024 15:07
Share dialog with chips
import InputWithChips, { UserChip } from "@components/InputWithChips";
import SimpleDivider from "@components/SimpleDivider";
import { Transition, Dialog } from "@headlessui/react";
import { PaperAirplaneIcon } from "@heroicons/react/20/solid";
import { Button, Typography } from "@material-tailwind/react";
import React, { Fragment, useEffect, useState } from "react";
import { Formik } from "formik";
import { AccessPermissions, AccessType } from "@prisma/client";
import AccessPermissionsPicker from "@components/AccessPermissionsPicker";
@gmotzespina
gmotzespina / file_system.py
Created July 2, 2024 16:40
File System Example
import os
def find_files(directory, pattern):
for item in os.listdir(directory):
full_path = os.path.join(directory, item)
if os.path.isfile(full_path) and pattern in item:
print(full_path)
elif os.path.isdir(full_path):
find_files(full_path, pattern) # Recurse into subdirectory
@gmotzespina
gmotzespina / string_reversal.py
Created July 2, 2024 16:39
String Reversal Example
def reverse_string(s):
if len(s) == 0:
return s
else:
return reverse_string(s[1:]) + s[0]
print(reverse_string("hello")) # Output: olleh
@gmotzespina
gmotzespina / fibonacci.py
Created July 2, 2024 16:38
Fibonacci example
def fibonacci(num):
if num<= 1:
return num
else:
return fibonacci(num-1) + fibonacci(num-2)
print(fibonacci(6)) # Output: 8
def factorial(num):
# Base case
if num == 0:
return 1
# Recursive step
else:
return num * factorial(num - 1)
print(factorial(3)) # Output: 6
@gmotzespina
gmotzespina / screen_recorder.ts
Last active August 26, 2025 15:13
Screen Recorder
import {
AddStreamOptions,
ConstructorOptions,
VideoStreamMerger
} from "video-stream-merger";
import { RecordRTCPromisesHandler } from "recordrtc";
import { ScreenShare } from "@components/ScreenShareOption";
// This just renames it to StreamSettings because it gives you a better idea of what it is.
// eslint-disable-next-line @typescript-eslint/no-empty-interface
@gmotzespina
gmotzespina / mail.php
Created May 6, 2020 23:26
PHP and mailgun configuration
<?php
define('MAILGUN_URL', 'https://api.mailgun.net/v3/YOUR_URL');
define('MAILGUN_KEY', 'MAILGUN_KEY');
$mail = $_POST;
$name = $mail['name'];
$from = $mail['email'];
if(empty($from) || empty($name)) {
print('false');
@gmotzespina
gmotzespina / Attributes.ts
Last active March 26, 2020 00:47
Generics Introduction: Class and interface using generics
export interface StudentProps {
id: number;
name: string;
}
export interface TeacherProps {
id: number;
name: string;
isGoodTeacher: boolean;
}
@gmotzespina
gmotzespina / student.ts
Created March 26, 2020 00:26
Generics introduction: Student class
interface StudentProps {
id: number;
name: string;
}
export class Student {
constructor(private data: StudentProps) {}
get(propName: string): number | string {
@gmotzespina
gmotzespina / SyncWithGenerics.ts
Last active March 24, 2020 13:09
Generics Introduction: Sync function using generics
const rootUrl = "https://path_to_your_server/students";
class Student {
public sync: Sync<StudentProps> = new Sync<StudentProps>(rootUrl)
}
interface HasId {
id?: number;
}