Oh, the irony of getting targeted ads for a privacy browser!
`git blast`
If you use my git dev, you may also find git blast useful.
It deletes both local and remote branch of the same name.
The code below is probably old and buggy so best grab the latest from my publicly accessible dotfiles and paste the git dev block into the [alias] section of your ~/.gitconfig file.
Probably buggy WIP code:
; `git blast `
; Delete branch both local and at origin.
blast = "!blast() {\
Y=\"\\033[1;33m\";\
B=\"\\033[1;34m\";\
N=\"\\033[0m\";\
G=\"\\033[1;32m\";\
R=\"\\033[1;31m\";\
\
branch=$1;\
\
[ \"$branch\" = \"master\" ]\
&& printf \"\\n\\t${R}NOPE!\\n\\tNot deleting your master branch!\\n\\tARE YOU MAD?!${N}\\n\\n\"\
&& exit 1;\
\
printf \"\\n${Y}Switching to master${N}\\n\";\
printf \"${B}git checkout master ...${N}\\n\";\
git checkout master;\
\
printf \"\\n${Y}Fetching refs${N}\\n\";\
printf \"${B}git fetch ...${N}\\n\";\
git fetch;\
\
printf \"\\n${Y}Deleting remote branch 'origin/${branch}'${N}\\n\";\
printf \"\\n\\t${G}PEW! PEW!${N}\\n\";\
printf \"\\n${B}git push --delete origin '${branch}' ...${N}\\n\";\
git push --delete origin \"${branch}\";\
\
printf \"\\n${Y}Deleting local branch '${branch}'${N}\\n\";\
printf \"\\n\\t${G}PEW! PEW!${N}\\n\";\
printf \"\\n${B}git branch -D '${branch}' ...${N}\\n\";\
git branch -D \"${branch}\";\
\
printf \"\\n\\t${G} POOF!${N}\\n\\n\";\
};\
blast"
`git dev` – git out of the way and start coding
95% of the time I get started developing by doing one of three things:
- I need to switch to an existing local branch
- I need to make a new local branch that tracks an existing branch
- I need to make a new remote branch and a local one that tracks it
With just a little bit of `.gitconfig` shenanigans, it can be done with a single command that makes the right decisions most most of the time.
`git dev newbranch [frombranch]` will:
- switch to the local `newbranch` if it exists
- create local `newbranch` and track `origin/newbranch` if the latter exists on remote
- create `origin/newbranch` (from `master` or `frombranch` when specified) and local `newbranch` tracking the `origin/newbranch` it.
The code below is probably old and buggy so best grab the latest from my publicly accessible dotfiles and paste the git dev block into the [alias] section of your ~/.gitconfig file.
Most likely out of date snip:
; `git dev` - a shortcut to your dev branch.
;
; USAGE:
; git dev [branch_from | default:master]
;
; FUNCTION:
; if already exists locally:
; switch to the local branch.
; if already exists at origin:
; create a local branch tracking the remote one.
; if it does not:
; create at origin
; and a local one tracking the remote one.
; start dev-ing
dev = "!dev() {\
R=\"\\033[1;31m\";\
G=\"\\033[1;32m\";\
Y=\"\\033[1;33m\";\
B=\"\\033[1;34m\";\
W=\"\\033[1;37m\";\
N=\"\\033[0m\";\
\
newbranch=$1;\
frombranch=$2;\
\
[ \"$newbranch\" = \"master\" ]\
&& printf \"\\n\\t${R}NOPE!\\n\\tNot messing with master branch!\\n\\tARE YOU MAD?!${N}\\n\\n\"\
&& exit 1;\
\
[ -z $frombranch ] && frombranch='master';\
\
[ -z $newbranch ]\
&& printf \"\\n${R}Specify branch name!${N}\\n\"\
&& printf \"\\n${Y}USAGE: git dev '' [branch_from | default:master]${N}\\n\"\
&& printf \"\\n\" && exit 1;\
\
printf \"\\n${Y}Checking if branch '${newbranch}' already exists locally${N}\\n\";\
printf \"${B}git rev-parse --verify '${newbranch}' ...${N}\\n\";\
git rev-parse --verify \"${newbranch}\";\
[ \"$?\" == \"0\" ]\
&& printf \"${R}Found local branch '${newbranch}'${N}\\n\"\
&& printf \"\\n${Y}Switching to local branch '${newbranch}'${N}\\n\"\
&& printf \"${B}git checkout '${newbranch}' ...${N}\\n\"\
&& git checkout \"${newbranch}\"\
&& printf \"\\n${G}You are now on your ${W}ALREADY EXISTING${G} local branch '${newbranch}'\\n\"\
&& printf \"\\nDo your DEVest!${N}\\n\\n\"\
&& exit 0;\
\
printf \"${R}No local branch '${newbranch}' found.${N}\\n\";\
printf \"\\n${Y}Checking if branch '${newbranch}' exists at origin${N}\\n\";\
printf \"${B}git fetch ...${N}\\n\" && git fetch;\
printf \"\\n${B}git ls-remote --heads origin '${newbranch}' ...${N}\\n\";\
alreadythere=$(git ls-remote --heads origin ${newbranch});\
\
[ -z \"$alreadythere\" ]\
&& printf \"${R}No remote branch '${newbranch}' found at origin${N}\\n\"\
&& printf \"\\n${Y}Creating '${newbranch}' locally and at origin by branching from '${frombranch}'${N}\\n\"\
&& printf \"${B}git checkout '${frombranch}' ...${N}\\n\"\
&& git checkout \"${frombranch}\"\
\
&& printf \"\\n${Y}Updating '${frombranch}'\\n\"\
&& printf \"${B}git pull --rebase ...${N}\\n\"\
&& git pull --rebase\
\
&& printf \"\\n${Y}Branching into '${newbranch}' from '${frombranch}'\\n\"\
&& printf \"${B}git checkout -b '${newbranch}' ...${N}\\n\"\
&& git checkout -b \"${newbranch}\"\
\
&& printf \"\\n${Y}Creating '${newbranch}' on remote\\n\"\
&& printf \"${B}git push origin '${newbranch}' ...${N}\\n\"\
&& git push origin \"${newbranch}\"\
\
&& printf \"\\n${Y}Setting '${newbranch}' to track remote\\n\"\
&& printf \"${B}git branch -u 'origin/${newbranch}' ...${N}\\n\"\
&& git branch -u \"origin/${newbranch}\"\
&& printf \"\\n${G}You are now on your ${W}BRAND NEW LOCAL BRANCH${G} '${newbranch}'\\n\"\
&& printf \"\\twhich is tracking a ${W}BRAND NEW${G} 'origin/${newbranch}'\\n\"\
&& printf \"\\t\\twhich was ${W}BRANCHED FROM${G} 'origin/${frombranch}'\\n\"\
&& printf \"\\nDo your DEVest!${N}\\n\\n\"\
&& exit 0;\
\
[ -n \"$alreadythere\" ]\
&& printf \"\\n${Y}Branch '${newbranch}' already exists at origin.\\n\"\
&& printf \"\\nBranching and tracking from 'origin/${newbranch}'\\n\"\
&& printf \"${B}git branch '${newbranch}' --track 'origin/${newbranch}' ...${N}\\n\"\
&& git branch $newbranch --track \"origin/${newbranch}\"\
&& printf \"\\n${Y}Checking out '${newbranch}'${N}\\n\"\
&& printf \"\\n${B}git checkout '${newbranch}' ...${N}\\n\"\
&& git checkout \"${newbranch}\"\
&& printf \"\\n${G}You are now on your ${W}BRAND NEW LOCAL BRANCH${G} '${newbranch}'\\n\"\
&& printf \"\\twhich is tracking an ${W}ALREADY EXISTING${G} 'origin/${newbranch}'\\n\"\
&& printf \"\\nDo your DEVest!${N}\\n\\n\"\
&& exit 0;\
\
};\
dev"
Hope you find it as handy as I have.
Happy DEVing!
Assembly
A non-technical coworker asked me what is “assembly language.”
Analogy to the rescue. My reply:
Assembly Language is a very low level programming language that directly instructs the computer’s processing chip, memory an registers what to do. It’s the closest to hardware programmers ever get.
I’d be surprised if they still teach it in undergrad programs. Most languages used for most purposes today are high level, meaning each instruction translates to a whole lot of more specific assembly instructions.
As an analogy, if you were programming a human to walk, in a higher level language your first instruction might be “right_leg:step_forward,” in assembly you’d start with “motor_cortex:send_electric_charge_down_the_right_sciatic_nerve…”
It’s a whole other level of instruction granularity.
Seemed to make sense to her, so perhaps worth sharing?
“Ding!”
If an ESL student asks you what `ding` means, do not tell them it’s the tintinnabulation onomatopoeia… 🤪
Programmer Productivity Problem
I’ve noticed that my productivity (in terms of code output) functions as a sort of punctuated equilibrium.
It’s not a sinusoid wave, as I had thought, but more of a series of spikes.
I’m analyzing the pattern to see if it can be hacked to fit sprints and deadlines.
There definitely seems to be a coherent pattern to it: Lull->Grok Point->Code Spill.
The `Lull` is the ramp-up period – when I’m trying to put all the requisite knowledge pieces together, understand both the problem and the solution at sufficient granularity. Very little if any code output is seen at this stage.
Eventually all the pieces fall into place and I reach the `Grok Point`, at which the productivity curve suddenly spikes and `boom!` – out spills
lots of code in a short period of time. This is the happiest and most exhilarating part of the process – and I want to get to it sooner each time.
But how?
The greatest obstacle is in managing the lull periods in a smart way.
I tend to overload my brain with too much context at once, which makes it harder and longer to reach the `grok point`. This is a most exhausting and miserable part of the process. Clearly, the solution is to break and let the brain rest awhile as soon as it becomes overwhelmed. But I can’t jump the gun on it either, because too frequent context switching is well known to have a very high cost as well.
So the key to reducing the `lull-to-grok` period seems to be a tightrope dance between burnout and context-switch.
The trouble is that it’s not at all evident when my brain gets overloaded. It creeps up on me. I’m not sure *how* to “be mindful” of my cortex capacity and identify the moment it overloads. This “mindfulness” is itself a datum maintained in the prefrontal cortex, and thus a subject to blowout when overload occurs.
More research is needed.
I’m Outraged Ergo Sum.
– A footnote for our times
Being wrong is hard
Do you have the stomach to change your mind?
Best Opening Quote – The Martian
I’m pretty much fucked.
#BestOpeningQuote
#Quote
Quote – The Leviathan
“Life is but a motion of limbs.”
– Thomas Hobbes