Modern shell #scripting is weird. :P #programming #bash #linux
#!/usr/bin/env bash
function parse_options () {
declare -n result="$1"
shift 1
result['verbosity']='4'
result['memory']='24G'
result['volumes']=''
result['device']='/dev/st0'
result['write-rate']='250M'
local opt
local OPTARG
while getopts 'vm:n:i:' opt
do
case $opt in
v)
result['verbosity']=6
;;
m)
result['memory']="$OPTARG"
;;
n)
result['volumes']="$OPTARG"
;;
i)
result['device']="$OPTARG"
;;
r)
result['write-rate']="$OPTARG"
;;
esac
done
if [[ -z "${result['volumes']}" ]]; then
echo "-i VOLUMES is required"
exit 1
fi
return 0
}
declare -A CONFIG
parse_options CONFIG "$@" || exit 1
exec mbuffer \
-v "${CONFIG['verbosity']}" \
-m "${CONFIG['memory']}" \
-n "${CONFIG['volumes']}" \
-p 30 \
-s 65536 \
-A 'sh /usr/local/bin/tape_wait.sh' \
-f \
-R "${CONFIG['write-rate']}" \
-i "${CONFIG['device']}"
like this
reshared this
Doesn't using an #LLM to create large portions of your codebase mean that you end up with a lot of code that nobody understands unless they put in the time to go through it and learn what it's doing? If so, it's not much different from writing the code from scratch in the long one. :/
(Yes, I know about boilerplate and do think that's a valid use case as long as you know what the boilerplate is doing.)
like this
Neil E. Hodges likes this.
Had quite the time working on a personal project recently. It changed my life forever.
- Learned the hard way that the (default on most POSIX)
fork
context is bad news. - Wrote a Unix domain datagram based log infrastructure.
- Wrote an algorithm that operates kind of like
concurrent.futures.as_completed()
, except it has a priority queue and doesn't eagerly load the list of futures. - Discovered that it's possible to overload
concurrent.futures.ProcessPoolExecutor
with futures, preventing any actual background processing after a point. - Got TONS of practice optimizing stuff for large datasets.
- Learned that taking breaks is important for reasons than most people are aware of.
- My life was permanently altered by this project. I basically nerd-sniped myself.
like this
Tech Cyborg reshared this.
This whole mess got me thinking seriously about learning #Kotlin, since it would eliminate needing to use IPC to make use of multiple CPU cores. (Yes, I actually like the #JVM, but don’t want to boilerplate myself to death with #Java. :P )
I’ll probably still look into learning Kotlin, but not for this project.
Christoph S likes this.
PEP 703 – Making the Global Interpreter Lock Optional in CPython
CPython’s global interpreter lock (“GIL”) prevents multiple threads from executing Python code at the same time. The GIL is an obstacle to using multi-core CPUs from Python efficiently. This PEP proposes adding a build configuration (--disable-gil
) to CPython to let it run Python code without the global interpreter lock and with the necessary changes needed to make the interpreter thread-safe.
#python #programming #gil
dieter_wilhelm likes this.
Andrew Sterian reshared this.
csv.writer.writerow()
and one of the strings (not bytes) in the row contains a null character in it, and you are using a csv.Dialect
with escapechar
set to None
, it will result in this condition evaluating to true when it shouldn't. That will almost immediately result in the need to escape, but no escapechar set
exception being thrown. #programminglike this
reshared this
like this
Of course current so-called "AI"s are all trained by reading lots of code, so it may also be possible to argue that nothing they produce can really be claimed to be truly "clean room" creations, even though technically the way they work pretty much can't copy any actual code (or anything else) from their training materials.
like this
I miss the simplicity of the early Web.
dieter_wilhelm likes this.
@contextmanager
def func(…):
resource = …
try:
yield resource
finally:
…
#programming
like this
reshared this
Greg A. Woods likes this.
Neil E. Hodges likes this.
Neil E. Hodges likes this.
The release notes for 10.15 (when it was first deprecated) do say:
Scripting language runtimes such as Python, Ruby, and Perl are included in macOS for compatibility with legacy software. Future versions of macOS won’t include scripting language runtimes by defaultThe same appears in the Xcode 11 release notes.
They don't say what specific "legacy software" they refer to though.
Neil E. Hodges likes this.
like this
reshared this
- Fediverse.Party - explore federated networks
Let's make social media free, federated and fun! Fediverse.Party is your guide into the world of decentralized, autonomous networks running on free open software on a myriad of servers across the world. No ads and no algorithms.fediverse.party
Neil E. Hodges likes this.
Neil E. Hodges likes this.
Neil E. Hodges likes this.
Any ideas on a JSON → Java code generator for the AP object boilerplate?
Neil E. Hodges likes this.
GitHub - jediverse/coruscant
Contribute to jediverse/coruscant development by creating an account on GitHub.GitHub
Neil E. Hodges likes this.
Neil E. Hodges reshared this.
I can handle the polymorphism, but I still won't have time until the weekend.
But I would probably want to design a new protocol from scratch first.
like this
dieter_wilhelm likes this.
like this
Neil E. Hodges likes this.
These days, a lot of the time I end up putting together my own answers from the source code and API reference.
Neil E. Hodges likes this.
like this
like this
CLR Assembly RegEx Functions for SQL Server by Example
Phil Factor presents a simple CLR Assembly to allow SQL Server users to access all the powerful RegEx library methods in .NET.Phil Factor (Simple Talk)
Neil E. Hodges likes this.
like this
https://www.reddit.com/r/java/comments/ypg8bl/comment/ivjed8w/
r/java - Comment by u/pron98 on ”Understanding Java's Project Loom”
173 votes and 24 comments so far on Redditreddit
Neil E. Hodges likes this.
like this
I haven't been uploading a couple of big trips' worth of #photos because I've been working on a new tag editor. With it, I won't need to mess around with #Flickr's uploading UI as much. (Photo)
I wrote it in #Java since it's what I've been writing the most because of work. As much as people love to hate on it, there are a number of things I like about Java 8+. #photography #programming #photog
like this
Stephane L Rolland-Brabant ⁂⧖⏚
in reply to Neil E. Hodges • • •thanks, I am not sure I ever used declare -n , but that is pretty nice to know. I have to experiment with it
Do you have any advise/warning about it? Seems like a huge step to introduce something resembling references into #bash
headrift
in reply to Neil E. Hodges • • •😀🚲
in reply to Neil E. Hodges • • •Greg A. Woods
in reply to Neil E. Hodges • • •Buffers? I see no buffers. It's a relatively trivial little script to translate one command-line API into another. I would use
typeset
instead ofdeclare
to make it portable to Korn Shell, and get rid of the unnecessarylocal OPTARG
. I would get rid of the unnecessary local-reference trick withresult
-- it is not a sin to modify a well named global variable in a shell script. It could easily be translated into entirely POSIX-compatible syntax by using multiple global variables.As for using another language, well that would be both silly, and far more complex. The shell is always already there and quite capable.
Neil E. Hodges likes this.