How to configure macOS TimeMachine and Ubuntu 20.04

Recently I wanted to be able to backup my Mac via TimeMachine, but unfortunately I did not have a large enough HDD to back up, so I’ve decided to backup to one of my servers. Not until recently that was not an option until I ran into a blog post that produced an step by step configuration to run successfully, but what I did find out was that my server was getting full and TimeMachine did not do a good enough job deleting old backups. So, I found a single command to limit the backups, but what I found was that if the plist has been already copied (meaning a backup was already ran), the new limits won’t be recognized. So you will need to run a new backup with carrying the limits on the new plist to the server.

Below are the steps to successfully be able to config a TimeMachine backup server with limits on your backups so you don’t run out of storage 😉 .

  1. Ensure that you have a ubuntu 20.04 LTS image running with enough storage to perform the backups
  2. Run sudo apt install -y netatalk avahi-daemon
  3. Run sudo vi /etc/netatalk/afp.conf
  4. Add a section for your Time Machine:
    [Time Machine]
      path = /media/path/to/backups
      time machine = yes
  5. Create a directory to act as the Time Machine:
    sudo mkdir -p /media/path/to/backups
  6. Run sudo chown nobody:nogroup /media/path/to/backups
  7. Run sudo chmod 777 /media/path/to/backups
  8. Restart netatalk:
    sudo service netatalk restart
  9. Now, on your Mac, before doing anything else, might be smart to put a limit on your backup.  The command below will put a 100GB limit.
    sudo defaults write ~/Library/Preferences/com.apple.TimeMachine MaxSize 102400
  10. At this point… you should be able to open the Time Machine settings in System Preferences and use Select Disk… to pick your new Time Machine backup drive. Where /media/path/to/backups should show up on the path.
  11. Enjoy your Time Machine backups 🙂

sources

https://www.grizzly-hills.com/2019/11/02/ubuntu-19-10-setting-up-time-machine/

How to update python packages to the latest version






Recently I wanted to update my python packages and really wasn’t a way to easily update them until I ran into Stack Overflow question on how to do it. Which it worked neatly.

Here are the steps on how to do it in your python environment

pip list --outdated --format=freeze #list outdated packages
pip freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U

If you have a specific python version, you can invoke it this way

pip2.7 list --outdated --format=freeze #list outdated packages
pip2.7 freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 sudo -H pip2.7 install -U

Sources
https://stackoverflow.com/questions/2720014/upgrading-all-packages-with-pip

Docker container + X11 on macOS = Awesome

I’ve been exploring dockerizaton lately more and more and I think I like the idea of having my apps in containers.  I am not going to lie, it does take some time to get used to, but it is pretty cool the things that you can do.

One thing that I think I wanted to accomplish was able to run X11 apps through docker.  I found Docker Headless VNC container and that was slick.  Where I was able to run a whole Xfce environment within a Docker container!!! kudos to those folks.  Now, my challenge was that in my case, I didn’t want a fat image and/or configure each app to download of configuring. So, this wasn’t my solution at this time.  So, I decided to explore further and found a way to run X11 from a Docker container in macOS.  Below are the steps on how to accomplish this.

  1. Install XQuartz (X11),  Docker and homebrew.  You can follow their respective installation process.
  2. Install socat which is a “multipurpose relay.”  This will allow us to call the display.
    brew install socat
  3. Create you local Dockerfile.  In this particular case, I am using Ubuntu latest (which at the time of this post is 16.04.1 LTS).  On your terminal, you can do “vi Dockerfile” and paste the info from below in that file.
    FROM ubuntu:latest
    
    RUN apt-get update && apt-get install -y firefox
    
    RUN useradd -ms /bin/bash developer && \
     echo "\ndeveloper ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
    
    USER developer
    ENV HOME /home/developer
    CMD /usr/bin/firefox
  4. Then, let’s build the Docker image by doing the following…
    docker build -t firefox .
  5. Now, on a different terminal, run the following command…
    socat TCP-LISTEN:6000,reuseaddr,fork UNIX-CLIENT:\"$DISPLAY\"
  6. Then come back to your old terminal (or a different one) and run this command
    docker run -ti --rm \
    -e DISPLAY=$(ipconfig getifaddr en0):0 \
    -v /tmp/.X11-unix:/tmp/.X11-unix \
    firefox
  7. At this point, you should have opened a Firefox instance from your Docker container through X11 on macOS 🙂
    If you didn’t… take a look at the steps again.  Happy dev and opening other X11 instances.

Sources:

http://fabiorehm.com/blog/2014/09/11/running-gui-apps-with-docker/

https://stackoverflow.com/questions/16296753/can-you-run-gui-apps-in-a-docker-container#

https://github.com/mbessler/docker-gnucash

https://hub.docker.com/r/palshife/ssh/

https://hub.docker.com/r/palshife/gnucash/

https://github.com/ConSol/docker-headless-vnc-container

https://askubuntu.com/questions/192050/how-to-run-sudo-command-with-no-password

https://stackoverflow.com/questions/27701930/add-user-to-docker-container

https://askubuntu.com/questions/842572/file-in-etc-sudoers-d-not-recognized

Python Mediacom Data Usage Prediction (mdup) via SMS

After years of monitoring my data usage and going over, I decided to make a dashboard (yes, like your car dashboard) for my ISP data usage.

I decided to publish this piece of code with the hopes that would help other people setting something up, where they could be notified via text message/SMS on their current data usage and predict what their usage will be by the end of the [billing] cycle.

Here is the repo -> https://github.com/blacknred0/mdup and the name of the project is “Mediacom Data Usage Prediction (mdup) via SMS”.

Python – Install pip and virtualenv and distribute without sudo access

Recently I started to so some dev on python and noticed that on the server that I was going to do the work I don’t have sudo access.  In the past, this has not been an issue, but in this case getting sudo access is almost impossible and not doable.  So my only option is being able to run pip (to install python packages) as an user.

After painfully researching on how to successfully do this, I was able to make it work.  I hope that this helps others in the future. Good luck!

  1. Make sure that you have python installed
    which python
  2. Download latest version of virtual environment (virtualenv)
    wget https://pypi.python.org/packages/d4/0c/9840c08189e030873387a73b90ada981885010dd9aea134d6de30cd24cb8/virtualenv-15.1.0.tar.gz#md5=44e19f4134906fe2d75124427dc9b716
    
  3. Unpack source tarball
    tar -xzf virtualenv-15.1.0.tar.gz
  4. Create your package environment
    python virtualenv-15.1.0/virtualenv.py py-packages
  5. Delete the virtual environment folder
    rm -rfv virtualenv-15.1.0
  6. Install virtualenv into your environment.  You can use the package that you downloaded or using pip.
    py-packages/bin/pip install virtualenv-15.1.0.tar.gz

    or

    py-packages/bin/pip install virtualenv
  7. If you want to clone environments you can do the following
    py-packages/bin/virtualenv py-clone1

Sources:
http://stackoverflow.com/questions/4324558/whats-the-proper-way-to-install-pip-virtualenv-and-distribute-for-python
https://pypi.python.org/pypi/virtualenv
https://packaging.python.org/installing/

Big Data, Data Science – Combo Course Training Classes Online | Big Data, Data Science – Combo Course Courses Online

Enroll for Big Data, Data Science – Combo Course Certification training classes online.Be a Big Data, Data Science – Combo Course Expert! ✓237 Hrs Learning ✓404 Hrs Projects ✓Life Time Access ✓24 X 7 Support ✓Job Assistance.

Source: Big Data, Data Science – Combo Course Training Classes Online | Big Data, Data Science – Combo Course Courses Online

Installing Multiple Version of R on the same machine for macOS (Mac)

 

Recently I wanted to install an application on a Mac, but it required an old version of R (3.2).  On Linux and Windows, that is easy, since you install the application on its own path.  Now, on a Mac, you can do it as well, but it will require extra work if you build it from source.  There is something better!!!  Here I outline what you can do easily…

Note that this illustration assumes that you want R 3.2 & 3.3 on the same system and be able to run either of them when you choose.

  1. Let’s assume that you already installed R 3.3 by downloading it from CRAN.
  2. To install R 3.2, you will need to download an old version from CRAN old R
  3. Before installing R 3.2, run the following commands
    sudo pkgutil --forget org.r-project.R.mavericks.fw.pkg
    sudo pkgutil --forget org.r-project.R.mavericks.GUI.pkg
    sudo pkgutil --forget org.r-project.R.mavericks.GUI64.pkg
  4. Install R 3.2 by double clicking on *.pkg
  5. Now, download and install RSwitch (RSwitch link), which it will allow you to switch between R version by clicking on the R version of your like.
    image

Sources:

Installing Multiple Version of R in parallel on the same machine – Mac OS X | R-bloggers

https://stat.ethz.ch/pipermail/r-sig-mac/2011-August/008534.html

https://cran.r-project.org/bin/macosx/RMacOSX-FAQ.html#How-can-R-for-Mac-OS-X-be-obtained-and-installed_003f

 

Ranking algorithm for the layman – New Modeler Extension

There are a lot of ranking algorithms for you to use and represent your data. Now, that doesn’t mean that the ranking algorithm is the most appropriate for your situation. It all depends on what you are trying to accomplish and who will be the audience of your final product. Some ranking algorithms could be too sophisticated to be actually understood by a layman’s type of person. The reasoning to develop this particular piece of work was to not only rank specific type of datasets but be able to explain how the ranking is performed for the layman’s type of person.

main-view

The inspiration for creating this node came from this site -> http://www.psychstat.missouristate.edu/introbook/sbk14.htm. Now that this node exists, it allows us to reuse it over and over. According to the author of the site, transforming raw scores into percentile ranking, will enable us to: 1) Give us meaning and interpret the scores and 2) Provide a direct comparison between scores.

Sample Output:
results-after-ranking

If you want to learn more and try this extension go to the GitHub Repository. You can find my extension and all others in thePredictive Analytics Gallery.

Source: Missouri State – Score Transfromations

Source: | Ranking algorithm for the layman – New Modeler Extension