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
@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;
@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).

@sumonst21
sumonst21 / self-signed-certificate-with-custom-ca.md
Created August 6, 2022 12:51 — forked from fntlnz/self-signed-certificate-with-custom-ca.md
Self Signed Certificate with Custom Root CA

Create Root CA (Done once)

Create Root Key

Attention: this is the key used to sign the certificate requests, anyone holding this can sign certificates on your behalf. So keep it in a safe place!

openssl genrsa -des3 -out rootCA.key 4096
@sumonst21
sumonst21 / centos-6-redis-php-session-handler.md
Created July 30, 2022 21:24 — forked from jdeathe/centos-6-redis-php-session-handler.md
CentOS-6 - Redis PHP Session Save Handler
@sumonst21
sumonst21 / monday-for-week.php
Created June 24, 2022 10:13 — forked from stecman/monday-for-week.php
Reliable PHP function to return Monday for week (pre-PHP 7.1)
<?php
/**
* Find the starting Monday for the given week (or for the current week if no date is passed)
*
* This is required as strtotime considers Sunday the first day of a week,
* making strtotime('Monday this week') on a Sunday return the adjacent Monday
* instead of the previous one.
*
* @param string|\DateTime|null $date
#
# Monitor file $1 for changes
# Send an alert emai to $2 if file $1 changes
# usage: inotify_email_watcher.sh /var/log/messages [email protected]
if [ -z "$2" ]; then
echo "Usage: inotify_email_watcher.sh"
exit 1
fi
# if the file exists
if [ -f $1 ] || [ -d $1 ]; then
@sumonst21
sumonst21 / find.sh
Created June 16, 2022 21:07 — forked from jonaslejon/find.sh
Find Trojan Source unicode characters (CVE-2021-42694 and CVE-2021-42574.)
#/bin/sh
# Usage instructions: sh find.sh php|tr '\n' '; '
# Then copy and paste the output and execute it
ext=$1
C="\u200E \u200F \u202A \u202B \u202C \u202D \u202E \u2066 \u2067 \u2068 \u2069 \u202C"
for a in $C; do echo find . -type f -name \"*.$ext\" -exec grep -H \$\'$a\' {} \\\; ; done
@sumonst21
sumonst21 / wwww.domain.com.conf
Created June 11, 2022 03:55 — forked from brian4286/wwww.domain.com.conf
Highly optimized WordPress nginx.conf for security and performance.
server {
listen 80 default_server;
listen [::]:80 default_server;
location / {
return 301 https://www.domain.com$request_uri;
}
}
server {
listen 443 ssl http2;
@sumonst21
sumonst21 / finderrors.ps1
Created June 7, 2022 19:39 — forked from kitmenke/finderrors.ps1
Working in progress: powershell script to automatically fix DCOM errors which show up in the event log
# Get-EvengLog doesn't quite work I guess:
# https://stackoverflow.com/questions/31396903/get-eventlog-valid-message-missing-for-some-event-log-sources#
# Get-EventLog Application -EntryType Error -Source "DistributedCOM"
# The application-specific permission settings do not grant Local Activation permission for the COM Server application with CLSID
#$logs = Get-EventLog -LogName "System" -EntryType Error -Source "DCOM" -Newest 1 -Message "The application-specific permission settings do not grant Local Activation permission for the COM Server application with CLSID*"
# 2 is error
# 3 is warning
$EVT_MSG = "The application-specific permission settings do not grant Local Activation permission for the COM Server application with CLSID"
# Search for System event log ERROR entries starting with the specified EVT_MSG
$logEntry = Get-WinEvent -FilterHashTable @{LogName='System'; Level=2} | Where-Object { $_.Message -like "$EVT_MSG*" } | Select-Object -First 1