Skip to content

Instantly share code, notes, and snippets.

View akhileshdarjee's full-sized avatar
😉
Unstoppable Today

Akhilesh Darjee akhileshdarjee

😉
Unstoppable Today
View GitHub Profile
@akhileshdarjee
akhileshdarjee / directory_structure.html
Created January 11, 2023 06:50
Directory structure in HTML
<details open="">
<summary>
<i class="bi-folder text-body me-1"></i> <strong>space</strong>
</summary>
<ul class="list-py-1 list-unstyled ps-4">
<li>
<details open="">
<summary>
<i class="bi-folder text-body me-1"></i> <strong>src</strong>
</summary>
@akhileshdarjee
akhileshdarjee / delete_old_git_branches.sh
Created August 31, 2022 14:02
Delete/Remove old Git Branches
#!/bin/bash
##
# Script to delete remote git branches
##
# Fetch the remote resources
git fetch
# Loop through all remote merged branches
@akhileshdarjee
akhileshdarjee / redirect_everything_to_https.txt
Created April 13, 2022 08:36
Let's Encrypt - Redirect everything to HTTPS
Let's Encrypt(Certbot) redirect everything to HTTPS:
1. Run the following command
certbot --apache -d yourdomain.com -d www.yourdomain.com
2. Navigate to your domain Apache2 conf file and scroll to the bottom. You'll see something like this:
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.yourdomain.com [OR]
RewriteCond %{SERVER_NAME} =yourdomain.com
RewriteRule ^ %{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
@akhileshdarjee
akhileshdarjee / string_similarity_percentage.js
Created April 13, 2022 08:31
Similarity Percentage between two strings in Javascript
var str1 = 'Hello World';
var str2 = 'World';
var similarity_percentage = Math.round(similarity(str1, str2) * 10000) / 100;
function similarity(s1, s2) {
var longer = s1;
var shorter = s2;
if (s1.length < s2.length) {
longer = s2;
@akhileshdarjee
akhileshdarjee / laravel_import_excel_calculate_formulas.txt
Created April 13, 2022 08:29
Laravel Import Excel and automatically calculate formulas
Laravel Excel automatically calculates the formulas inside Excel and output result:
use Maatwebsite\Excel\Concerns\WithCalculatedFormulas;
class ExcelImport implements ToCollection, WithCalculatedFormulas
Note:
Replace "ExcelImport" with your class name
@akhileshdarjee
akhileshdarjee / laravel_encrypt_decrypt.php
Last active April 13, 2022 13:03
Laravel Encrypt & Decrypt string
<?php
# Laravel provides a convenient way to encrypt/decrypt a string i.e. encrypt() and decrypt() methods, but the output string is too long.
# It also provides a bcrypt() method where the output string is not lengthy but is not URL friendly.
# Here's a function to encrypt/decrypt a string, which is also URL friendly and the encrypted string length is way small:
/**
* Encrypt & decrypt strings.
*
* Create secret key & iv bu running the following commands
@akhileshdarjee
akhileshdarjee / mysql_password_setup.txt
Last active April 13, 2022 08:34
Setup MySQL password after fresh installation
Set MySQL password after fresh installation:
After fresh installation do not start, restart or stop mysql service. Do not run any commands which will affect MySQL in anyway. Run the below commands as soon as the installation is finished. If the below commands are not working then reinstall MySQL.
1. Login to MySQL
mysql -u root
2. Set Password
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'new_password';
@akhileshdarjee
akhileshdarjee / change_php_version_system_wide.txt
Last active November 30, 2021 07:52
Change PHP version system wide
## Interactive Mode
sudo update-alternatives --config php
sudo update-alternatives --config phar
sudo update-alternatives --config phar.phar
## Manual Mode
Apache (Webserver):
sudo a2dismod php7.4 -> PHP version which is currently enabled `php -v`
@akhileshdarjee
akhileshdarjee / set width and height while dragging object in jquery.js
Created April 22, 2019 14:39
Set width and height while dragging object in jquery
$('body').find('.draggable').draggable({
revert: true,
revertDuration: 0,
stack: ".draggable",
helper: 'clone',
start: function(event, ui) {
$(ui.helper).removeAttr('width');
$(ui.helper).removeAttr('height');
var ele_width = $('body').find('.square').width();