Categories
Software www

Check websites with LanguageTool for typos

This is quick and dirty (and with the help of ChatGPT).

FlatTurtle has a new site, and there’s been some fine-tuning here and there that led to a few typos creeping in. I wanted a quick tool to plug in a page, and that would highlight possible mistakes.

I’ve been a personal (paying) user of LanguageTool for a few years now (European, and less spammy and dodgy than Grammarly)

Started off with a terminal tool, but in the end that wasn’t working out (hard to get the colouring to work and make it clear enough).

Figured a website would be easier:

  • Insert a site
  • Let it go through the LanguageTool API for mistakes*
  • Show what is potentially wrong and explain why so I can go and edit it

(*) Surprisingly hard because it needs to trim all HTML and js and other crap. And it has issues detecting headers (without punctuation) from paragraph text, etc).

It’s far from perfect, but it works well enough for half a day of fiddling around.

You can hover your mouse over the red words to get some information as to why something is wrong.

The code, provided as-is, is here, and you can run it using:

python3 -m pip install flask selenium beautifulsoup4 geckodriver-autoinstaller requests
python3 web_check.py --api-key KEY --username EMAIL

And opening http://localhost:5000.

EMAIL is your login, the KEY can be found here.

Have fun.

Categories
Apple Hardware Software

Script to display Mac battery information

You can see how this script makes that couple very happy.

Quick and dirty script that shows your Mac battery information (health, cycles, etc). If an Apple keyboard or mouse is connected, it’ll also display the battery % of those.

# Battery information
battery() {

	if !ioreg > /dev/null 2>&1; then
		echo "ioreg not found. Exiting."
		return 1
	fi

	_ioreg=`ioreg -l`
	_profile=`system_profiler SPPowerDataType`

	MOUSE=`echo $_ioreg -l | grep -A 10 "Mouse" | grep '"BatteryPercent" =' | sed 's/[^0-9]*//g'`
	TRACKPAD=`echo $_ioreg -l | grep -A 10 "Track" | grep '"BatteryPercent" =' | sed 's/[^0-9]*//g'`
	KEYBOARD=`echo $_ioreg -l | grep -A 10 "Keyboard" | grep '"BatteryPercent" =' | sed 's/[^0-9]*//g'`
	CYCLE=`echo $_profile | grep "Cycle Count" | awk '{print $3}'`

	if [ -n "$MOUSE" ]; then
		echo "Mouse: "$MOUSE"%"
	fi

	if [ -n "$TRACKPAD" ]; then
		echo "Trackpad: "$TRACKPAD"%"
	fi

	if [ -n "$KEYBOARD" ]; then
		echo "Keyboard: "$KEYBOARD"%"
	fi

	if [ -n "$CYCLE" ] && [ "$CYCLE" -ne 0 ]; then
		echo "Mac battery "`echo $_profile | grep "State of Charge" | awk '{print $5}'`"%"
		echo "Charging: "`echo $_profile | grep "Charging" | head -n 1 | awk '{print $2}'`
		echo "Cycles: "$CYCLE
		echo "Condition: "`echo $_profile | grep "Condition" | awk '{print $2}'`
		echo "Health: "`echo $_profile | grep "Maximum Capacity" | awk '{print $3}'`
	fi
}

Outputs something similar to this (no mouse or keyboard connected):

nazgul ~ $ battery
Mac battery 54%
Charging: No
Cycles: 224
Condition: Normal
Health: 89%

This works on zsh and may not work in bash.

Categories
Misc

Macbook Air M1 issues

I recently got my mom a Macbook Air M1, upgrading from a 2010 Macbook Pro (High Sierra).

When migrating over from High Sierra to Big Sur, using Migration Assistant (my Synology TimeMachine kept on failing — but besides that, migration went smoothly) two issues came up that required calling Apple.

But first off I noticed that when migrating, for some reason FileVault was turned off (more on that later). I, obviously, turned it on.

Problem A: when rebooting the Mac, I noticed the keyboard layout changed from Belgian (Azerty) to ABC (which is US English?) and it didn’t accept the password to unlock the Mac. You can manually select another keyboard layout which accepts the password, but at every reboot that resets and requires going back through the layout picker.

Solution A: M1 no longer supports the usual SMC or NVRAM reset. But this problem could be solved by turning off the mac, closing the lid (?!) and waiting 30+ seconds before turning it back on. According to the person on the phone, that’s the M1 SMC reset.

Problem B: I disabled guest mode in System Preferences > Users & Groups — but it was still showing alongside the regular/admin user. I don’t want guest mode.

Note that the guest mode only showed at the disk unlock (i.e.: after a reboot) and not when logged out (i.e.: Apple logo > Log Out from the regular user).

Solution B: Tried several things with Apple support:

  • Turning off screen sharing and print sharing (sure — didn’t care too much about these)
  • Turn guest mode on/off and reboot/force quite System preferences
  • Turn off Find My in iCloud settings (not acceptable)
  • Turn off FileVault (not acceptable)
  • Manually running:
    • sudo defaults write /Library/Preferences/com.apple.AppleFileServer guestAccess -bool NO\n
    • sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server AllowGuestAccess -bool NO\n
  • and a few other things I now forgot

This is what actually did help:

  • Turning off FileVault actually turns off Guest mode; so when the Mac was not encrypted, it only showered one user (instead of the user + Guest) at the login prompt.
    • Obviously, that’s not acceptable and I turned it back on
  • Supposedly turning off Find My in iCloud settings is needed (according to Apple this requires Guest mode)
    • I later turned it back on and Guest mode did not reappear. So, what Apple was saying was incorrect, and it does not make the Guest user show up.
  • Running sudo fdesetup list in Terminal shows the list of users. This may be helpful for debugging.
  • Running dscl . list /Users shows many users and included Guest in my mom’s case. Not entirely sure what I am looking at here.
  • Running sudo dscl . delete /Users/Guest solved the problem. This deletes the Guest user (?).

Categories
Apple Hardware

Yard Sale: Macbook Pro late 2013

For sale due to getting a portable Macbook:

  • Late 2013 Macbook Pro (15.4″ Retina)
  • 2.3Ghz i7 (quad core + Hyper-Threading)
  • 16Gb RAM
  • 512Gb SSD
  • Intel Iris onboard GFX + Nvidia GeForce GT 750M PCE GFX
  • BE-Azerty keyboard
  • €2445,41 in 28 October 2013
  • SUPER fast
  • Minor scratch in the back of the LCD
  • Minor (not very noticeable) corrosion at the right hand
  • Weird scratch “smear” in LCD display (only visible on white background; about 2x2cm; to be honest it’s not really visible)
  • Besides this very decent Macbook Pro, it has been used, but in very good shape for the extreme work it has committed. Taken care of this device as if it was my own child. And did I mention blazing fast?

Contact: [email protected]

Specs:

Processor 2.3GHz Quad-core Intel Core i7
Memory 16GB 1600MHz DDR3L SDRAM
Flash Storage 512GB Flash Storage
Apple Thunderbolt to Enet Adpt Apple Thunderbolt to Enet Adpt Apple Thunderbolt to FW Adptr No FireWire Adapter
Mini DisplayPort to VGA Adptr No VGA Adapter
Keyboard and Documentation Keyboard/User’s Guide(Z)-BEL Country Kit Country Kit-INT

Pictures:

IMG_20160823_010509

It’s a Macbook Pro !

IMG_20160823_010523

“Smear” above “AGE” (really hard to see)

IMG_20160823_010531

Scratch at the back (knocked it against a glass door at night in my old apartment)

IMG_20160823_010450

Corrosion at the right hand (not left, don’t ask why — probably because I use the touch pad all the time).

More info:

Screen Shot 2016-08-23 at 00.50.51

Screen Shot 2016-08-23 at 00.50.54

Screen Shot 2016-08-23 at 00.52.35

Screen Shot 2016-08-23 at 00.54.11Screen Shot 2016-08-23 at 00.54.28

Categories
Apple Errors Linux Networking Software

Courier IMAP and auto deleting trash after 7 days

E-mails that had been deleted for over 7 days were automatically removed from the IMAP server. E-mail date was ignored (ie the mail could have been from 2010; the actual time in “Trash” counted). This didn’t happen to other folders (Sent, Archive, Spam). This recently happened and hadn’t happened before.

I had to restore my trash folder from backups every 7 days (yay for rdiff-backup).

It took me a while to figure it out… The problem first appeared in October, right after several big changes:

  • Yosemite update
  • Airmail to Airmail 2 update (I was convinced this was the root cause, looking at my clients instead of the server)
  • Android 5.0.x
  • Android Email app sunset, changes to GMail app
  • IPv6 working decently at home after updating my RPi to Fritzbox devices.
  • Random connection errors in GMail app (this was due to misconfigured DNS in the GMail app and causing IPv6 catch all to redirect to the webserver instead of the mailserver. It didn’t happen consistently because over mobile (4G & lower) there is no IPv6 and at home is randomly falls back to IPv4 as well. IPv4 DNS was well configured.
  • Moving my ~100.000 deleted e-mails from “Deleted Items” (OS X Mail default) to “Trash” (Android & Courier default) to stop having to move them manually from one folder to the other every so often. => this was eventually the cause but I didn’t realize.

Being convinced it was most likely Airmail 2 and very maybe Android I had been looking in that direction.

Debugging was also extremely slow as I had to wait 7 days before being able to check if the changes I made helped anything.

I eventually figured out that it was not Airmail when I rebuild my whole mail database and it defaulted back to putting my deleted mails into the Archive folder instead of Trash. Archive mails were kept over 7 days, but items in Trash still removed.

That’s when I started looking at Courier IMAP config: /etc/courier/imapd (and not imapd-ssl).

There’s an option that says:

##NAME: IMAP_EMPTYTRASH:0
#
# The following setting is optional, and causes messages from the given
# folder to be automatically deleted after the given number of days.
# IMAP_EMPTYTRASH is a comma-separated list of folder:days.  The default
# setting, below, purges 7 day old messages from the Trash folder.
# Another useful setting would be:
#  
# IMAP_EMPTYTRASH=Trash:7,Sent:30
#
# This would also delete messages from the Sent folder (presumably copies
# of sent mail) after 30 days.  This is a global setting that is applied to
# every mail account, and is probably useful in a controlled, corporate
# environment.
#
# Important: the purging is controlled by CTIME, not MTIME (the file time
# as shown by ls).  It is perfectly ordinary to see stuff in Trash that's
# a year old.  That's the file modification time, MTIME, that's displayed.
# This is generally when the message was originally delivered to this
# mailbox.  Purging is controlled by a different timestamp, CTIME, which is
# changed when the file is moved to the Trash folder (and at other times too).
#
# You might want to disable this setting in certain situations - it results
# in a stat() of every file in each folder, at login and logout.
#
IMAP_EMPTYTRASH=Trash:7

Comment out that last line, and restart courier-imap(-ssl)… Simple as that.

This solved my issue.

I’m not sure when that config change happened (Debian update?) and I do not know who at Courier thought it was a good idea …. But sheesh.