Run Command on File Update

This is a poor man’s “watch a file for changes and when it does, run a command”.


while true; do inotifywait --event modify a-document.tex ; pdflatex a-document.tex ; done

Keychron K3 Function Keys

The Keychron K2 and K3 have dual-purpose media/function keys. The accompanying card says to use fn+x+l to change modes, but I tried it and it didn’t work. I need my function keys, I’m already used to pressing fn when I do need to access multimedia functionality.

I found this repo which explains how to set up a systemd service to configure the keys by writing a value to a driver configuration file. This works, but I was also able to get this changed immediately (though not persistently) by doing:


# Set the keys to operate in Fx mode
echo 0 | sudo tee /sys/module/hid_apple/parameters/fnmode

# Set the keys to operate in multimedia mode

echo 1 | sudo tee /sys/module/hid_apple/parameters/fnmode

Sirueta

Esta es una historia de fantasmas. Los nombres han sido cambiados para proteger identidades.

Hola que tal mi nombre es L. B. C. vivo en el estado de mexico ( municipio de chimalhuacan ) en mi casa abitan no se si talvez sean niños pero el asunto es de que hay alguien mas en nuestra casa en ocaciones mis hermanos pequeños ven un niño de color oscuro en mi cuarto y disen que se pone a brincar en mi cama.

Una ocacion mi hermana estaba en el baño y dejo la puerta abierta y entonses le empeso a gritar a mi mama pero no le hiso caso entonses mi hermana empeso a llorar talves de temor por que como enfrente del baño esta su cuerto de mi hermana, dise que vio a un niño que se asomo y se metio rapido a su cuarto entonses ya cuando llego mi mama a ver por que estaba llorando estaba bien espantada.

Antes de que esto susediera a nadien de nosostros nos abian espantado al unico que le pasaba era a mi hermano el tambien beia niños en el baña y en la sala, eso lla tiene tienpo y desde aquel entonses ya no habiamos hescuchado ni bisto nada, hasta que una noche llo me dormi un poca tarde, y entonses desde el momento que me fui a costar senti miedo y en eso que bolteo a la puerta pribnsipal de los dos cuartos y bi una sirueta que esta en la puerta el tamaño era de una persona adulta, pero como a mi me dio mucho miedo me tape toda la cara, pero enseguida de que me tape la cara senti que algo le levantaba todo el coberto y la colcha que tenia con eso senti en miedo increible.

En este tiempo que mis hermanos an estado biendo los niños a mi me esta pasando que lla cuando me voy a dormir siento como una presensia o alguien que se hacerca a mi asta siento como se me va hacercando cada vez mas pero volteo y no veo nada.

Bueno talvez no se si estar seguro de saber de lo que esta pasando hay pero quisiera que me ayudaran mi telefono es el 5XXXXXXX mi domisilio es ( Calle XXXXXX Manzana 2 Lote 11 San Ajustin Chimalhuacan )

Una cosa mas disen que antes de que nosotros construlleramos la casa hase como 8 años era un kinder y una guarderia.

Bueno es todo lo que les puedo mensionar les agradeseria si me informaran de algo ADIOS.

Itunes on Ubuntu

I’m cheating because this uses virtualbox.

This is ubuntu 20.04.

install these debs:

virtualbox
virtualbox-dkms
virtualbox-ext-pack
virtualbox-guest-additions-iso

Download this Win10 evaluation/development VM

or a suitable one from here

Unzip the file, then on virtualbox, import the VM from the ova file.

Update settings for the VM and enable USB controller, with xHCI so it doesn’t take ages to transfer files.

Boot the VM, log in.

Download itunes from apple inside the vm (maybe with edge):

https://www.apple.com/itunes/download/win64

(I couldn’t install from the ms app store because reasons)

Start itunes by keeping SHIFT pressed while opening itunes:

https://support.apple.com/en-ca/guide/itunes/itns3259/windows

Choose the path where the itunes library is.

Google Rejection and Srs

A few domains are hosted on my server and I have an exim4 setup where I can create virtual addresses by dropping text files in a directory and putting the destination address in the text file. This is convenient because it lets me redirect everything to gmail inboxes and manage all things in one place.

However, sometimes the virtual addresses do receive spam which they promptly forward to gmail, which is unhappy, tanking my server’s reputation.

This came to a head yesterday when I noticed legitimate emails being 550d at the SMTP dialog level, which is bad because they are not resent and we start losing important data.

I installed an additional spam filter, but crucially (I think, remains to be seen whether this really helps) I found this page which describes Sender Rewriting Scheme (and the explanation makes sense, since from Google’s point of view I’m delivering email for the originating domain, after a forward from my server, which is not a designated sender for those domains).

A bit of googling led me to another page describing how to set up srs with an srs client, but unfortunately the config suggested there made a few assumptions that didn’t work for my system. At the bottom of that though, there’s a link to this exim bug which describes a pure exim4 solution with 3 routers and a new transport. This was easy to adapt and it seems to be working well.

#routers
# /etc/exim4/conf.d/router/110_srs
outbound:
  driver =    dnslookup
  domains =   ! +local_domains
  transport = ${if eq {$local_part@$domain} \
                      {$original_local_part@$original_domain} \
                   {remote_smtp} {remote_forwarded_smtp}}

inbound_srs:
  driver =    redirect
  senders =   :
  domains =   +local_domains
  condition = ${if match {$local_part} \
                         {^(?i)SRS0=([^=]+)=([A-Z2-7]+)=([^=]*)=(.*)\$} \
                {${if and { {<= {${eval:$tod_epoch/86400 - ${base32d:$2} & 0x3ff}} \
                                {10}} \
                            {eq {$1} \
                                {${l_4:${hmac{md5}{SRS_SECRET}{${lc:$4@$3}}}}}} \
                          } \
                         {true}{false} \
                 }} \
                 {false} \
                }
  data =    ${sg {$local_part} \
                 {^(?i)SRS0=[^=]+=[^=]+=([^=]*)=(.*)\$} \
                 {\$2@\$1}}


inbound_srs_failure:
  driver =    redirect
  senders =   :
  domains =   +local_domains
  condition = ${if match {$local_part} \
                         {^(?i)SRS0=([^=]+)=([^=]+)=([^=]*)=(.*)\$} \
                }
  allow_fail
  data =    :fail: Invalid SRS recipient address

and

# transport
#/etc/exim4/conf.d/router/30_exim4-config_remote_forwarded_smtp
remote_forwarded_smtp:
  driver =              smtp
  return_path =         SRS0\
                        =${l_4:${hmac{md5}{SRS_SECRET}{${lc:$return_path}}}}\
                        =${base32:${eval:$tod_epoch/86400&0x3ff}}\
                        =${domain:$return_path}\
                        =${local_part:$return_path}\
                        @$original_domain

TIL - Fzf Alt-C

The title of this post is somewhat cryptic but what I learned today is awesome.

I was looking at fzf’s page to see how I could better integrate it with vim. I’ve been happily using fzf in bash for a while now, primarily leveraging the ctrl-r history fuzzy search, and also ocassionally ctrl-t to insert a fuzzily-searched file in the command line. Today I learned about:

Files and directories

Fuzzy completion for files and directories can be triggered if the word before the cursor ends with the trigger sequence, which is by default **.

  • COMMAND [DIRECTORY/][FUZZY_PATTERN]**<TAB>
# Files under the current directory
# - You can select multiple items with TAB key
vim **<TAB>

# Files under parent directory
vim ../**<TAB>

# Files under parent directory that match `fzf`
vim ../fzf**<TAB>

# Files under your home directory
vim ~/**<TAB>


# Directories under current directory (single-selection)
cd **<TAB>

# Directories under ~/github that match `fzf`
cd ~/github/fzf**<TAB>

Process IDs

Fuzzy completion for PIDs is provided for kill command. In this case, there is no trigger sequence; just press the tab key after the kill command.

# Can select multiple processes with <TAB> or <Shift-TAB> keys
kill -9 <TAB>

But the one that REALLY blew my mind was this:

ALT-C - cd into the selected directory

  • Set FZF_ALT_C_COMMAND to override the default command
  • Set FZF_ALT_C_OPTS to pass additional options

This is brilliant, I might get used to this and I’ll become entirely unable to manually cd into a directory now.

Hugo Conversion

I finally bit the bullet and decided to get rid of wordpress, after 16 years. There’s no benefit for my personal blog to be running a dynamic platform, I don’t have any users, or dynamic content, and comments which might be the main attraction are not something I really use.

I still need to figure out how to replace the dynamic contact form, though.

To achieve this, I initially tried to follow the Hugo tutorial, but it really only described a very incomplete set of basics. I had more luck with this other tutorial, and the theme they recommend actually has some interesting sample posts that describe how to create a hugo theme.

I also looked at this to figure out some intricacies of markdown image rendering.

I’ll continue migrating content to the new site, and running both in parallel until ready to switch.

TIL - Python f-string expression value

There’s a python module called icecream which provides a nice ic() function to print an expression and its value, but in a discussion about it I learned that a quick equivalent can be achieved by using Python f-strings (available since Python 3.6) and appending “=” to the variable name:

>>> print(f"{d['key'][1]=}")
d['key'][1]='one'

Hollow Knight

Categories: videogames

Hollow Knight.

It’s a visually interesting platformer/exploration game which does shine in several areas. The controls are tight and responsive, the art style is gorgeous and detailed, and the music is top-notch and really heightens the gaming experience.

It has an expansive world to explore and an incredibly interesting lore to discover along the way, and the enemies are varied and interesting for the most part.

It’s sad, though, that the developers chose to diminish the value of the positive aspects by being so hostile, unfair and disrespectful to players.

The lore (all 20k words of it if reports are to be believed) is inscrutable, hidden among disjoint dialog by (some impossible to find) NPCs, and I wonder why go through all the trouble of creating this if it’s not going to be discoverable in a way that can be pieced together within the game.

The player is never truly rewarded by honing their skill and gathering achievements – weapon and spell upgrades are few and far between and the increases in power are not all that impressive (sure the final nail upgrade is 4x more powerful than the basic one, but it still does only 21 damage against late-level enemies having more than 1000 hit points), and a lot of the charms are so limited as to be basically useless (hiveblood only restores the most-recently-lost mask, an affront to auto-regeneration in any other metroidvania -really only useful for platforming sections such as the white palace). Almost feels like the devs begrudgingly give upgrades, and some only when the plot demands it to progress.

To further this point, upgrades are somewhat pointless given some enemies and bosses that actually gain hit points according to the nail upgrade level the player has achieved. This is almost a slap in the face, why would I bother upgrading the nail if it’s only going to make enemies harder? and it kind of negates the benefit of upgrades, it’s again the developers saying “why should the player beat our game?” (which is indeed the entire point – you can produce an unbeatable game by simply killing the player at the very beginning but then nobody would ever play that).

Details like losing all your money when dying (“don’t fret it, in the late game you’ll have tons of money and nothing to spend it on”, they say – if that’s the case then why not let the player keep the money on death, if it’s not such a big deal?) or enemies re-spawning when the player rests on a bench (the reasoning is probably along the lines of “if he gets to regenerate, so should enemies”) further point to the developers coding the game to challenge themselves, and not to provide the player with a fun, rewarding experience, and rather a punishing, frustrating one.

Exploring is the most interesting part of the game but it’s hindered by ridiculously difficult bosses. “git gud” and all but they are a horrid roadblock to less-proficient players who might not have the time, devotion and reflexes to learn and beat the attack patterns. Three bosses (Hornet, Traitor Lord, Radiance) took me a full week each of trying and trying until I managed to beat them, definitely far beyond the patience of most players.

Yet I persevered and did finish the game, diligently gathering all the achievements needed for the “true ending”. My final reward? A lame 30-second cinematic which explains nothing, gives no closure and is just as inscrutable as the rest of the game’s lore. Honestly it was not worth it.

I did end up with a feeling of accomplishment, but it was more a “I finally beat this sucker, good riddance” than a more positive and satisfying one. I can finally put this piece of crap down and devote my time to games which actually respect me and want me to play and have fun, not be a grueling experience.

“git gud” indeed – I sank 90 hours of time in this game, I got proficient enough to finish it – but it should be and feel like a game and be fun, it’s not a job and should not require honing your skill that much – I found I couldn’t make a lot of progress if I played at the end of the day when I’m relatively tired – a game that requires this level of training, attention and concentration doesn’t really feel like a game, and more like a job.

I’m quitting this job and going on to easier, greener pastures – and despite how gorgeous it looks, I’m not going to buy Silksong and give these guys more of my money and time.