Found on https://victorzhou.com/ (which has very good content), and reminded me of those "FREE BEER" banners
jueves, 11 de abril de 2019
miércoles, 10 de abril de 2019
bypass zsh commands in bash
Here's a small trick I came out with, when trying to run some scripts that were thought for zsh in bash.
I use 'noglob' in many places, and sometimes they leak into my bash scripts, or are called from bash somehow. As bash doesn't know about noglob, usual result is an error.
But! you can use this
cat <<-EOF >~/bin/noglob
#!/usr/bin/env bash
$*
EOF
So a bypass file is called in case the command 'noglob' is not catched by the shell.
EDIT: Now I remember why the f I created this.
You know I'm a heavy user of zsh's global aliases. my aliases that contain pipes are always UPPERCASE, because it gives a hint that something strange is happening there, and I also see it entering the realm of pipes.
The thing is that when pairing with others, if I write that when they are looking, people have no clue what's happening when I type that, and it's pretty unintuitive. Also, as my zsh and bash share part of the history, if I reach some command that contains one of the magic aliases, I've to manually fix them by expanding by hand.
1st fix: magic expansions
This expands the previous word if it's an alias, but I only want to expand the ones that are ALL CAPSLOCK. Because I have very nasty aliases I don't want to expand as I go. (This has extra an benefit of allowing expansions of "dynamic aliases", which I'll show in some other post)
With this, I end up with noglobs scattered around my history, and if for some reason I execute those in bash, it'll try to run `noglob http ....`. Here is where ~/bin/noglob works fine by just bypassing everything.
I use 'noglob' in many places, and sometimes they leak into my bash scripts, or are called from bash somehow. As bash doesn't know about noglob, usual result is an error.
But! you can use this
cat <<-EOF >~/bin/noglob
#!/usr/bin/env bash
$*
EOF
So a bypass file is called in case the command 'noglob' is not catched by the shell.
EDIT: Now I remember why the f I created this.
You know I'm a heavy user of zsh's global aliases. my aliases that contain pipes are always UPPERCASE, because it gives a hint that something strange is happening there, and I also see it entering the realm of pipes.
The thing is that when pairing with others, if I write that when they are looking, people have no clue what's happening when I type that, and it's pretty unintuitive. Also, as my zsh and bash share part of the history, if I reach some command that contains one of the magic aliases, I've to manually fix them by expanding by hand.
1st fix: magic expansions
globalias() {
if [[ $LBUFFER =~ ' [A-Z0-9]+$' ]]; then
zle _expand_alias
zle expand-word
fi
zle self-insert
}
zle -N globalias
bindkey " " globalias
This expands the previous word if it's an alias, but I only want to expand the ones that are ALL CAPSLOCK. Because I have very nasty aliases I don't want to expand as I go. (This has extra an benefit of allowing expansions of "dynamic aliases", which I'll show in some other post)
With this, I end up with noglobs scattered around my history, and if for some reason I execute those in bash, it'll try to run `noglob http ....`. Here is where ~/bin/noglob works fine by just bypassing everything.
sábado, 16 de marzo de 2019
Dan Ingalls showing smalltalk magic
- https://www.youtube.com/watch?v=NqKyHEJe9_w
- https://www.youtube.com/watch?v=4ki2AQvneD8
- https://www.youtube.com/watch?v=Ao9W93OxQ7U
- https://www.youtube.com/watch?v=if72CFsF_SY
jueves, 14 de marzo de 2019
dark mode for slack on mobile
So apparently slack app provides a way for a dark mode.
https://smartphones.gadgethacks.com/how-to/get-dark-mode-slack-your-iphone-android-phone-0194709/
https://smartphones.gadgethacks.com/how-to/get-dark-mode-slack-your-iphone-android-phone-0194709/
miércoles, 6 de marzo de 2019
emms ftw
I never got into the Emacs MultiMedia System, but just read that it has support for streaming radios so I gave it a try. And you know what? It's awesome. I'm adding all the radios I have in my radios repo.
But you already knew that.
Only a few concepts/commands:
- m-x emms-streams RET
- m-x emms RET
- c-+ + + +
- m-x emms-add-dired RET
Enough to get by and start using it.
But you already knew that.
Only a few concepts/commands:
- m-x emms-streams RET
- m-x emms RET
- c-+ + + +
- m-x emms-add-dired RET
Enough to get by and start using it.
martes, 19 de febrero de 2019
FP vs OO talk
Here's a quite balanced talk about FP and OO that fits my view of the two paradigms. Give it a shot if you have 40mins on your commute or something.
https://www.reddit.com/r/programming/comments/as6epa/fp_vs_oo_choose_two_by_brian_goetz/
https://www.reddit.com/r/programming/comments/as6epa/fp_vs_oo_choose_two_by_brian_goetz/
jueves, 7 de febrero de 2019
TIL: paste -sd+
Following https://hacker-tools.github.io/ lectures, I found a neat trick I didn't know in the data wrangling chapter:
seq 100 | paste -sd+ | bc -l # 5050
That's pretty nice. I already had this usecase solved by an "addup" perl script that I stole years ago from Mark Jason Dominus' utils repo.
As a bonus, it reminds me the very similar trick to generate a regex that matches either of many words. That's part of my git pre-commit hook
Not exactly the same, but it also belongs to "Higher Order Shell"
seq 100 | paste -sd+ | bc -l # 5050
That's pretty nice. I already had this usecase solved by an "addup" perl script that I stole years ago from Mark Jason Dominus' utils repo.
As a bonus, it reminds me the very similar trick to generate a regex that matches either of many words. That's part of my git pre-commit hook
Not exactly the same, but it also belongs to "Higher Order Shell"
Suscribirse a:
Entradas (Atom)
