Skip to content

Instantly share code, notes, and snippets.

View bastami82's full-sized avatar

Ben Bastami bastami82

View GitHub Profile
@bastami82
bastami82 / git
Created October 18, 2024 10:54
How to create a new orphan branch from existing repository (where new branch does not have former git commits history)
git checkout --orphan <new-local-branch-name>
git add .
it commit -m "init commit - with no git history"
optional push to `origin` :
git push -u origin main // this will track new-local-branch-name with origin/main
@bastami82
bastami82 / cloneAllBranchesFromGitRepoCommand.txt
Last active September 5, 2020 17:05
clone all branches of git repository
git branch -a | grep -v HEAD | perl -ne 'chomp($_); s|^\*?\s*||; if (m|(.+)/(.+)| && not $d{$2}) {print qq(git branch --track $2 $1/$2\n)} else {$d{$_}=1}' | csh -xfs
@bastami82
bastami82 / Vim basic commands
Last active June 11, 2020 08:11
reminder of Vim commands to prevent me google it every time !
There are two Modes: Insert and Command:
1. to go o Insert mode -> Press `i`
2. to switch back to Command mode -> pres `esc`
x - to delete the unwanted character
u - to undo the last the command and U to undo the whole line
CTRL-R to redo
A - to append text at the end
@bastami82
bastami82 / gist:ef5987b79353978223b74257f42c09c9
Last active April 4, 2018 07:06
set drwabale icon backward compatible
import android.support.v7.content.res.AppCompatResources;
THE_VIEW.setBackgroundDrawable(AppCompatResources.getDrawable(ctx, R.drawable.ic_report_review);
//with drwable left
THE_VIEW.setCompoundDrawablesWithIntrinsicBounds(AppCompatResources.getDrawable(ctx, R.drawable.ic_report_review), null, null, null);
@bastami82
bastami82 / androidHandlerRecursiveChecker.java
Created January 3, 2018 11:55
using Android handler as a timer to check a condition
private Runnable runnable;
private Handler handler;
private boolean condition;
runnable = () -> {
if (condition) {
handler.removeCallbacks(runnable); //stop handler
} else {
handler.postDelayed(runnable, 500); //check a condition every half a second (until condition is met)