Friday, August 14, 2020

My Mac Terminal Setup (Homebrew, iTerm2, Fish, )

I did this twice in 2 weeks, so I've got a feel for what I like now and the least sucky way to do it. If I did it more often I'd probably write a script for it, but since I don't plan to do this for another 2 years here's a quick blog. Including sources so that if things change you can find them yourself and you don't have to trust this blog.

First install brew because having a *nix computer without up to date versions of things sucks. (source)

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

Now install iTerm2 because even if you don't end up using it's features you might some day so you may as well use it instead of the default terminal. (source)

brew cask install iterm2 

iTerm2 should be in your Applications folder, open it up as your new terminal. 

Now install fish because it's the shell script that makes the most sense to me. It comes configured out of the box closer to what I want so I use it. (source)

brew install fish

Now add fish to your list of allowable shells and make fish your default shell.

echo "/usr/local/bin/fish" | sudo tee -a /etc/shells

chsh -s /usr/local/bin/fish

I don't know if I have enough of an opinion to care, but Oh My Fish and Fisher are both ways to get more out of fish. I installed Oh My Fish because it seemed to be the thing more people are using. Fisher is probably the correct tool for what I need, but whatever. (source)

curl -L https://get.oh-my.fish | fish

Now install bobthefish because it is a good theme that supports stuff like git out of the box. (source)

omf install bobthefish

That theme might throw some odd characters at us because it looks cool, so you need a font that will keep up. The font called Hack looks he most like I expect a font to look, so I use the version supplied via Nerd Fonts. (source)

brew tap homebrew/cask-fonts

brew cask install font-hack-nerd-font

Now you have to go into your iTerm preferences and select the new font.

As long as you are in the preferences menu you should find a color scheme that you like. I really couldn't find something I liked a lot but Smoooooth was the one I disliked the least so I went with it.

Saturday, January 19, 2019

Automatically Mount USB Drive in Raspbian

This blog is mostly information for myself but maybe the powers of google will bless you with this search result. If you use Raspbian for only command line USB devices don't mount automatically.
Luckily the process to get it to work is pretty easy.
Unfortunately there are lots of documented processes that aren't very good. You should use a udev rule for this not any of the other funky junk.

You should be able to do most of this by installing the usbmount package (https://github.com/rbrito/usbmount) but it doesn't always work perfectly out of the box so I've been sticking to this solution because it has always worked for me.

The biggest piece is to use this automount rule from Axllent.org

Create a file /etc/udev/rules.d/11-media-by-label-auto-mount.rules that contains the following.

 KERNEL!="sd[a-z][0-9]", GOTO="media_by_label_auto_mount_end"   
 # Import FS infos   
 IMPORT{program}="/sbin/blkid -o udev -p %N"   
 # Get a label if present, otherwise specify one   
 ENV{ID_FS_LABEL}!="", ENV{dir_name}="%E{ID_FS_LABEL}"   
 ENV{ID_FS_LABEL}=="", ENV{dir_name}="usbhd-%k"   
 # Global mount options   
 ACTION=="add", ENV{mount_options}="relatime"   
 # Filesystem-specific mount options   
 ACTION=="add", ENV{ID_FS_TYPE}=="vfat|ntfs", ENV{mount_options}="$env{mount_options},utf8,gid=100,umask=002"   
 # Mount the device   
 ACTION=="add", RUN+="/bin/mkdir -p /media/%E{dir_name}", RUN+="/bin/mount -o $env{mount_options} /dev/%k /media/%E{dir_name}"   
 # Clean up after removal   
 ACTION=="remove", ENV{dir_name}!="", RUN+="/bin/umount -l /media/%E{dir_name}", RUN+="/bin/rmdir /media/%E{dir_name}"   
 # Exit   
 LABEL="media_by_label_auto_mount_end"  

Edit the udev config:  sudo nano /lib/systemd/system/systemd-udevd.service 
Comment out the last 7 lines and everything works normally. Comment below if you actually know what these do. Otherwise I'm not terribly worried.

 #KillMode=mixed  
 #WatchdogSec=3min  
 #TasksMax=infinity  
 #MountFlags=slave  
 #MemoryDenyWriteExecute=yes  
 #RestrictRealtime=yes  
 #RestrictAddressFamilies=AF_UNIX AF_NETLINK AF_INET AF_INET6  

Restart udev with the command:  sudo udevadm control --reload-rules
Restart the box with the command command:  sudo reboot

Saturday, November 10, 2018

iPhone XS and iPhone XR Black Friday Deals 2018

Sam's Club Member Event
Stores Open 7am on Saturday, November 10, 2018

$300 Gift Card with Activation & Payment Plan (AppleCare required for Payment Plan?)
iPhone 8, 8+, X, XS, XS Max, XR

Target Black Friday Circular
Stores Open 5pm on Thanksgiving

$150 Gift Card with Activation (requiring Payment Plan?)
iPhone 8, 8+, X

$250 Gift Card with Activation (requiring Payment Plan?)
iPhone XS, XS Max

Best Buy Black Friday Ad
Stores Open 5pm on Thanksgiving

"Up to" $150 Gift Card with Activation (requiring Payment Plan?)
iPhone XR, XS XS Max

Walmart Black Friday Ad
Stores Open 6pm on Thanksgiving

$400 Gift Card with Activation & Payment Plan
iPhone 8, 8+, X

$300 Gift Card with Activation & Payment Plan
iPhone XR, XS XS Max

Tuesday, February 6, 2018

Docker for Script Kiddies


Do you want to easily write some code and run it and not foul up your normal desktop with funky environment variables or versions of scripting languages that aren't officially supported? Yes.

Do you want to use Docker because it is the cool thing that all the other kids are running now? Yes.

Alpine Linux is built to be super super small so it is perfect for things like Docker where you might have a lot of your systems running in parallel. So I build my examples on top of Alpine Linux because why not. I picked the "most popular" programming languages that can be easily installed in vanilla Alpine Linux. This means that Go,  Java, and C# are left out because Alpine Linux uses musl instead of gnu libc and that's not something easily supported out of the box (much respect for Rust for supporting this).

So here are all my GitHub repos with some basic shell scripts for you to run so you can see a HelloWorld run in the languages that are easily supported in vanilla Alpine Linux

GitHub Repos

File Size Comparison

Of all the ways to measure a programming language probably the worst way is to compare the file size needed on disk to get a Hello World program running. But it was easy to do so I went ahead and did it. The base Alpine Linux weighs in at 4.15MB so everything else is on top of that.
  • COMPILER: GCC 6.4.0
    • SIZE: 100MB
  • COMPILER: G++ 6.4.0
    • SIZE: 152MB
  • LANGUAGE: Node.js v8.9.3
    • SIZE: 50.2MB
  • LANGUAGE: PHP 7.1.12
    • SIZE: 14.2MB
  • LANGUAGE: Python 2.7.14
    • SIZE: 44.3MB
  • LANGUAGE: Python 3.6.3
    • SIZE: 55.4MB
  • LANGUAGE: Ruby 2.4.3
    • SIZE: 20.4MB
  • LANGUAGE: Rust 1.22.1
    • SIZE: 267MB

Wednesday, September 20, 2017

Printrbot Auto-Leveling Probe Fix

Has your Printrbot gotten cranky or just given up the ghost when trying to probe your bed?
Is the Printrbot forum not terribly helpful?

My Printrbot would detect the bed in the first spot.
Move to the second spot and go up, up.
Move to the third spot and go up, up.

If your bot acts kind of like this it means that something is wrong with your probe or your firmware or something. Use M119 to see if you can get z_min to be triggered at different positions. In my case it was easy to see that it would trigger near home, but not away so I could tell the probe was broken. Because the only difference was how the wires were stretched I had a strong suspicion it was somewhere in the middle of that wire pull that was getting moved.

None of the other wires in the bundle were having any problems so I don't know why the probe wires are so cheap. Anyway, I did it the proper DIY way chopped out the bulk of the wire and soldered in some heavier duty electrical wires I had laying around.



It looked like this.

I keep the thinner wires on the probe and the connector and soldered there because it was easier that tearing those apart and reconnecting. I fished the probe back into place and it works flawlessly.

I've had 2 different probes fail due to garbage thin wires, but never had a problem with the firmware as some people claim is part of the problem.

So if your probe stopped detecting the your metal build surface you may as well try replacing the wires. It's the maker way after all.

Wednesday, April 26, 2017

Using a Raspberry Pi as an Airplay Server

This is mostly for my own personal notes. Maybe you'll get something out of it.
I've got an original Raspberry Pi B with a WiFi dongle that I have hooked directly to the USB input of my JVC Receiver.

Grab the "Lite" version of Raspbian because you won't need any windows.
At press time the most recent version is 2017-04-10-raspbian-jessie-lite.zip

Setup your accounts/wifi/localization the way you like.
Update and upgrade/dist-upgrade to get everything current.
Reboot to make sure everything is on the level.

Go to: https://github.com/mikebrady/shairport-sync and skim the instructions so you know what you are doing.

Install All The Things!
sudo apt-get install build-essential git xmltoman autoconf automake libtool libdaemon-dev libasound2-dev libpopt-dev libconfig-dev avahi-daemon libavahi-client-dev libsoxr-dev libssl-dev
Clone All The Things!
git clone https://github.com/mikebrady/shairport-sync.git
Change Directory
cd shairport-sync
Setup Configuration Script
autoreconf -i -f
Configure All The Things!
./configure --sysconfdir=/etc --with-alsa --with-avahi --with-ssl=openssl --with-soxr --with-systemd
Make All The Things!
make

Create Shairport-Sync Group for Security
 getent group shairport-sync &>/dev/null || sudo groupadd -r shairport-sync >/dev/null
Create Shairport-Sync User for Security
getent passwd shairport-sync &> /dev/null || sudo useradd -r -M -g shairport-sync -s /usr/bin/nologin -G audio shairport-sync >/dev/null
Install All The Things!
sudo make install
Launch on System Boot
sudo systemctl enable shairport-sync
Configure All The Things!
sudo nano /etc/shairport-sync.conf
I added a name to the "general" section
name = "MusicPi";
interpolation = "soxr";
I added some output info to the "alsa" section
output_device = "hw:1";

Thursday, September 22, 2016

Vonets VOPWRT and How I Spent $8


Forgive the brevity. I don't want to waste much more time on this subject
  • I have WiFi.
  • I have a device that is old and doesn't support WiFi
  • I have experience mucking around in OpenWRT and have setup a few devices.

I figured I'd take this bullet list and put it to good use.
I went on eBay and found an $8 piece of hardware that uses OpenWRT. The Vonets VOPWRT. You won't find much information on Google about it. That should have been a red flag.

The first step of this project was to get this VOPWRT box on my WiFi. Start it up. Connect to the config as listed on the bottom of the box and try.

Try it again. Reset the firmware to factory. Try again the next day. Try again a different way. Try again a third way. Try a couple more different ways and fail. Try via command line stuff. Try again. Give up.

Decide to try upgrading the firmware. Checking the OpenWRT wiki where it lists the device. No supported version of it, but what ever. The version with mt7620a_mt7530 in the name sounds promising as it aligns with the specs listed. Download that and attempt to upgrade.

Flash the image to the device. Notice the upgrade seems to go fine. Watch as the device reboots and it is bricked. Open up the box. Notice no screws so you know it is a high quality product. Note the 3 empty antenna structures clearly designed to make you think it pumps out a great signal.

Take out the 8GB MicroSD card.
Throw everything else away.
Vow to not waste your money on more piece of garbage electronics