Skip to content

Instantly share code, notes, and snippets.

View HirbodBehnam's full-sized avatar

Hirbod Behnam HirbodBehnam

View GitHub Profile
@HirbodBehnam
HirbodBehnam / TelegramDownloader.py
Last active July 11, 2020 12:12
A python script to download a file from Telegram
# Usage: At first send the file to your saved messages. Make sure it's the last message and run this script with python
# At first install Telethon and humanize with pip3 install telethon humanize cryptg
# Note that cryptg is optional and only is used for speeding up the downloads
import asyncio
import humanize
from telethon import TelegramClient
# These example values won't work. You must get your own api_id and
# api_hash from https://my.telegram.org, under API Development.
api_id = 12345
@HirbodBehnam
HirbodBehnam / multifile-upload.go
Last active November 24, 2021 02:43
A code to upload multiple files with multipart with small ram usage
package main
import (
"bytes"
"fmt"
"io"
"io/ioutil"
"log"
"mime/multipart"
"net/http"
@HirbodBehnam
HirbodBehnam / RandomFileServer.go
Last active August 31, 2020 06:36
Spawns file server of current directory on a random port and configures firewall for it.
package main
import (
"context"
"log"
"math/rand"
"net/http"
"os"
"os/exec"
"os/signal"
package main
import (
"fmt"
tls "github.com/refraction-networking/utls"
"net"
"time"
)
var requestHostname = "cloudfront.com"
./configure --prefix=/etc/nginx \
--sbin-path=/usr/sbin/nginx \
--modules-path=/usr/lib64/nginx/modules \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
--build=CentOS \
--with-select_module \
--with-poll_module \
@HirbodBehnam
HirbodBehnam / spotmybackup-dl.py
Last active August 8, 2025 18:19
This script will help you download tracks from http://www.spotmybackup.com/
import json
import os
import requests
import shutil
import spotipy
import sys
from bs4 import BeautifulSoup
from deezloader import Login # https://github.com/An0nimia/deezloader
from glob import glob
@HirbodBehnam
HirbodBehnam / google-form-to-tg.gs
Last active May 22, 2025 11:28
A google script to send submitted form results to a telegram bot
// Inspired by https://github.com/Iku/Google-Forms-to-Discord
const BOT_API = "YOUT_BOT_API";
const CHAT_ID = "CHAT_ID";
function onSubmit(e) {
var form = FormApp.getActiveForm();
var allResponses = form.getResponses();
var latestResponse = allResponses[allResponses.length - 1];
var response = latestResponse.getItemResponses();
var result = "";
@HirbodBehnam
HirbodBehnam / floor_sqrt.cpp
Last active November 6, 2020 13:07
A simple script to calculate the floor(sqrt(x)) with binary search in cpp. Also prevents the integer overflow on large values.
unsigned long long floor_sqrt(unsigned long long x)
{
unsigned long long low = 0, high = x;
// prevent integer overflow on pow2
if (high > 18446744065119617025)
return 4294967296;
if (high > 4294967296 * 2 - 1)
high = 4294967296 * 2 - 1;
// use binary search
while(low <= high)
@HirbodBehnam
HirbodBehnam / dark-pdf.js
Created November 12, 2020 15:50
A tampermonkey script to enable dark mode even on local files.
// ==UserScript==
// @name PDF Dark Mode
// @namespace http://tampermonkey.net/
// @version 1
// @description A tampermonkey script to enable dark mode even on local files.
// @author Hirbod Behnam
// @match *://*/*.pdf
// @grant none
// ==/UserScript==
@HirbodBehnam
HirbodBehnam / chacha20.h
Last active February 7, 2021 19:36
A super simple chacha20 implantation
#include <stdint.h>
#include <string.h>
static uint32_t rotl(uint32_t a, uint32_t b) {
return (a << b) | (a >> (32 - b));
}
static void qr(uint32_t x[], uint32_t a, uint32_t b, uint32_t c, uint32_t d) {
x[a] = x[a] + x[b];
x[d] = rotl(x[d] ^ x[a], 16);