Skip to content

Instantly share code, notes, and snippets.

View AnjanaMadu's full-sized avatar
:shipit:
Luv open source

Anjana Madu AnjanaMadu

:shipit:
Luv open source
View GitHub Profile
@MarshalX
MarshalX / 1_pytgcalls_video_telethon_example.py
Last active March 30, 2024 16:44
Example of the most simple way to stream any video to Telegram Live Stream (Group Call) with https://github.com/MarshalX/tgcalls
# before run this script install required packages via command below
# pip3 install -U pytgcalls==3.0.0.dev24
import asyncio
import pytgcalls
import telethon
# EDIT THIS
# more info about API keys here https://docs.telethon.dev/en/latest/basic/signing-in.html
@painor
painor / FastTelethon.py
Last active April 27, 2024 16:21
This will increase the download/upload speed when using telethon
# copied from https://github.com/tulir/mautrix-telegram/blob/master/mautrix_telegram/util/parallel_file_transfer.py
# Copyright (C) 2021 Tulir Asokan
import asyncio
import hashlib
import inspect
import logging
import math
import os
from collections import defaultdict
from typing import Optional, List, AsyncGenerator, Union, Awaitable, DefaultDict, Tuple, BinaryIO
@j33ty
j33ty / print-memory.go
Created May 22, 2019 20:54
Go print current memory
package main
import (
"runtime"
"fmt"
"time"
)
func main() {
// Print our starting memory usage (should be around 0mb)
@kgantsov
kgantsov / large_file_server.py
Created April 14, 2017 11:18
Example of serving large files using aiohttp server without reading entire file into a memory
import asyncio
import os
from aiohttp import web
from aiohttp import streamer
@streamer
async def file_sender(writer, file_path=None):
"""
@import 'https://fonts.googleapis.com/css?family=Open+Sans';
* {
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
body {
font-family: 'Open Sans', sans-serif;
line-height: 1.75em;
@andrewmilson
andrewmilson / file-upload-multipart.go
Last active April 24, 2024 10:27
Golang multipart/form-data File Upload
package main
import (
"net/http"
"os"
"bytes"
"path"
"path/filepath"
"mime/multipart"
"io"
@nestoru
nestoru / ubuntu-install-xrdp.sh
Last active August 30, 2021 12:58
Install XRDP in Ubuntu
#!/bin/bash -e
#
# ubuntu-install-xrdp.sh
# Tested in Ubuntu 20.04: Bidirectional clipboard does work.
#
# One line installer (change ubuntu by the username that you want to remotely login):
# curl -L https://gist.github.com/nestoru/fee24a59804d60ccba1a/raw | sudo bash -s ubuntu
#
START=$(date +%s)
@mattetti
mattetti / multipart_upload.go
Last active April 22, 2024 05:24
Example of doing a multipart upload in Go (golang)
package main
import (
"bytes"
"fmt"
"io"
"log"
"mime/multipart"
"net/http"
"os"
@troelskn
troelskn / gist:1287893
Created October 14, 2011 18:24
Luhn's algorithm in php
<?php
function is_valid_luhn($number) {
settype($number, 'string');
$sumTable = array(
array(0,1,2,3,4,5,6,7,8,9),
array(0,2,4,6,8,1,3,5,7,9));
$sum = 0;
$flip = 0;
for ($i = strlen($number) - 1; $i >= 0; $i--) {
$sum += $sumTable[$flip++ & 0x1][$number[$i]];
@aeurielesn
aeurielesn / util.php
Created July 31, 2011 03:47
Decode Unicode strings in PHP
<?php
#source: http://stackoverflow.com/questions/2934563/how-to-decode-unicode-escape-sequences-like-u00ed-to-proper-utf-8-encoded-char
function replace_unicode_escape_sequence($match) {
return mb_convert_encoding(pack('H*', $match[1]), 'UTF-8', 'UCS-2BE');
}
function unicode_decode($str) {
return preg_replace_callback('/\\\\u([0-9a-f]{4})/i', 'replace_unicode_escape_sequence', $str);
}