Archive for the ‘Scripting’ Category
Posted by jpluimers on 2020/04/01
It is important to look beyond your own comfort zone to see what other languages can support: [WayBack] Forde’s Tenth Rule, or, “How I Learned to Stop Worrying and ❤ the State Machine”.
The article is about implementing finite state machines in JavaScript with as little usage of string literals as possible.
Via: [WayBack] How I Learned to Stop Worrying and Love the State Machine – Adrian Marius Popa – Google+
–jeroen
Posted in Development, JavaScript/ECMAScript, Scripting, Software Development | Leave a Comment »
Posted by jpluimers on 2020/03/31
Cool example, which requires dnspython and might need an update of the DNS record type list (maybe dnspython has that list built in?):
[WayBack] Printing all DNS records using DNSPython in Python 3 · GitHub
–jeroen
Read the rest of this entry »
Posted in Development, Python, Scripting, Software Development | Leave a Comment »
Posted by jpluimers on 2020/03/25
On Mac OS X with stock Python:
All you need to do is
sudo easy_install pip
After this, you might want to upgrade pip:
sudo pip install --upgrade pip
Source: [WayBack] python – How do I install pip on macOS or OS X? – Stack Overflow
You could go the homebrew way, but that means your system will have two Python installations usually causing a nightmare of path dependency orders. In addition, homebrew puts you on the wrong foot, so:
DO NOT DO THIS!
# brew install pip
Error: No available formula with the name "pip"
Homebrew provides pip via: `brew install python`. However you will then
have two Pythons installed on your Mac, so alternatively you can install
pip via the instructions at:
https://pip.readthedocs.io/en/stable/installing/
–jeroen
Posted in Apple, Development, Mac OS X / OS X / MacOS, macOS 10.12 Sierra, macOS 10.13 High Sierra, Power User, Python, Scripting, Software Development | Leave a Comment »
Posted by jpluimers on 2020/03/17
From [WayBack] bash – How to add a progress bar to a shell script? – Stack Overflow (thanks Mitch Haile!):
You can implement this by overwriting a line. Use \r to go back to the beginning of the line without writing \n to the terminal.
Write \n when you’re done to advance the line.
Use echo -ne to:
- not print
\n and
- to recognize escape sequences like
\r.
Here’s a demo:
echo -ne '##### (33%)\r'
sleep 1
echo -ne '############# (66%)\r'
sleep 1
echo -ne '####################### (100%)\r'
echo -ne '\n'
–jeroen
Posted in *nix, *nix-tools, bash, bash, Development, Power User, Scripting, Software Development | Leave a Comment »
Posted by jpluimers on 2020/03/11
I’ve read this twice and need to re-read this a few times, so from my reading list then need to follow the course one day: Practical Deep Learning for Coders 2018 · fast.ai [WayBack].
… deep learning course based on Pytorch (and a new library we have built, called fastai), with the goal of allowing more students to be able to achieve world-class results with deep learning. … this course, Practical Deep Learning for Coders 2018 [WayBack], … The only prerequisites are a year of coding experience, and high school math (math required for understanding the material is introduced as required during the course).
Related: [WayBack] The Matrix Calculus You Need For Deep Learning – Terence Parr and Jeremy Howard
Via:
–jeroen
Posted in Development, Python, Scripting, Software Development | Leave a Comment »
Posted by jpluimers on 2020/02/19
This is such a cool blog: Mad With PowerShell (Tim Curwick’s PowerShell blog, tips and tricks, tools and techniques, explanations and explorations).
I bumped into it by finding these two:
What I like most is that it gives great insight on how and why the internals of PowerShell work the way they do, and how to use that to your advantage.
–jeroen
Posted in CommandLine, Development, PowerShell, PowerShell, Scripting, Software Development | Leave a Comment »
Posted by jpluimers on 2020/02/18
Excellent answer at [WayBack] linux – Bash: Command grouping (&&, ||, …) – Stack Overflow by Charles Duffy:
Operator precedence for && and || is strictly left-to-right.
Thus:
pwd; (ls) || { cd .. && ls student/; } && cd student || cd / && cd ;
…is equivalent to…
pwd; { { { (ls) || { cd .. && ls student/; }; } && cd student; } || cd /; } && cd ; }
…breaking that down graphically:
pwd; { # 1
{ # 2
{ (ls) || # 3
{ cd .. && # 4
ls student/; # 5
}; # 6
} && cd student; # 7
} || cd /; # 8
} && cd ; # 9
pwd happens unconditionally
- (Grouping only)
ls happens (in a subshell) unconditionally.
cd .. happens if (3) failed.
ls student/ happens if (3) failed and (4) succeeded
- (Grouping only)
cd student happens if either (3) succeeded or both (4) and (5) succeeded.
cd / happens if either [both (3) and one of (4) or (5) failed], or [(7) failed].
cd happens if (7) occurred and succeeded, or (7) occurred and succeeded.
Using explicit grouping operators is wise to avoid confusing yourself. Avoiding writing code as hard to read as this is even wiser.
–jeroen
Posted in *nix, *nix-tools, bash, bash, Development, Power User, Scripting, Software Development | Leave a Comment »