Skip to content

Instantly share code, notes, and snippets.

View fmtarif's full-sized avatar

Faisal Muhammad fmtarif

View GitHub Profile
@fmtarif
fmtarif / js-tricky-bits.md
Created July 2, 2024 20:06 — forked from amysimmons/js-tricky-bits.md
Understanding closures, callbacks and promises in JavaScript

#Understanding closures, callbacks and promises

For a code newbie like myself, callbacks, closures and promises are scary JavaScript concepts.

10 months into my full-time dev career, and I would struggle to explain these words to a peer.

So I decided it was time to face my fears, and try to get my head around each concept.

Here are the notes from my initial reading. I'll continue to refine them as my understanding improves.

@fmtarif
fmtarif / random_codes.php
Last active June 25, 2024 18:52
#php Generate a random code with pre-defined length and characters PHP
<?php
echo random_code(6); //E4QGR9
echo PHP_EOL;
echo random_digits(6); //610470
echo PHP_EOL;
echo random_chars(6); //XBRBDH
echo PHP_EOL;
@fmtarif
fmtarif / composer.json
Created June 4, 2022 08:25 — forked from secrethash/composer.json
Laravel Helper Function to create a Unique slug based on Provided Model Instance. Save 'slugify_model.php' in your 'app/Helpers/' directory and update your composer.json to reference and autoload the helper function.
{
...
"autoload": {
"psr-4": {
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
},
"files": [
...
@fmtarif
fmtarif / deploy_ee.sh
Last active April 12, 2022 18:42
#bash take a php project git repo and deploy it in containers using easyengine (ee)
#!/bin/bash
#take a php project git repo and deploy it in containers using easyengine (ee)
set -e
domain="test.host.com"
app_path="/opt/easyengine/sites/${domain}/app/htdocs"
gitrepo="https://repo_url"
doc_root_realive_to_app_path="repo/src/public"
@fmtarif
fmtarif / .htaccess
Created July 29, 2021 16:39
#htaccess basic htaccess content
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.html [L]
@fmtarif
fmtarif / index.sh
Created July 25, 2021 08:37
#scripts #cli #devops a local script to keep within project dir in git and run ssh cmds remotely
#! /usr/bin/env bash
DIR="$( dirname "$_" )"
DIR=${DIR/\./} #if script invoked like ./index then remove the dot
commands=("sshprod", "sshproddeploy")
echo ${commands[@]}
@fmtarif
fmtarif / bkash_total_received.php
Last active July 15, 2021 17:13
#php Bkash - Parse number of bkash messages and get total received amount
<?php
//messages.txt sample content
/*
You have received Tk 800.00 from 0199999999.Ref XYZ. Fee Tk 0.00. Balance Tk 0.00. TrxID XYZABC at 15/07/2021 11:00
You have received deposit from iBanking of Tk 1,000.00 from Eastern Bank Limited Internet Banking. Fee Tk 0.00. Balance Tk 0.00. TrxID XYZABC at 14/07/2021 16:43
Cash In Tk 3,260.00 from 0199999999 successful. Fee Tk 0.00. Balance Tk 0.00. TrxID XYZABC at 14/07/2021 20:19. Download App: https://bKa.sh/8app
*/
@fmtarif
fmtarif / debug.css
Created July 2, 2021 20:36
Debug CSS layouts - Adds outline to elements
/* from https://www.freecodecamp.org/news/heres-my-favorite-weird-trick-to-debug-css-88529aa5a6a3/ */
*:not(path):not(g) { color: hsla(210, 100%, 100%, 0.9) !important; background: hsla(210, 100%, 50%, 0.5) !important; outline: solid 0.25rem hsla(210, 100%, 100%, 0.5) !important; box-shadow: none !important;}
@fmtarif
fmtarif / eedeploy.sh
Created June 24, 2021 19:14
#cli #bash #server take a php project git repo and deploy it in containers using easyengine (ee)
#!/bin/bash
#take a php project git repo and deploy it in containers using easyengine (ee)
set -e
domain="example.com"
app_path="/opt/easyengine/sites/${domain}/app/htdocs"
gitrepo="https://github.com/laravel/laravel.git"
doc_root_realive_to_app_path="public"
@fmtarif
fmtarif / unique-random.php
Created June 19, 2021 22:22
#php generate unique random numbers within a range
<?php
//https://stackoverflow.com/a/24493651
function unique_randoms($min, $max, $count) {
$arr = array();
while(count($arr) < $count){
$tmp =mt_rand($min,$max);
if(!in_array($tmp, $arr)){
$arr[] = $tmp;
}