Zip files and UUID from Bash

Two quick items for .bashrc.  The archive command takes a folder name and zips its contents.  The UUID produces a unique number easily.

archive() { read -p "Enter folder name: " name && zip -rv9 $name-$(\
            date +"%Y-%m-%d-%H%M%p").zip $name; }
uuid() { UUID=$(cat /proc/sys/kernel/random/uuid) && echo $UUID; }

Grub2 change with latest CentOS update

The previous article regarding configuring Grub 2 for Windows 10 no longer works with the latest CentOS updates.  Here is the newer one.

File to edit:
/etc/grub.d/40_custom

Content to add:
menuentry "Windows 10 (system) (on /dev/sda1)" --class windows --class os {
    insmod part_msdos
    insmod ntfs
    insmod ntldr
    set root='(hd0,msdos1)'
    ntldr ($root)/bootmgr
}

Command to rebuild menu:
grub2-mkconfig -o /boot/grub2/grub.cfg

Data science work station

As of October 2017, these installations on Cent OS 7 create a functional data science workstation.

  1. yum install epel-release
  2. yum install ImageMagick
  3. yum install python-pip
  4. yum install python-devel
  5. yum install tkinter
  6. yum groupinstall “Development Tools”
  7. yum install R
  8. pip install –user parsedatetime
  9. pip install –user matplotlib
  10. pip install –user cython
  11. pip install –user scipy
  12. pip install –user xlsxwriter
  13. pip install –user pystan
  14. pip install –user fbprophet
  15. from R prompt of the user who uses R: install.packages(‘prophet’)

AMD black screen on Linux

The AMD Radeon HD 5770 PCIe card causes difficulty when installation Linux. The screen turns black very quickly and the monitor displays the no signal message on the DVI input. There are several sources that say to set a the boot parameter acpi_osi in Grub .1, 2 Even though ACPI 3 was available in 2005, newer systems often support version 1 or version 2.3 ACPI 1 and 2 specified _OS as a string that shows the operating system. ACPI 3 specified OSI. Many BIOS still use _OS. It is acpi_os=Linux, not acpi_osi=Linux that resolves the high fan speed and black screen issue with AMD cards and fan speeds on legacy chip sets. This may not work in all instances.It seems that some BIOS configuration need _OS rather than _OSI.

Add this to the boot parameters in the file
/etc/default/grub and
rebuild the boot menu via grub2-mkconfig -o
/boot/grub2/grub.cfg
.

Notes
1. What does the kernel boot parameter “set acpi_osi=Linux” do?
2. Fan not working after resume – Toshiba Satellite L300-214
3. What features does enabling ACPI 2.0 support in BIOS enable?
4. Before_OSI, there was _OS

SHA1 Hash in Right Click Menu

Minecraft’s server.properties file has a field for sha1 hash for resource packs. To use this, install nautilus-python and then copy this python script using any file name (such as sha1_hash.py) into ~/.local/share/nautilus-python/extensions.  This provides a SHA-1 hash on the right click menu.

# Robert Knight, 

from gi.repository import Nautilus, GObject
import hashlib
import urllib

class Sha1Menu(GObject.GObject, Nautilus.MenuProvider):
    """ This places a SHA-1 sum in the context menu in Nautilus.
    To use it, nautilus-python is required.  This script then goes in
    ~/.local/share/nautilus-python/extensions and should work after a 
    restart of Nautilus
    """
    def __init__(self):
        pass

    def menu_activate_cb(self, menu, file):
        print "menu_activate_cb",file

    def get_file_items(self, window, files):
        if len(files) != 1:
            return

        file = files[0]
        filename = urllib.unquote(file.get_uri()[7:])
        sha1sum = hashlib.sha1()
        with open(filename,'rb') as f:
            for chunk in iter(lambda: f.read(8192), ''):
                sha1sum.update(chunk)
        f.close()
        string = sha1sum.hexdigest()
        item = Nautilus.MenuItem(name="Sha1Menu::Show_File_Name",
                                 label="SHA-1: %s" % string,
                                 tip="SHA-1: %s" % string)
        item.connect('activate', self.menu_activate_cb, file)
        
        return [item]

SHA-1 is not the most secure, but is the version used in the Minecraft server for resource pack hashing.

Installing Cups remote administration and HP OfficeJet with CentOS

This relates to installing an Office Jet with hplip for uses on a print server.  A good Linux server can operate for weeks, months, and even longer without reboots.  hp-setup -i configures the printer.  This may not work over pure SSH console-only.  It will work with X over SSH via Xming by launching gnome-terminal and then running hp-setup -i in that terminal. The Cups web administration panel works via cupsctl –remote-admin. The firewall needs to allow traffic on port 631 via firewall-cmd –zone=public –add-port=631/tcp –permanent, and then firewall-cmd –reload. Command firewall-cmd –list-all shows the active ruleset.   Cups administration website works at http://10.10.10.10:631, replacing the IP address with the one for the Linux server.  Windows uses the print via network printer with address of the form http://10.10.10.10:631/printers/Officejet-4630-series, where the IP address is the machine with Cups remote access, and where the printer name is the actual one on the server.   The printer name appears in the Cups administration website.

Other notes: Best Practices for the Linux and Application Admins – Great article with mistakes and the lessons learned, Running a program as root on startup [creating a service for use with systemd] – excellent discussion on creating services.  Keeping SSH access secure – Basic analysis on dealing with SSH worms that try many username and password combinations. This page on Microsoft’s DevOps for bots has a lot of useful resources such as telemetry, testing, dashboards, and source examples related to bots and smart agents.

Linux tips and Microsoft DevOps

Best Practices for the Linux and Application Admins – Great article with mistakes and the lessons learned, Running a program as root on startup [creating a service for use with systemd] – excellent discussion on creating services.  Keeping SSH access secure – Basic analysis on dealing with SSH worms that try many username and password combinations. This page on Microsoft’s DevOps for bots has a lot of useful resources such as telemetry, testing, dashboards, and source examples related to bots and smart agents.

Desktop Shortcuts for Kids 5.2.2

Desktop Shortcuts for Kids has been updated to a new version.  It now works on any Windows version and launches the Chrome browser.  The Windows 10 edition (5.1) opens the sites in Edge browser.  This one adds Ryan ToysReview and HoneyheartsC channels on YouTube.  It also adds Starfall, Kinder Site, Chateau Meddybemps, and Scholastic’s Clifford the Big Red Dog.

Continue reading ‘Desktop Shortcuts for Kids 5.2.2’

Some data sources

Monetary Economics datasets sources: https://sites.google.com/site/davesmant/various/data-sets-sources
Economics Web Institute data sources: http://www.economicswebinstitute.org/ecdata.htm
Kenneth R. French data library: http://mba.tuck.dartmouth.edu/pages/faculty/ken.french/data_library.html
Carnegie Mellon Time Series Data Sets old: https://www.andrew.cmu.edu/user/rwerner/timeseries.htm
Carnegie Mellon University Datasets: http://guides.library.cmu.edu/datasets
Bureau of Labor Statistics Labor Force Statistics: https://www.bls.gov/cps/tables.htm
OECD Statistics: http://stats.oecd.org/
St. Louis Federal Reserve Bank (FRED): https://fred.stlouisfed.org/
St. Louis Federal Reserve Bank (FRED) Daily time series data: https://fred.stlouisfed.org/tags/series?et=&pageID=1&t=daily
City of Chicago data portal: https://data.cityofchicago.org/
Bureau of Labor Statistics: Bowling Green, KY Economy at a Glance: https://www.bls.gov/eag/eag.ky_bowlinggreen_msa.htm

 

Timezone and .bashrc

Changing Linux instances to a local time-zone from UTC. I found the easiest way thanks to ajtrichards.

sudo m /etc/localtime
sudo ln -s /usr/share/zoneinfo/America/Chicago /etc/localtime

For the local machine, to have a calculator in the command line, and the Zen Burn color scheme, and a title for the terminal window, this works as a good .bashrc.

 # .bashrc
 # Source global definitions
 if [ -f /etc/bashrc ]; then
 . /etc/bashrc
 fi
 # Uncomment the following line if you don't like systemctl's auto-paging feature:
 # export SYSTEMD_PAGER=
 # User specific aliases and functions
 calc () { echo "$*" | bc -l; }
 PROMPT_COMMAND='echo -ne "\033]0;Fedora 25: ${PWD}\007"'
 # Zen Burn color Scheme
 # Thanks to https://github.com/sonatard/color-theme-zenburn
 echo -ne '\e]12;#BFBFBF\a'
 echo -ne '\e]10;#DCDCCC\a'
 echo -ne '\e]11;#3F3F3F\a'
 echo -ne '\e]4;0;#3F3F3F\a'
 echo -ne '\e]4;1;#705050\a'
 echo -ne '\e]4;2;#60B48A\a'
 echo -ne '\e]4;3;#DFAF8F\a'
 echo -ne '\e]4;4;#506070\a'
 echo -ne '\e]4;5;#DC8CC3\a'
 echo -ne '\e]4;6;#8CD0D3\a'
 echo -ne '\e]4;7;#DCDCCC\a'
 echo -ne '\e]4;8;#709080\a'
 echo -ne '\e]4;9;#DCA3A3\a'
 echo -ne '\e]4;10;#C3BF9F\a'
 echo -ne '\e]4;11;#F0DFAF\a'
 echo -ne '\e]4;12;#94BFF3\a'
 echo -ne '\e]4;13;#EC93D3\a'