Skip to content

Instantly share code, notes, and snippets.

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

Masiur Rahman Siddiki masiur

💭
I may be slow to respond.
View GitHub Profile
@masiur
masiur / oracle_cloud.md
Created March 15, 2024 17:52
Oracle iptable/firewall allow after first setup

Run This command sudo iptables -I INPUT 6 -m state --state NEW -p tcp --dport 8443 -j ACCEPT

@masiur
masiur / build.sh
Last active January 15, 2024 20:51
wordpress plugin build bash
#!/bin/bash
# Function to handle copying and compressing
copy_and_compress() {
local source_dir="$1"
local destination_dir="$2"
local copy_list=("${@:3}")
# Delete existing files in the destination directory
rm -rf "$destination_dir"
@masiur
masiur / self-vs-static.php
Created July 11, 2023 06:10 — forked from AaronFlower/self-vs-static.php
What is the difference between new self and new static?
<?php
/**
* What is the difference between new self and new static?
* self refers to the same class in which the new keyword is actually written.
*
* static, in PHP 5.3's late static bindings,
* refers to whatever class in the hierarchy you called the method on.
*
* In the following example, B inherits both methods from A.
* The self invocation is bound to A because it's defined in A's implementation
@masiur
masiur / array_splice.php
Last active October 19, 2022 19:33
swap between php array (move to left ) using splice
<?php
// take out the target element from array, $key is the target element index number , 1 means 1 element
$arraySpliced = array_splice($stages, $key, 1);
// adding the spliced element to the previous index of $key and 0 means extract or slice no element.
$arraySpliced = array_splice($stages, $key-1, 0, $arraySpliced);
@masiur
masiur / move_array_elem.js
Created October 18, 2022 08:04
Javascript move left/right of elements in array
let stage='completed';
this.statuses = ['open', 'in-progress', 'completed'];
let index = this.statuses.indexOf(stage);
if (direction === 'left') {
if (index > 0) {
this.statuses.splice(index, 1);
this.statuses.splice(index - 1, 0, stage);
}
} else if (direction === 'right') {
if (index < this.statuses.length - 1) {
@masiur
masiur / apache_proxy
Created June 19, 2021 12:10
Apache Proxy and reverse proxy
<VirtualHost *:*>
ProxyPreserveHost On
# Servers to proxy the connection, or;
# List of application servers:
# Usage:
# ProxyPass / http://[IP Addr.]:[port]/
# ProxyPassReverse / http://[IP Addr.]:[port]/
# Example:
ProxyPass / http://0.0.0.0:8080/
@masiur
masiur / lara_deploy.sh
Last active October 15, 2020 20:10
bug fixed
#!/bin/bash
echo "Domain name eg. example.com:"
read domain_name
sudo mkdir -p /var/www/html/$domain_name
sudo chown -R $USER:$USER /var/www/html/$domain_name
cd /var/www/html/$domain_name
read -p 'Git Repo Full Url:' git_url
@masiur
masiur / apache domain config.md
Last active June 8, 2020 08:41
apache redirectin www/non-www to www with https

Written with StackEdit.

/etc/apache2/sites-available/example.com.conf

<VirtualHost *:80>
    ServerName www.example.com
    ServerAlias example.com
    RedirectMatch permanent ^/(.*) https://www.example.com/$1
</VirtualHost>
@masiur
masiur / index.php
Created August 8, 2018 10:51
laravel redirect to public folder
<?php
$url = 'http://' . $_SERVER['HTTP_HOST']; // Get the server
$url .= rtrim(dirname($_SERVER['PHP_SELF']), '/\\'); // Get the current directory
$url .= '/public/'; // <-- Your relative path
header('Location: ' . $url, true, 302);
?>
@masiur
masiur / adminer_nginx_config
Last active August 30, 2018 08:04
Adminer nginx configuration
server {
listen 51;
listen [::]:51;
root /var/www/html;
index db.php;
location / {
try_files $uri $uri/ /index.php?$query_string;