Skip to content

Instantly share code, notes, and snippets.

View AmirSbss's full-sized avatar
♾️

Amirh. Safavi AmirSbss

♾️
View GitHub Profile
@carcinocron
carcinocron / debugger pause beforeunload
Last active September 24, 2024 12:02
Chrome: pause before redirect
// Run this in the F12 javascript console in chrome
// if a redirect happens, the page will pause
// this helps because chrome's network tab's
// "preserve log" seems to technically preserve the log
// but you can't actually LOOK at it...
// also the "replay xhr" feature does not work after reload
// even if you "preserve log".
window.addEventListener("beforeunload", function() { debugger; }, false)
@statickidz
statickidz / nearby-coordinates.sql
Last active September 27, 2024 15:59
Ordering with SQL by nearest latitude & longitude coordinates (MySQL & SQLite)
---
METHOD 1
This should roughly sort the items on distance in MySQL, and should work in SQLite.
If you need to sort them preciser, you could try using the Pythagorean theorem (a^2 + b^2 = c^2) to get the exact distance.
---
SELECT *
FROM table
ORDER BY ((lat-$user_lat)*(lat-$user_lat)) + ((lng - $user_lng)*(lng - $user_lng)) ASC
@cmer
cmer / haproxy.cfg
Last active September 9, 2024 11:24
Simple, no bullshit TCP port forwarding using HAProxy
listen l1
bind 0.0.0.0:443
mode tcp
timeout connect 4000
timeout client 180000
timeout server 180000
server srv1 host.example.com:9443
@smaznet
smaznet / README.md
Last active June 1, 2021 11:04
اجرا کردن چندین تلگرام بر روی ابونتو

کد زیر رو دانلود یا کپی کنید بعدش تو ترمینال chmod +x tltweak.sh ./tltweak.sh

یه شماره وارد کنید مثلا ۲ که اسم تلگرامتون بشه Telegram 2 ایکون تو دسک تاپ ایجاد شد و همچنین تو منو اپ هاتون هم میاد

@holmberd
holmberd / php-pools.md
Last active September 25, 2024 05:44
Adjusting child processes for PHP-FPM (Nginx)

Adjusting child processes for PHP-FPM (Nginx)

When setting these options consider the following:

  • How long is your average request?
  • What is the maximum number of simultaneous visitors the site(s) get?
  • How much memory on average does each child process consume?

Determine if the max_children limit has been reached.

  • sudo grep max_children /var/log/php?.?-fpm.log.1 /var/log/php?.?-fpm.log
@GhostofGoes
GhostofGoes / .gitignore
Created October 4, 2018 04:29
Basic .gitignore template for Python projects
# Editors
.vscode/
.idea/
# Vagrant
.vagrant/
# Mac/OSX
.DS_Store
@oskar456
oskar456 / wgcf.py
Last active February 17, 2024 12:47
Cloudflare WARP linux client (using wg-quick for actual tunnel setup)
#!/usr/bin/env python3
import subprocess
import json
import os
from pathlib import Path
import requests
from requests.compat import urljoin
@ijash
ijash / ubuntu_server_fastest_mirror_trick.md
Last active July 6, 2023 15:08
Switching to nearest mirror using terminal in ubuntu server with "mirror" method.

The apt mirror method

A gem was found during my google search. Not much known as it said(at least during this writing),but works damn good.

This mirror method will automatically select the fastset mirror during apt update. based on your location. tested and running well on Ubuntu Server 18.04

  1. First, open /etc/apt/sources.list with a text editor.

sudo nano /etc/apt/sources.list

@draincoder
draincoder / tg_web_app_auth.py
Last active June 26, 2024 08:12
Python implementation of Telegram.WebApp.initData validation
import hashlib
import hmac
import json
from dataclasses import dataclass
from operator import itemgetter
from typing import Any
from urllib.parse import parse_qsl
@dataclass(eq=False)