Skip to content

Instantly share code, notes, and snippets.

View sadiqsalau's full-sized avatar
💻
Coding

Sadiq Salau sadiqsalau

💻
Coding
View GitHub Profile
@sadiqsalau
sadiqsalau / index.js
Created April 6, 2025 17:31
GramJS Detect Connection State
import { Raw } from "telegram/events";
import { UpdateConnectionState } from "telegram/network";
/** Add Connected Event Handler */
client.addEventHandler(
(event) => {
console.log(event);
/** Do Something With State **/
setConnected(event.state === UpdateConnectionState.connected);
@sadiqsalau
sadiqsalau / TelegramValidator.php
Created April 1, 2025 10:45
PHP / Laravel Validate Telegram WebAppData
<?php
use Base64Url\Base64Url;
use Elliptic\EdDSA;
// composer require simplito/elliptic-php spomky-labs/base64url
class TelegramValidator {
/**
* Check if is valid WebAppData
* @param string $webAppData
@sadiqsalau
sadiqsalau / example.js
Last active March 29, 2025 15:42
GramJS with Multiple Sessions and Promises
const client = await GramClient.create("default");
/** POST: /telegram/login */
await client.startPending(); // Starts Client, response can be called later
await client.startResponse("phoneNumber", "phone");
/** POST: /telegram/code */
await client.startResponse("phoneCode", "code");
@sadiqsalau
sadiqsalau / release.yml
Last active March 2, 2025 09:57
Electron Builder + Python Workflow Fix
name: Build/release Electron app
on:
push:
tags:
- v*.*.*
permissions:
contents: write
@sadiqsalau
sadiqsalau / backup.sh
Last active February 7, 2025 16:53
Telegram Portable Updater and Backuper
#!/usr/bin/bash
# Directory Structure
# _BACKUP
# _BINARY
# _BASE
echo "Cleanup Previous Backup"
rm -rf _BACKUP telegram-accounts-backup.zip
@sadiqsalau
sadiqsalau / crontab
Created February 2, 2025 15:19
Laravel EC2 Ubuntu Crontab
# Start Server
@reboot cd /home/ubuntu/laravel-app && screen -dmS server php artisan serve --host 0.0.0.0
# Send Server IP Address
@reboot cd /home/ubuntu/laravel-app && php artisan app:send-server-address >> /dev/null 2>&1
# Run Scheduled Commands
* * * * * cd /home/ubuntu/laravel-app && php artisan schedule:run >> /dev/null 2>&1
@sadiqsalau
sadiqsalau / TelegramForcePortable.md
Last active January 19, 2025 10:12
Telegram Linux Portable
@sadiqsalau
sadiqsalau / .htaccess
Created January 12, 2025 03:38
Redirect Crawlers to Backend
Options -MultiViews
RewriteEngine On
# Enable Https
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_USER_AGENT} (facebookexternalhit/[0-9]|Twitterbot|Pinterest|Google.*snippet|LinkedInBot|Slackbot|Discordbot|WhatsApp|TelegramBot|Applebot|Bingbot|YandexBot|DuckDuckGo-Favicons-Bot|Sogou|Exabot|Baiduspider|SeznamBot|ahrefsbot|MJ12bot|DotBot|ia_archiver|Embedly|W3C_Validator) [NC]
RewriteRule ^(.*)$ https://backend.example.com/og/$1 [L,R=301]
@sadiqsalau
sadiqsalau / Isotope.jsx
Last active February 15, 2024 03:22
React Isotope
/** npm install isotope-layout clsx **/
import IsotopeLayout from "isotope-layout";
import React from "react";
import clsx from "clsx";
const IsotopeContext = React.createContext();
export const Isotope = ({ children, ...props }) => {
const isotope = React.useRef();
@sadiqsalau
sadiqsalau / .cpanel.sample.conf
Last active October 14, 2023 15:39
Deploy Laravel to another workflow
export RUN_MIGRATIONS=false