Skip to content

Instantly share code, notes, and snippets.

View ruman's full-sized avatar
:octocat:

Mohammad Mahbubur Rahman ruman

:octocat:
View GitHub Profile
@ruman
ruman / docker-compose.yml
Created June 15, 2023 07:13
Docker Compose file for React APP #nginx #redis #react #mariadb #postgresSQL #network
version: '3.7'
services:
simple_react:
container_name: simple_react
# image: node:11.9.0-alpine
image: node:12.16.2-alpine
volumes:
- type: bind
source: ./
@ruman
ruman / dd.php
Created January 19, 2023 09:34 — forked from james2doyle/dd.php
A implementation of "dump and die" (dd) for WordPress
<?php
if (!function_exists('dd')) {
function dd($data)
{
ini_set("highlight.comment", "#969896; font-style: italic");
ini_set("highlight.default", "#FFFFFF");
ini_set("highlight.html", "#D16568");
ini_set("highlight.keyword", "#7FA3BC; font-weight: bold");
ini_set("highlight.string", "#F2C47E");
@ruman
ruman / wordpress_svg.php
Created September 28, 2022 13:49
Hook for wordpress to allow svg type file
function wp_mime_types($mimes) {
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
add_filter('upload_mimes', 'wp_mime_types');
@ruman
ruman / php_version_switch.md
Last active November 30, 2023 15:46
PHP additional version installation with version switched.

Install PHP version 8.0

In order to install PHP version 8.0, first, open your Ubuntu Terminal and enter the following command in order to add the Ondrej PHP repository to your Ubuntu system (in case you have not done that already in the above chapter to install PHP 5.6).

$ sudo add-apt-repository ppa:ondrej/php

This repository contains all the released versions of PHP till date.

Once the Ondrej repository is added, you need to update your system’s repository with that on the internet. This way you can install the latest available version of a software on your system. Enter the following command in order to do so:

@ruman
ruman / .htaccess
Created September 7, 2022 20:54
Basic .htaccess file for Wordpress
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule "^(.*/)?\.git/" - [F,L]
RedirectMatch 404 /\.git
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
@ruman
ruman / getkeyrange.php
Last active February 25, 2022 09:08
Generate defined ranges of keys to generate unqiue array list
/*
* e.g. A=1 - B=2 - Z=26 - AA=27 - CZ=104 - DA=105 - ZZ=702 - AAA=703
*/
function stringtointvalue($str)
{
$amount = 0;
$strarra = array_reverse(str_split($str));
for ($i = 0; $i < strlen($str); $i++) {
$amount += (ord($strarra[$i]) - 64) * pow(26, $i);
@ruman
ruman / encrypt_decrypt.php
Created January 20, 2022 15:53
Encrypt and Decrypt with single function
<?php
/**
* simple method to encrypt or decrypt a plain text string
* initialization vector(IV) has to be the same when encrypting and decrypting
*
* @param string $action: can be 'encrypt' or 'decrypt'
* @param string $string: string to encrypt or decrypt
*
* @return string
*/
@ruman
ruman / Arisan
Last active December 16, 2021 08:07
artisan.command
Reoptimizing the loader class:
php artisan optimize
Clearing the cache
php artisan cache:clear
php artisan route:cache
php artisan view:clear
Clearing the config cache:
php artisan config:cache
@ruman
ruman / sample-php-headers.php
Created September 9, 2021 00:39 — forked from ScottPhillips/sample-php-headers.php
PHP Header Examples
301 moved permanently (redirect):
<?php
header('HTTP/1.1 301 Moved Permanently');
header('Location: http://www.example.com');
die();
?>
302 moved temporarily(redirect):
<?php
header('Location: http://www.example.com');
@ruman
ruman / functions.php
Created June 2, 2021 16:19 — forked from contemplate/functions.php
WooCommerce - Allow guest checkout for certain products when Guest checkout is Disabled globally
/*--------------------------------------
Woocommerce - Allow Guest Checkout on Certain products
----------------------------------------*/
// Display Guest Checkout Field
add_action( 'woocommerce_product_options_general_product_data', 'woo_add_custom_general_fields' );
function woo_add_custom_general_fields() {
global $woocommerce, $post;
echo '<div class="options_group">';