Skip to content

Instantly share code, notes, and snippets.

View M-Razavi's full-sized avatar
🏹
Focusing

Mahdi Razavi M-Razavi

🏹
Focusing
View GitHub Profile
# Delete all local branches but keeping others like "develop" and "master":
git branch | grep -v "develop" | grep -v "master" | grep -v "main" | xargs git branch -D
@M-Razavi
M-Razavi / create-a-chrome-git-hub-search-shortcut.md
Last active March 16, 2023 14:11
Create a Chrome GitHub Search Shortcut

Create a Chrome search shortcut for your GitHub

If you only want to search in a specific repository, follow the Instruction-1 that David tweeted Winterbottom. For searching in whole repositories of organiation/user follow the Instruction-2

Instructions-1: search in a specific repository

  1. Open Chrome > Settings
  2. Search "manage search engines" and click into it
@M-Razavi
M-Razavi / Search in multiline (REGEX)
Created December 10, 2021 17:12
Search in multiline (REGEX)
\bWORDA[\s\S]*?WORDB
\bWORDA[\s\S]*?WORDB(?=[\r\n])
mvn clean install -DskipITs=true -DskipTests=true
@M-Razavi
M-Razavi / init.sh
Last active July 6, 2021 13:28 — forked from ocindev/init.sh
Convenient script to setup a WSL dev environment with Docker, sdkman.io, Maven, AdoptOpenJDK 1.8, NPM and Node.js
# Replace with your windows username
win_user=<replace>
# Update the apt package list.
sudo apt-get update -y
# Install Docker's package dependencies.
sudo apt-get install -y \
apt-transport-https \
ca-certificates \
UBUNTU:
SSD:
sudo apt install nvme-cli
sudo nvme smart-log /dev/nvme0
# check percentage_used %
Memory:
1-Turn On or Restart the system
2-Hold down Shift to bring up the GRUB menu.
3-Use the arrow keys to move to the entry labeled Ubuntu, memtest86+
@M-Razavi
M-Razavi / getCompileTime.java
Created July 10, 2019 05:45
Java print time of last compilation
private static final Date buildDate = getClassBuildTime();
/**
* Handles files, jar entries, and deployed jar entries in a zip file (EAR).
* @return The date if it can be determined, or null if not.
*/
private static Date getClassBuildTime() {
Date d = null;
Class<?> currentClass = new Object() {}.getClass().getEnclosingClass();
URL resource = currentClass.getResource(currentClass.getSimpleName() + ".class");
; commands separated by a ; are executed sequentially. The shell waits for each command to terminate in turn.
&& command after && is executed if, and only if, command before && returns an exit status of zero. You can think of it as AND operator.
| a pipe. In expression command1 | command2 The standard output of command1 is connected via a pipe to the standard input of command2.
There are more similar control operators, worth to mention:
@M-Razavi
M-Razavi / sbt-utilities
Created June 24, 2019 13:30 — forked from joesan/sbt-utilities
Ignore Tests when Running SBT
sbt 'set test in Test := {}' clean assembly
#!/bin/bash
#algorithm from jdf project(a calender convertor for php.)
#day,month,year and other english var used for miladi and sal mah rooz and ... used for jalali.
#-h (help) -f(farsi) -d(special date) -s (spliter character) and without option we use finglish and print curent date.
#default spliter(delimiter) character is "-"
#although -s suport string but recomended using a character.
date=$(date "+%Y-%m-%d") #set default date