Skip to content

Instantly share code, notes, and snippets.

View 4msar's full-sized avatar
🧑‍💻
Working...

Saiful Alam Rakib 4msar

🧑‍💻
Working...
View GitHub Profile
@4msar
4msar / iframe.tsx
Created February 19, 2024 09:39
Render React Component to Iframe
import React, { useRef } from "react"
import { createPortal } from "react-dom"
export const IFrame = ({
children,
title,
...props
}: HTMLAttributes<HTMLIFrameElement> & {
children: React.ReactNode
}) => {
@4msar
4msar / console.php
Created October 13, 2023 19:28
Simple laravel Artisan command
<?php
use Illuminate\Foundation\Inspiring;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\DB;
// inspire with random qoutes
Artisan::command('inspire', function () {
$this->comment(Inspiring::quote());
})->purpose('Display an inspiring quote');
@4msar
4msar / DataHelper.php
Last active August 19, 2023 20:20
PHP Object Array Helper
<?php
namespace App\Helpers;
class DataHelper implements \ArrayAccess
{
/**
* Where the data is stored
*
* @var array
@4msar
4msar / nginx-server-block-generator.sh
Created August 1, 2022 05:46 — forked from 0xAliRaza/nginx-server-block-generator.sh
A handy shell script to create Nginx server-block (virtual host).
#!/usr/bin/env bash
#
# Nginx - new server block
# Functions
ok() { echo -e '\e[32m'$1'\e[m'; } # Green
die() {
echo -e '\e[1;31m'$1'\e[m'
exit 1
}
@4msar
4msar / script.js
Created May 31, 2022 09:18
Determine the browser window is visible or not
(function(callback) {
var hidden = "hidden";
// Standards:
if (hidden in document)
document.addEventListener("visibilitychange", onchange);
else if ((hidden = "mozHidden") in document)
document.addEventListener("mozvisibilitychange", onchange);
else if ((hidden = "webkitHidden") in document)
document.addEventListener("webkitvisibilitychange", onchange);
@4msar
4msar / WpParser.php
Created March 20, 2022 08:40
Wordpress Export: Parse the WP exported xml file
<?php
namespace App\Helpers\Import;
/**
* WordPress exported XML Parser class for managing parsing of XML files.
* This class is cloned from the link below with partially modified.
* https://github.com/wecodemore/wp-importer
*/
class WpParser
@4msar
4msar / conventional_commit_messages.md
Created January 26, 2022 11:04 — forked from qoomon/conventional_commit_messages.md
Conventional Commit Messages

Conventinal Commit Messages

See how a minor change to your commit message style can make a difference. Examples

Have a look at CLI util git-conventional-commits to ensure this conventions and generate changelogs

Commit Formats

Default

@4msar
4msar / php-style-guide.md
Created February 17, 2021 18:44 — forked from ryansechrest/php-style-guide.md
PHP style guide with coding standards and best practices.

PHP Style Guide

All rules and guidelines in this document apply to PHP files unless otherwise noted. References to PHP/HTML files can be interpreted as files that primarily contain HTML, but use PHP for templating purposes.

The keywords "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.

Most sections are broken up into two parts:

  1. Overview of all rules with a quick example
  2. Each rule called out with examples of do's and don'ts
@4msar
4msar / AdbCommands
Created December 6, 2020 15:52 — forked from Pulimet/AdbCommands
Adb useful commands list
adb help // List all comands
== Adb Server
adb kill-server
adb start-server
== Adb Reboot
adb reboot
adb reboot recovery
adb reboot-bootloader
@4msar
4msar / districts.php
Created March 5, 2020 16:15
Bangladesh District List With Police Stations
<?php
return [
"Bagerhat"=>[
"BagerhatSadar",
"Chitalmari",
"Fakirhat",
"Kachua",
"Mollahat",
"Mongla",