Category Archives: applications

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”.

Sophos UTM 9 blocking continuity between iPhone, iPad, Mac

I just recently migrated from Untangle 11.2 to Sophos UTM to give it a ride and noticed that a lot of things are blocked (which is a good thing if you know what you are doing and need to unblock it).  Just recently I noticed that I couldn’t make any more calls by using my iPad or Mac through my iPhone.  So, continuity was not working like it was before.

I went to the Apple site (see sources), but couldn’t figure out what port or services were the one that needed to be allowed by the firewall.  So, after analyzing dropped packages by the firewall, I noticed a pattern and created the following firewall rule.  Since the creation of this firewall rule, I haven’t had any more issues with continuity nor downloading content from games in Game Center.

Overall network mapping: Internal network -> Allow ports 6384:16472 -> Any

  1. Go to “Network Protection”
  2. “Firewall”
  3. Click “New rule…”
  4. Under “Sources:” add “Internal (Network)”
  5. Under “Services” (you probably haven’t created this, so we are going to do it the long way), click on the “+” to add a new service
  6. Give it a name.  Probably “Apple Continuity”
  7. On “Destination port:” allow ports from “16384:16472”
  8.  Under “Comment” add these ports are “Real-Time Transport Protocol (RTP), Real-Time Control Protocol (RTCP)” for “iChat AV (Audio RTP, RTCP; Video RTP, RTCP), FaceTime, and Game Center”
  9. Click “Save”
  10. Under “Destinations:” add “Any”
  11. (Optional) Add comment
  12. Click “Save”

Now you should be able to use Apple continuity by handing over calls over your iPad and/or Mac from your phone under the same network.

Hopefully Sophos UTM could include this as default with their future releases.

Source: TCP and UDP ports used by Apple software products – Apple Support

How to install a new version of python in RHEL 6

So, if you have RHEL 6, you might be stuck with Python 2.6.  But, not really.  Even though you might not be able to install a new version of python using yum, you can still download a new version of python and install it in your environment.  Now, you can install it and replace the current version or you can install another version and have two python in your system.

  1. Install GCC by typing
    sudo yum install gcc
  2. Go to
    cd /usr/src/
  3. Now, let’s download a release from python.org. In this example we will be using Python 3.5.0.

    sudo wget https://www.python.org/ftp/python/3.5.0/Python-3.5.0.tar.xz sudo tar xf Python-3.5.0.tar.xz sudo cd Python-3.5.0
  4. Let’s compile
    sudo ./configure
  5. Let’s build the package
    sudo make
  6. Now, to install it you have two options.  You can either overwrite the python executable or you can install as concurrent instance.
    1. If you want to overwrite the OS python executable
       sudo make install
    2. If you want to install concurrent (not overwritting the OS executable)
       sudo make altinstall
  7. Now let’s link it so others could use it
     sudo ln -s /usr/local/bin/python3.5 /usr/bin/python3.5
  8. Now test it by invoking the following command
    python3.5 -V

    You should have the following result

    "Python 3.5.0"
  9. If you get that result let’s continue, otherwise look back and see what step you missed.
  10. Now that you have python 3.5 install along with 2.7, you might want to install pip to handle package installations.
  11. In order to do that, let’s first download pip.
    cd ~/Downloads
    wget https://bootstrap.pypa.io/get-pip.py
  12. Now, let’s install it
     sudo python3.5 get-pip.py

    If setuptools is not installed, get-pip.py will automatically install setuptools.

  13. To check pip if installed successfully
     pip3.5 -V

    You should have the following result

     "pip 7.1.2 from /usr/local/lib/python3.5/site-packages (python 3.5)"
  14. If you want others to use pip with sudo command, you probably want to do this
  15. sudo ln -s /usr/local/bin/pip3.5 /usr/bin/pip3.5
  16. And there you go!  Now you have two python versions and two pip versions running concurrently on your OS.

Sources

https://www.python.org/

https://pip.pypa.io/en/stable/installing/

http://stackoverflow.com/questions/8087184/installing-python3-on-rhel

http://stackoverflow.com/questions/6587507/how-to-install-pip-with-python-3

IBM SPSS Modeler Streams with Excel export nodes fail with Insufficient memory for JVM – United States

From time to time you might run into some issues with SPSS Modeler of running out of memory on Java Virtual Memory.  The way you fix it is by expanding the allocated JVM.

So, in order to do this we mustdo the following…

  1. Close SPSS Modeler if you have it open
  2. Open C:\Program Files\IBM\SPSS\Modeler\\config\jvm.cfg as Administrator
  3. Find the line with the following
    options, "-Xmx256m"
  4. Now change "-Xmx256m" to a new value where 256m = RAM.  So if you would like to lets say allocate 1G of RAM, then you will change it to options, "-Xmx1024m".

Source: IBM Streams with Excel export nodes fail with Insufficient memory for JVM – United States

How to make Thunderbird portable

The title to this post might be deceiving, since I am not going to walk you through on how to make Thunderbird portable, but rather how to make Thunderbird portable cross different devices by using a file sharing tool (ie. Dropbox).

Let’s say that you have two Linux, Mac, or Windows machines and would like to have your Thunderbird mailboxes and configurations to be the same.  So, whenever you make a change on one machine, it will synchronize on the other.  Key that you want to consider is how much space your Thunderbird profile is taking and if you will have enough space in Dropbox.

The following was tested in two different Ubuntu Linux machines (I also did it on Windows machines, but the steps below are for Linux).  Here is what you will need to do.

  1. Make sure that you have Thunderbird configure the way you want it/like it on PC#1
  2. Then close out Thunderbird to make the following changes
  3. Go to folder /home/pc1_user/.thunderbird/
    where pc1_user will be change to your actual user profile
  4. You will see couple of files and folders in there.  The ones that you will be interested are “profiles.ini” and “randomfoldername.default”
    where “randomfoldername.default” will be something like this “z85gg4eg.default”
  5. Move “randomfoldername.default” to your Dropbox account.  In my case I created a folder for Thunderbird where this new folder will be under.
    Here is how it looks… /home/pc1_user/Dropbox/Thunderbird/randomfoldername.default
  6. Now, let’s update “profiles.ini”.  Your configurations might look like something like this
    [General]
    StartWithLastProfile=1
    [Profile0]
    Name=default
    IsRelative=1
    Path=randomfoldername.default

    What you are going to do is to make some modifications to this file by changing “IsRelative” and “Path” to look this this

    [General]
    StartWithLastProfile=1
    
    [Profile0]
    Name=default
    IsRelative=0
    Path=/home/pc1_user/Dropbox/Thunderbird/randomfoldername.default
  7. Now you should be able to open Thunderbird on the computer with no problem :).  Just note that by doing this doesn’t fix your problem on having Thunderbird synchronized in two computer.
  8. You will need to do something similar on PC#2.
    1. Make sure that you have Thunderbird installed
    2. Make sure that you have Dropbox installed
  9. Go to folder /home/pc2_user/.thunderbird/
    where pc2_user will be change to your actual user profile
  10. You will see couple of files and folders in there.  The one that you will be interested are this time is only the “profiles.ini”.
  11. Now, let’s update “profiles.ini”.  Your configurations might look like something like this
    [General]
    StartWithLastProfile=1
    [Profile0]
    Name=default
    IsRelative=1
    Path=randomfoldername.default

    What you are going to do is to make some modifications to this file by changing “IsRelative” and “Path” sections to look this this

    [General]
    StartWithLastProfile=1
    
    [Profile0]
    Name=default
    IsRelative=0
    Path=/home/pc2_user/Dropbox/Thunderbird/randomfoldername.default
  12. There you have it!!! Now you can enjoy Thunderbird in two (or many more) machines with the same settings, mailboxes, and configurations.

Sources:
http://kb.mozillazine.org/Running_from_a_USB_drive_(Thunderbird)
http://www.makeuseof.com/tag/access-your-personalised-thunderbird-client-on-any-computer-worldwide/
http://www.lifehacker.com.au/2011/05/how-to-sync-your-desktop-email-client-across-multiple-computers/

How to make GPG4Win portable app

Lately I been using PGP more and more… and I wanted to have my portable application on a flash drive where I could carry all of the private and public keys (of course that if I loose my flash drive, I am at risk – I know that). But, there is really not good documentation that walks through a first time user on how to accomplish this.  So, here is my attempt to those first time users on how to do it.

  1. You need a Windows machine (physical or virtual)
  2. Download Gpg4Win -> http://www.gpg4win.org/
    In my case, I tested this with version 2.2.4
  3. When installing Gpg4Win, make sure that you have enable all of these options
    GnuPG 2.0.27
    Kleopatra 2.2.0-git945878c
    GPA 0.9.7
    GpgOL 1.2.1
    GpgEX 1.0.1
    Claws Mail 3.9.1
    Kompendium (de) 3.0.0
    Compendium (en) 3.0.0
  4. Once you are done with the installation, then you can run the following command in order to make your own Gpg4Win portable application.  Keep in mind that you can go two different routes.  Full or Lite.  In my example, I will show you how to have it fully loaded.
  5. Open command prompt (CLI)
  6. cd to the path where GPG4Win is located
    If you use the defaults it will be at “C:\Program Files (x86)\GNU\GnuPG\”
  7. Run “mkportable.exe –full –verbose TARGETDIR”
    where TARGETDIR in this case will be “E:\gpg4winapp”
  8. Then once the program runs, you will be able to open Kleopatra and there you have it
  9. Enjoy!!!

Streaming movies and music from iTunes to iPad to iPhone

Not until today that I found the right article to be able o stream from my iTunes to any of my apple devices.  Previously any time that I tried to make such a research, I found a bunch of apps that you would need to pay for and do some configuration on your PC or Mac.  Well, the article below will go over that you can do such a sharing for free by just using Apple “Home Sharing”.  … and let me tell you, it works slick!!! I was able even to stream my >15k songs to my devices :).

  1. First things first… enable iTunes Home Sharing on your PC so open iTunes
  2. Go to File “Home Sharing” -> “Turn On Home Sharing”
    Login with your Apple ID and password to identify your Home Shares
    With your Apple ID entered, click on “Create Home Share”
  3. Now let’s configure your devices….
  4. Go to “General” -> “Videos and scroll down and login with your Apple ID and password
  5. Open the Video app on the device.
  6. Then your shared library will show up 🙂
  7. Click on that library and you will be able to see all of your videos.
  8. Then click on the video that you would like to watch and enjoy

I’ve tested the steps form 5 through 9 using the Music app as well from my device.  The only difference is is that you would have to click on “More” to make the switch from sharing library to local library on the device.

I am Therefore iPad: Home Share iTunes Movies to iPad.