Nixgeek

Random Ramblings

Moving site over to Hugo

Working on moving the site again over to Hugo. Some derpyness is still happening though so be warned.

Maybe I’ll even post some new stuff when it’s all done heh.

Links relating to keto

So, I’m a geek. That much is easily proven by the domain name. I’m also a big geek. As in I need to lose a lot of weight to be healthy and also to feel better about myself, have more energy, etc. I’m looking into doing Keto and am compiling a list of interesting links to things others do, recipes and other Keto related things. If you have any other interesting ones, feel free to send me the link to keto@nixgeek.com

Ruled.Me Keto Calculator

Ruled.Me Keto Guide - includes a calculator to help you determine what you should be eating, how much your deficit needs to be to lose weight, etc.

Ruled.Me Keto Guide to Intermittent Fasting

Ruled.Me 30 day Keto Diet Plan

Ruled.Me Eating Keto on a Budget

Ruled.Me Keto FAQ

Quick bash script to check if a volume is mounted

A quick and dirty little bash script to check if a mount point is active or not.

if grep -qs '/mnt/drive1' /proc/mounts; then
    echo "It's mounted."
else
    echo "It's not mounted."
fi

You can easily change the code to automatically mount the volume (or unmount) as per your needs.

Installing Glances on Debian

Glances is a cross-platform curses-based system monitoring tool written in Python. It shows a large amount of information such as cpu usage, memory usage, hardware monitoring, battery monitoring and much more.

Install the required dependencies:

sudo apt-get install python-dev python-jinja2 python-psutil python-setuptools hddtemp python-pip lm-sensors
sudo pip install batinfo pysensors

If you are running on actual hardware (ie: not a vps like many of my servers), you should detect the sensors for that part of the monitoring:

sudo sensors-detect

Now install the actual Glances program:

sudo pip install Glances

And finally, you can run it by simply:

sudo glances

To upgrade, you can do

pip install --upgrade glances

There are also a number of other optional dependencies you can install:

bottle (for Web server mode)

py3sensors (for hardware monitoring support) [Linux-only]

hddtemp (for HDD temperature monitoring support) [Linux-only]

batinfo (for battery monitoring support) [Linux-only]

pymdstat (for RAID support) [Linux-only]

pysnmp (for SNMP support)

zeroconf and netifaces (for the auto discoverer mode)

influxdb (for the InfluxDB export module)

statsd (for the StatsD export module)

pystache (for the action script feature)

docker-py (for the Docker monitoring support) [Linux-only]

How to install Plex Media Server ob Debian Squeeze or Wheezy

Plex Media Server is a great server for playing media (tv, movies, pictures) on a variety of devices (Android, Roku, Smart TVs, Windows, Mac, IOS, etc). It supports transcoding, a very nice interface layout, tracks what episodes or movies you have already watched, share with your friends and with a plus pass (paid account) there are additional features as well such as sync so your device can sync when you are at home and let you play when you are mobile without using data to watch.

There is a third party repo that seems to be updated quite often (as of this article anyway) for Debian Squeeze and Wheezy. To use it, the instructions are pretty simple:

sudo apt-get install curl
echo "deb http://shell.ninthgate.se/packages/debian squeeze main" | sudo tee -a /etc/apt/sources.list.d/plexmediaserver.list
sudo curl http://shell.ninthgate.se/packages/shell-ninthgate-se-keyring.key | sudo apt-key add -
sudo apt-get update
sudo apt-get install plexmediaserver

Your server should now be installed and functional. The default port is 32400 for the web interface, so to manage it you can go to http://192.168.0.5:32400/web/ (change your ip as needed) and add in your media files. Have fun :)

How to use loopback addresses other than 127.0.0.1 with OSX

Strange little thing I encountered a while back. Basically, I use ssh tunnels to a number of remote hosts and to organize it a bit easier, I tend to use 127.0.0.X and assign each server a different number. However, under OSX you cannot use any others except for 127.0.0.1

The fix isn’t too bad though, you basically need to add the interfaces either manually or at startup.

To add just a few, you can do:

sudo ifconfig lo0 alias 127.0.0.2 up

and change 2 to whatever ip you need. However, if you want to add a large number or all of the possible ones, this will take a long time. So, a quick little script to do it would be something like:

for ((i=2;i<256;i++))
do
   sudo ifconfig lo0 alias 127.0.0.$i up
done

You could also change the 256 to something else like 50 if you don’t want the full list added.

How to clear DNS cache in various OS

There are a variety of reasons why (updated a DNS record, issues with resolver, etc) but sometimes a good diagnostic step is to clear out the dns cache.

Each operating system (and even versions / distributions in some cases) have a different method

OSX 10.10 > sudo discoveryutil udnsflushcaches

OSX 10.9 > dscacheutil -flushcache; sudo killall -HUP mDNSResponder

OSX 10.7 – 10.8 > sudo killall -HUP mDNSResponder

OSX 10.5 – 10.6 > sudo dscacheutil -flushcache

Windows > ipconfig /flushdns

Linux - There are many different distros and versions here, but one of the following should work > /etc/init.d/named restart

/etc/init.d/nscd restart

service nscd reload

sudo /etc/init.d/dnsmasq restart

service dnsmasq restart

How to remove the Google Chrome Name Badge

Google Chrome recently made a change to the display. They added a new feature that promises to be useful for some people, but it annoys me: My name being shown in the top right corner, allowing me to switch accounts.

While I can see the usefulness of the feature and I do have multiple google accounts, I rarely switch to them and usually do it through an incognito tab. Therefore, the added screen real estate that this feature takes up can be annoying. It’s pretty easy to get rid of it though.

First, go to the url Chrome://flags and then look for “Enable the new avatar menu”. Change this to disabled.

As an alternative if you don’t want to remove it, you can go to chrome://settings/manageProfile and change the name that is displayed as well as the icon.

Personally I’ve removed it, but it’s nice having options.

Adding an existing project to a Git repo

Just a quick tip for creating a new repo with existing files.

  1. Create a new repo on your preferred solution (I use Bitbucket but the other main choice is Github, it’s all about what works for you)

  2. Change to your project directory > cd ~/git/project

  3. Initialize the local directory as a repo > git init

  4. Add all files to the repo > git add .

  5. Write your first commit message > git commit -m ‘First commit’

  6. Tie your local files and remote repo together. For the url, an example would be ssh://git@bitbucket.org/daevien/nixgeek.git, but the method to find it varies depending on your provider. Bitbucket shows it at the top of the main page and GitHub shows it along the right side. > git remote add origin repo_url_here

  7. Have git verify it can connect to the remote repo > git remote -v

  8. Push your initial commit to the remote url > git push origin master

Thats it, your repo is created and initial update complete. Now to continue your content and update it as needed.