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
# ----------------------------------------------------------------------
# Expires headers (for better cache control)
# ----------------------------------------------------------------------
# These are pretty far-future expires headers.
# They assume you control versioning with filename-based cache busting
# Additionally, consider that outdated proxies may miscache
# www.stevesouders.com/blog/2008/08/23/revving-filenames-dont-use-querystring/
# If you don't use filenames to version, lower the CSS and JS to something like
@sumonst21
sumonst21 / regform-notemplate.php
Created October 3, 2022 20:00 — forked from mhawksey/regform-notemplate.php
Embedding and customising a Google Form (with dynamic parallel session selection)
<?php
$formKey = "blahblahblah"; // ENTER YOUR OWN VALUE - you can find your formkey by going to your live form in the spreadsheet and copying the value from the url
$redirectUrl = "http://www.yoursite.com/thank-you/"; // ENTER YOUR OWN VALUE - the url you want to direct people to after they fill in the form
$dataUrl = "https://spreadsheets0.google.com/spreadsheet/pub?blahblahblah&single=true&gid=1&output=csv"; // ENTER YOUR OWN VALUE - for parallel sessions you need to publish the public sheet via the share settings. This url is not published in the live webpage source
// function to get external webpages/data
function getData($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
@sumonst21
sumonst21 / php_form_submit.md
Created October 3, 2022 13:08 — forked from jesperorb/php_form_submit.md
PHP form submitting with fetch + async/await

PHP Form submitting

If we have the following structure in our application:

  • 📁 application_folder_name
    • 📄 index.php
    • 📄 handle_form.php
    • 📄 main.js

And we fill our index.php with the following content just to get a basic website with a form working. You should be able to run this through a php-server of your choice.

@sumonst21
sumonst21 / clutch.php
Created October 3, 2022 13:08 — forked from kn0ll/clutch.php
an asynchronous http library for php.
<?php
namespace clutch;
class Request {
/**
* The url of the request
* @var string
*/
public $url;
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