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 / 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
@sumonst21
sumonst21 / inotifywatch.sh
Created June 17, 2022 22:06
for a client
inotifywait -m ~/public_html -e create -e moved_to -e modify |
while read directory action file; do
if [[ "$file" =~ .*php$ ]] || [[ "$file" =~ .*htaccess$ ]]; then
echo "File $file was $action" >> ~/watch.log
~/watchit.sh
fi
done
#
# 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
@sumonst21
sumonst21 / README.md
Created April 29, 2022 04:51 — forked from goodmami/README.md
Parsing JSON with regular expressions

Parsing JSON with Regular Expressions

When I learned of regular expression engines that support recursion I thought I could write a recursive-descent parser in regex. Since I've written JSON parsers a few times and it's a simple spec, I chose that as the test case. In the end I created two versions.

version 1

@sumonst21
sumonst21 / php_environment_setup_ubuntu.md
Created April 20, 2022 23:47 — forked from linkanp/php_environment_setup_ubuntu.md
PHP 5.6 Development Environment on Ubuntu 16.04

PHP 5.6 Development Environment on Ubuntu 16.04

As a PHP developer on Ubuntu, we may need to re setup our development environment sometimes. I did it already a few times, so decided to write down the steps for a typical php development environment on ubuntu. My Ubuntu version is 16.04.

Installation List