Raspi Network Failure Shenanigan

It seems as I run into a common issue with my Raspberry 4. After an indeterministic uptime, the wifi stops working.

And here is the hotfix, a small script provided by @pitto first restarting the nic and if anything fails just reboots the device:

This bash script checks for wireless internet connection and, if it is failing, tries to fix it.

It is simple and it seems to work.


I just have to write some automation to roll it out automatically including a corresponding cron job once I find some time.

GitHub Repo: https://github.com/ltpitt/bash-network-repair-automation

Turn off your Screen in Windows 10

A problem you might have as well: how to turn off the screen of your laptop without changing the battery settings and without using any tools? Probably using a hotkey? Did you realize, this is not part of Windows at all?

Basically, here is the batch file you have to create for it. Yes, someone wrote a batch file for this. Create a shortcut to the batch file, assign a hotkey and be happy. You also can download the batch file from TechNet. Works on my machine (with Windows 10).

powershell (Add-Type '[DllImport(\"user32.dll\")]^public static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);' -Name a -Pas)::SendMessage(-1,0x0112,0xF170,2)

Found on TechNet: https://gallery.technet.microsoft.com/scriptcenter/Turn-off-screen-4d173e0a

Glow Effect for SynthWave’84 on macOS

During today’s recording of our podcast, I talked about not getting the glow effect for the SynthWave’84 theme working. Right after doing so, I figured out how to solve the issue.

After installing the plugin, you need also the extension Custom CSS and JS Loader.

Now edit the settings in the settings.json file of Visual Studio Code by adding the following entries:

"vscode_custom_css.policy": true,
"vscode_custom_css.imports": [
 "file:///Users/andreas/.vscode/extensions/robbowen.synthwave-vscode-0.0.7/synthwave84.css" 
],

Of course, you have to change the user name above to yours. The settings.json should now look quite similar to the following:

Eventually, you need to make sure Visual Studio can apply the modifications by running

>sudo chown -R $(whoami) "/Applications/Visual Studio Code.app/Contents/MacOS/Electron"

That is, by the way, the step I have missed in my previous attempts.

Now you can restart Visual Studio Code, enter Command+Shift+P and enter Enable Custom CSS and JS

Once Visual Studio Code is reloaded, the glow effect of the theme should work like a charm.

If you receive any message about a corrupt Code installation, you might want to simply click it away.

Some of the previous steps might need to be repeated once the Visual Studio Code installation was updated to a new version.

Theme: https://marketplace.visualstudio.com/items?itemName=RobbOwen.synthwave-vscode

Custom CSS Loader: https://marketplace.visualstudio.com/items?itemName=be5invis.vscode-custom-css

Raspberry Pi – Setting a static IPv4 address

It run me mad, as I tried to change the IP address of my Raspberry to a static one. I changed literally everything in  /etc/network/interfaces and reloaded, restarted and reboot the device over and over.

iface eth0 inet static
address 192.168.0.207
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.

As the above configuration did not help a lot, I figured out that based on the Raspberry model, you need to change settings on various places.

First run

cat /proc/cpuinfo

to determine you model. While getting something like

pi@raspberrypi:~ $ cat /proc/cpuinfo
processor    : 0
model name    : ARMv6-compatible processor rev 7 (v6l)
BogoMIPS    : 2.00
Features    : half thumb fastmult vfp edsp java tls
CPU implementer    : 0x41
CPU architecture: 7
CPU variant    : 0x0
CPU part    : 0xb76
CPU revision    : 7

Hardware    : BCM2708
Revision    : 0004
Serial        : 000000004715b608

you need to use the hardware revision and

Model and Pi Revision 256MB Hardware Revision Code from cpuinfo
Model B Revision 1.0 256MB 0002
Model B Revision 1.0 + ECN0001 (no fuses, D14 removed) 256MB 0003
Model B Revision 2.0
Mounting holes
256MB 0004
0005
0006
Model A
Mounting holes
256MB 0007
0008
0009
Model B Revision 2.0
Mounting holes
512MB 000d
000e
000f
Model B+ 512MB 0010
Compute Module 512MB 0011
Model A+ 256MB 0012
Pi 2 Model B 1GB a01041 (Sony, UK)
a21041 (Embest, China)
PiZero 512MB 900092

Based on this information you need

Model a

Static IP addresses in /etc/network/interfaces is not the “prefered” way,as it is an old way and DHCPCD5 is installed.

Model b

Static IP addresses are configured in the /etc/dhcpcd.conf and it is  required that /etc/network/interfaces is set to manually.

iface eth0 inet manual

That’s all…

Sud-o-Visual Studio Code

There are literally no good reasons to start Visual Studio Code on macOS with leveraged rights. Applications on macOS are not designed to run sudoed in general. If you would do so, this can have unintended sided effects. So much for the disclaimer.

If you want to start Visual Studio Code on macOS sudoed, just run

sudo open /Applications/Visual\ Studio\ Code.app

That’s all.

RFC Quick Access

To follow best practices, understand and learn new de-facto standards, I read and refer a lot RFCs (Requests for Comments). Luckily, the IETF provides an endless list of RFCs to do so.

If often need quick look into these RFCs while being in an editor or at a console windows. To avoid switching from the keyboard and losing focus, I use a small batch file called rfc.bat to gain access to RFCs very quickly.

rfc batch file call on cmd.exe

The batch script simply calles the IETF RFC URL with the RFC number as parameter.

@echo off
start https://tools.ietf.org/html/rfc%1

Where ever the batch files lives, make sure the directory is in your path. I use a folder called c:\Prg\batch which is synchronized over all my computers.

I have adapted this approach to a variety of manual tasks to open files which live on a dedicated place. E.g. I use a much more sophisticated script to open Visio diagrams based on process numbers from our company sharepoint to gain quick access instead of maneuvering through a bunch of websites. These are more than 500 documents named based on a alphanumeric pattern, so this way makes it much more easy to find and open the documents.

I do not want to see this web content on Yosemite

For a couple of weeks I now this really annoying message during the start up  of my Yosemite installation.

To view this web content, you need to install the Java Runtime Environment.

If I do follow the instructions of the pop up, I usually land on the Java site.

To view this web content, you need to install the Java Runtime Environment.As I develop on a regular base, I have the latest version of Java already installed (right no it should be version 8u25). Therefore, nothing to do.

I case you thought of installing Apple’s Java version for Mac. That’s  IMHO not the way to solve the issue. You might cure the symptoms, however, you will not fix the root cause for this issue.

To get rid of the message, you need the find the root cause. In my case it was the attempt to try Facebook’s video chat some weeks ago. That was the only one installation I performed since I receive this message. Even though, I disabled the add-on in Firefeox, the message kept showing at start up.

To get finally rid of the message head straight to the terminal and enter

launchctl list

In case you wonder that launchctl does, check the manpage which says

launchctl interfaces with launchd to load, unload daemons/agents and generally control launchd. launchctl supports taking subcommands on the command line, interactively or even redirected from standard input. These commands can be stored in $HOME/.launchd.conf or /etc/launchd.conf to be read at the time launchd starts.

Anyway, you shot not get a list of off all jobs loaded into launchd. There ckeck if you can find com.facebook.videochat.{username}.updater in this list. Wondering what this is? It’s some kind of Facebook-collects-your-data thing. Honestly, I don’t want to know much more about what it does, I just want to get rid of it.

com.facebook.videochat updater

Check out

ls ~/Library/LaunchAgents/ | grep facebook

You should get something like com.facebook.videochat.{username}.plist.
Now run

launchctl unload ~/Library/LaunchAgents/com.facebook.videochat.{username}.plist

followed by

launchctl remove ~/Library/LaunchAgents/com.facebook.videochat.{username}.plist

You might want to run the following command instead

launchctl remove com.facebook.videochat.{username}.updater

You now can delete the property list file

rm ~/Library/LaunchAgents/com.facebook.videochat.{username}.plist

Now check for the FacebookUpdate application  via

ls ~/Library/Internet\ Plug-Ins/ | grep Facebook

Again, you should fine something like FacebookVideoCalling.bundle. Send it to /dev/null via

rm ~/Library/Internet\ Plug-Ins/FacebookVideoCalling.bundle

Now there still something to get rid of by calling

rm -R ~/Library/Application\ Support/Facebook/

Et voiá, your are done. The cause for the message should be gone by now.

To get rid of the JAR file itself use Spotlight to looking for FacebookVideoCalling. You should find something like FacebookVideoCalling_v1.6.jar. Use Finder then to get rid of it.

Finding FacebookVideoCalling_v1.6.jar That is, by the way, the only thing Facebook suggest to uninstall the videochat. Not only, the sort of infect you with the above updater, they also do not provide useful information for uninstalling the stuff.

The fact, Facebook’s add-on installed this nasty updater is quite annoying. Adding a job to the launchd for an Firefox add-on is quite questionable. Even more annoying that this one slipped through the cracks.

How to get the favicon.ico from any Page

Recently, I was in the need of retrieving the favicon.ico file from a website. As I had to process the file programmatically and render it on a website, it would have been quite a lot of manual work to get the .ico file and make sure the browser does render it in the correct way. After digging around, I learned about a secret URI probably provided once by Google’s social bookmarking service Google Shared Stuff. While Google Shared Stuff was launched in 2007,  it was already discontinued in 2009. However, this one URI seems to work perfectly maybe because it is still used within Google extensively.

The Secret

To get the favicon.ico file from any arbitrary page you simply have to use an URI using the following pattern:

http://www.google.com/s2/favicons?domain=www.example.org

Eventually, this URI will provide you the following image: Image retrieved using http://www.google.com/s2/favicons?domain=www.example.org

How it Works

Some More examples to see how it works:

  • Facebook
  • TechChrunch
  • aheil blog
  • Google
  • dotnetpro Magazine
  • heise.de
  • Google+

As most of the sites do keep their favicon.ico file right in the root of the web site, others like Google don’t. Actually, you might find Google’s plus icon located at

https://ssl.gstatic.com/s2/oz/images/faviconr2.ico

While this is probably not a problem retrieving the favicon.ico file using the standard URI at all, the secret URI provides one major advantage: you’ll get the icon as a nice 16×16 PNG file, ready to be rendered in any <img> tag right away.

The Risk

As every time building up on a Google service as I did before, it might disappear tomorrow without notice leaving your site with quite a bunch of 404s though. Even worse, as it seems there is no official support for this URI, there won’t be any notice or deprecation period until switched of as done for other services like Feedburner.