Skip to content

Instantly share code, notes, and snippets.

View movahhedi's full-sized avatar
💻
Coding, probably.

Shahab Movahhedi movahhedi

💻
Coding, probably.
View GitHub Profile
@t3dotgg
t3dotgg / try-catch.ts
Last active December 9, 2025 20:30
Theo's preferred way of handling try/catch in TypeScript
// Types for the result object with discriminated union
type Success<T> = {
data: T;
error: null;
};
type Failure<E> = {
data: null;
error: E;
};
@lionrajkumar
lionrajkumar / UpgradeMariaDB.md
Last active December 3, 2025 05:19
Upgrade MariaDB to latest in Xampp

How to upgrade MySQL to MariaDB in XAMPP in 5 minutes on Windows

Here are the steps I used to to upgrad MySQL to MariaDB in XAMPP on Windows in about 5 minutes. After completing this process, MariaDB will look and work just like MySQL. You may even notice a performance increase in your website. No need to panic fellow developer, increased performance is perfectly normal and just one of the great benefits of MariaDB over MySQL.

IMPORTANT: Before you begin, always be sure to make a good backup. Do not do move instead of copy files in the instructions below as the original files may be required in order to back out and restore the original MySQL environment if it doesn't work out for you.

  1. Open a command prompt.
  2. Go to your xampp folder.
  3. Enter the following command: mysql/bin/mysql --version
  4. Take note of the version of MySQL you have installed. This is the version of MariaDB that you will need. You can now exit the command prompt as the rest of the instructions can be done through Windows Explorer
@einari
einari / LetsEncryptCertbotTLS.sh
Created November 23, 2022 08:56
Script for creating a Lets Encrypt certificate using Certbot and then exporting to .pfx file
#!/bin/bash
sudo certbot \
certonly \
--server https://acme-v02.api.letsencrypt.org/directory \
--manual \
--agree-tos \
--preferred-challenges dns \
--register-unsafely-without-email \
-d *.domain. # Wildcard - could be regular and one can also specify multiple -d options to include in the certificate
@movahhedi
movahhedi / SmsIr.php
Last active June 7, 2023 13:11
SMS.IR Full PHP Class
<?php
/**
* @author Shahab Movahhedi <[email protected]>
* @copyright © 2022 Shahab Movahhedi. All rights reserved.
* @link http://sms.ir/ Documentation of sms.ir RESTful API PHP sample.
* @version 1.2
*/
class SmsIr {
@daviesesiro
daviesesiro / image-resize.js
Last active June 27, 2024 01:05
a minimal function to resize an image on the browser in JavaScript
/**
* Resizes an Image File and converts it to a dataurl string.
* @param imageFile the image file (probably from a file input)
* @param resize_width The width you want the image to be
* @param quality quality of the resize image 0 - 1
*/
const resizeImage = ({
resizeWidth = 400,
imageFile,
quality = 1,
@aleclarson
aleclarson / rollup-typescript.md
Last active September 14, 2025 14:31
The best Rollup config for TypeScript libraries

It's 2024. You should use tsup instead of this.


Features

🔥 Blazing fast builds
😇 CommonJS bundle
🌲 .mjs bundle
.d.ts bundle + type-checking

@anuraghazra
anuraghazra / Exclude-node_modules.md
Last active October 3, 2025 22:40
Exclude node_modules folder when copying directory.

Handy Trick To Get Rid Of node_modules

This one is a simple and handy trick when you want to copy your directories without node_modules folder.

Enter this command in your terminal.

robocopy SOURCE DEST /mir /xd node_modules
@LoganGray
LoganGray / chromeinstall_ubu16.sh
Last active June 6, 2023 14:35
this worked to install selenium and google chrome on my Ubuntu 16 server.
#!/usr/bin/env bash
# used to install offical chrome and selenium on Ubuntu 16.04.1 LTS, 18.04, 20.04.1 LTS desktop, Jan 2021
# also tested and works on Elem OS 5.1 :)
#
# make sure script is run as root or sudo
if [[ $(whoami) != "root" ]] ; then
echo ; echo "This script, $0, SHOULD be run as ROOT. " ; echo
exit 1
fi
#