Skip to content

Instantly share code, notes, and snippets.

View mshafiee's full-sized avatar

Mohammad Shafiee mshafiee

View GitHub Profile
/*
TinyMCE Local Editor Server
This program is a simple HTTP server that serves a local HTML file with an embedded TinyMCE editor.
It allows you to edit the content of the HTML file in real-time using the TinyMCE rich text editor.
The server also saves any changes made in the editor back to the original HTML file.
Usage:
go run main.go [-dir ltr|rtl] <html_file>
"""
TinyMCE Local Editor Server
This script is a simple HTTP server that serves a local HTML file with an embedded TinyMCE editor.
It allows you to edit the content of the HTML file in real-time using the TinyMCE rich text editor.
The server also saves any changes made in the editor back to the original HTML file.
Usage:
python tinymce_editor.py [-dir ltr|rtl] <html_file>
from telethon import TelegramClient
from telethon.tl.types import PeerChannel
import os
# Replace these with your own values
api_id = 'YOUR_API_ID' # Your API ID from my.telegram.org
api_hash = 'YOUR_API_HASH' # Your API Hash from my.telegram.org
phone_number = 'YOUR_PHONE_NUMBER' # Your phone number with country code
# List of private and public channel links
import os
import sys
def collect_go_files_content(directory):
content = ""
for root, _, files in os.walk(directory):
for file in files:
if file.endswith(".go"):
file_path = os.path.join(root, file)
with open(file_path, 'r', encoding='utf-8') as f:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Magic Square Generator</title>
<style>
table {
border-collapse: collapse;
margin: 20px 0;
@mshafiee
mshafiee / create-certificate-stack.sh
Created February 13, 2023 20:59
This is a bash script that creates a CloudFormation stack for a public certificate with DNS validation, based on input parameters provided as command line flags.
#!/bin/bash
# This is a bash script that creates a CloudFormation stack for a public certificate with DNS validation,
# based on input parameters provided as command line flags.
# The script starts by defining the print_help function that displays the usage information for the script,
# along with the available command line flags.
# Next, the script uses the getopts command to parse the command line flags and store their values in variables
# (stack_name, csv_file, and domain_name). If any of the required flags are missing, the script will display
# an error message and exit.
# The script then reads the contents of the CSV file into a bash array (subject_alternative_names), which
# will be used to specify the SubjectAlternativeNames for the certificate.
@mshafiee
mshafiee / resetBranch.sh
Created February 4, 2023 15:14
This bash script will check if a branch named BRANCH_NAME exists in the Git repository. If it exists, it will checkout to that branch and reset the branch to the previous commit, discarding all previous commits except the last one. It will then rename the latest commit to COMMIT_NAME and push the rewritten branch to the remote repository. Finall…
#!/bin/bash
# This bash script will check if a branch named BRANCH_NAME exists in the Git repository.
# If it exists, it will checkout to that branch and reset the branch to the previous commit,
# discarding all previous commits except the last one. It will then rename the latest
# commit to COMMIT_NAME and push the rewritten branch to the remote repository.
# Finally, it will display a message indicating that the branch has been rewritten
# and the last commit has been renamed.
if [ $# -ne 2 ]; then
# This script is a command line tool that reads German conjugations of the verb "sein" (to be)
# in the present tense using Festival TTS engine on Linux. The script declares an array of strings,
# each string containing a conjugation of the verb "sein" for a different personal pronoun.
# Then, it uses an infinite while loop to iterate over the array, reading each conjugation 60 times
# with a sleep of 1 second in between each reading. The script uses the echo "$i" | festival --tts -voice de
# command to read the current string in the array, where -voice de option is added to the festival --tts command,
# which causes the TTS engine to use a German voice. The script is useful for language learners who want to
# practice the conjugations of the verb "sein" in the present tense on Linux.
# How to install festival:
# sudo apt-get install festival
@mshafiee
mshafiee / sysctl.conf
Last active June 27, 2022 09:50
Customized sysctl for high network loads
###################################################################
# Protected links
#
# Protects against creating or following links under certain conditions
# Debian kernels have both set to 1 (restricted)
# See https://www.kernel.org/doc/Documentation/sysctl/fs.txt
#fs.protected_hardlinks=0
#fs.protected_symlinks=0
net.ipv4.ip_forward=1
#net.ipv4.ip_local_reserved_ports=30000-32767
@mshafiee
mshafiee / haproxy.cfg
Last active June 13, 2022 10:34
Sample of HAProxy active-active peers rate limiting by counting a custom header
global
localpeer haproxy-1
defaults
timeout connect 5s
timeout client 1m
timeout server 1m
peers haproxy-peers