Skip to content

Instantly share code, notes, and snippets.

View sumonst21's full-sized avatar
💭
I may be slow to respond.

Md. Sumon Islam sumonst21

💭
I may be slow to respond.
View GitHub Profile
import requests
import asyncio
from timeit import default_timer
from concurrent.futures import ThreadPoolExecutor
START_TIME = default_timer()
def request(session, i):
url = "https://jsonplaceholder.typicode.com/photos"
with session.get(url) as response:
import requests
from timeit import default_timer
def request(session):
url = "https://jsonplaceholder.typicode.com/photos"
with session.get(url) as response:
data = response.text
if response.status_code != 200:
print("FAILURE::{0}".format(url))
@sumonst21
sumonst21 / dropzone.php
Created September 24, 2022 07:36 — forked from kreativan/dropzone.php
Upload files with dropzone.js and php
<?php
// process $_POST request
if(isset($_POST["submitDropzone"])) {
// Do something
print_r($_POST);
}
?>
@sumonst21
sumonst21 / cloudflare_fetch_rayid_log.sh
Created September 23, 2022 22:29 — forked from mihaitodor/cloudflare_fetch_rayid_log.sh
Fetch Cloudflare log data for a given Ray ID
#!/bin/bash
# Fetch Cloudflare log data for a given Ray ID
# Please note that the Ray ID is the first part of `CF-RAY` (4a807f60ca5727a4-FRA -> 4a807f60ca5727a4)
CF_ZONE=${1}
RAY_ID=${2}
if ! host -N 0 "${CF_ZONE}" 2>&1 > /dev/null; then
echo "Invalid domain '${CF_ZONE}'"
@sumonst21
sumonst21 / captcha.php
Created September 22, 2022 17:14 — forked from NachoToast/captcha.php
Verify a recaptcha v3 token.
<?php
function verify_captcha($token) {
$threshold = 0.5; // Score must be > threshold to pass captcha.
// Default is 0.5, although the majority of users will get 0.9
$sites = ["localhost", "nachotoast.com", "ntgc.ddns.net"]; // Site names string, e.g. sub.domain.com:8080
$secret = "Put your client secret here.";
$url = "https://www.google.com/recaptcha/api/siteverify";
$data = array("secret" => $secret, "response" => $token);
@sumonst21
sumonst21 / allow
Created September 13, 2022 14:26 — forked from Nilpo/allow
CSF Allow AND Ignore Cloudflare IPv4 IP's.
for i in `curl https://www.cloudflare.com/ips-v4`; do csf -a $i; done
@sumonst21
sumonst21 / timing.php
Created September 8, 2022 18:43 — forked from cam-gists/timing.php
PHP: Benchmarking / Timing Class
<?php
/**
* Timing Class for benchmarking in PHP
* @ref: http://www.if-not-true-then-false.com/2010/php-timing-class-class-for-measure-php-scripts-execution-time-and-php-web-page-load-time/
*/
class Timing {
private $break;
private $start_time;
private $stop_time;
<?php
/**
* Dump MySQL database
*
* Here is an inline example:
* <code>
* $connection = @mysql_connect($dbhost,$dbuser,$dbpsw);
* $dumper = new MySQLDump($dbname,'filename.sql',false,false);
* $dumper->doDump();
* </code>
@sumonst21
sumonst21 / latency.markdown
Created August 14, 2022 00:57 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@sumonst21
sumonst21 / 2019-https-localhost.md
Created August 6, 2022 13:06 — forked from cecilemuller/2019-https-localhost.md
How to create an HTTPS certificate for localhost domains

How to create an HTTPS certificate for localhost domains

This focuses on generating the certificates for loading local virtual hosts hosted on your computer, for development only.

Do not use self-signed certificates in production ! For online certificates, use Let's Encrypt instead (tutorial).