Skip to content

Instantly share code, notes, and snippets.

View nasirkhan's full-sized avatar
🚀
Focusing

Nasir Khan Saikat nasirkhan

🚀
Focusing
View GitHub Profile
@nasirkhan
nasirkhan / comand.markdown
Last active April 10, 2024 16:56
Git, Github -- Keep a file in the project but do not track the changes.

Sometimes we need to keep a file in the project but do not want to track the changes, for example the config/configuration file or other setting file.

git has a solution to do this. First change the file you do not want to be tracked and use the following command.

git update-index --assume-unchanged FILE_NAME

and if you want to track the changes again use this command,

@nasirkhan
nasirkhan / zip-split-unzip.md
Last active December 21, 2023 16:26
Split a Zip file and combine and unzip next linux

You have existing.zip but want to split it into 50M sized parts.

zip existing.zip --out new.zip -s 50m

will create

new.zip
@nasirkhan
nasirkhan / auto-deploy.php
Last active December 5, 2023 16:47
Deploy to Production Server with Git Webhook using PHP. Configure a Webhook, push to repository and new code will be deployed automatically. Tested with Github, Gitlab webhook auto triggers.
<?php
/**
*
* GIT AUTO DEPLOYMENT SCRIPT
*
* GITHUB? GITLAB webhook
* -------------------------------
*
*/
@nasirkhan
nasirkhan / bengali2english.php
Created March 26, 2014 07:41
Convert a Bengali (Bangla) Number to English Number
/**
*
* Input any number in Bengali and the following function will return the English number.
*
*/
function bn2enNumber ($number){
$search_array= array("১", "২", "৩", "৪", "৫", "৬", "৭", "৮", "৯", "০");
$replace_array= array("1", "2", "3", "4", "5", "6", "7", "8", "9", "0");
$en_number = str_replace($search_array, $replace_array, $number);
@nasirkhan
nasirkhan / laravel-controller-method-commands.php
Last active March 31, 2023 04:11
Call Laravel Controller methods via command line
<?php
php artisan tinker
$controller = app()->make('App\Http\Controllers\MyController');
app()->call([$controller, 'myMethodName'], []);
//the last [] in the app()->call() can hold arguments such as [user_id] => 10 etc'
@nasirkhan
nasirkhan / git command.markdown
Last active May 12, 2022 03:17
`git` discard all local changes/commits and pull from upstream

git discard all local changes/commits and pull from upstream

git reset --hard origin/master

git pull origin master

@nasirkhan
nasirkhan / www-html-file-permission-fix.md
Last active December 29, 2021 08:01
Correct permissions for /var/www and laravel wordpress

First, you should ensure that your username is included in www-data group. If not, you can add your username as www-data group

sudo adduser $USER www-data

After that, you should change the ownership of /var/www to your username

sudo chown $USER:www-data -R /var/www

Next step, you should change permission to 755 (rwxr-xr-x), not recommend changing permission to 777 for security reason

# initialization file (not found)
@nasirkhan
nasirkhan / remove_file_extension.sh
Last active October 7, 2021 15:17
Remove file extension using the linux shell script
```
#!/bin/sh
for file in `ls *.html`
do
newname=`echo $file|sed 's/\.html$//g'`
mv $file $newname
done
```
@nasirkhan
nasirkhan / Envoy.blade.php.md
Last active August 3, 2021 13:43
Deploying with Envoy

SSH Keys

SSH keys provide a more secure way of logging into a virtual private server with SSH than using a password alone. While a password can eventually be cracked with a brute force attack, SSH keys are nearly impossible to decipher by brute force alone. Generating a key pair provides you with two long string of characters: a public and a private key. You can place the public key on any server, and then unlock it by connecting to it with a client that already has the private key. When the two match up, the system unlocks without the need for a password. You can increase security even more by protecting the private key with a passphrase.

https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-keys--2

Step One—Create the RSA Key Pair

The first step is to create the key pair on the client machine (there is a good chance that this will just be your computer):