Enable TRIM support on Mac OS X Snow Leopard 10.6.8

With the introduction of solid state drives (SSDs), Apple began enabling TRIM support only on its OEM supplied drives to ensure a predictable compatibility with the TRIM protocol as some 3rd party drives weren’t fully supported.

To manually override and enable this feature on a new SSD supporting a proper implementation of TRIM, the following shell commands will do the trick.

Patching the kernel extension (kext) responsible is unique to your version of OS X (or macOS). Third party enabling software does exist.

To patch the kext for TRIM support in Mac OS X Snow Leopard 10.6.8, fire up a terminal window and enter the following:

Begin by backing up the original kext driver to your home directory

sudo cp /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext /Contents/MacOS/IOAHCIBlockStorage /IOAHCIBlockStorage.original

Then find and replace the segment of code responsible for limiting TRIM support to Apple OEM devices only.

The following code is specific to 10.6.8 only!

sudo perl -pi -e 's|\x41\x50\x50\x4c\x45\x20\x53\x53\x44|\x00\x00\x00\x00\x00\x00\x00\x00\x00|g' /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage

After patching, purge all kext caches in OS X with the following commands

sudo kextcache -system-prelinked-kernel
sudo kextcache -system-caches
sudo touch /System/Library/Extensions/

The last step is restarting your mac. You can do so manually or, if you still have the terminal window open, enter the following

sudo reboot

In case you no longer wish to have this enabled, simply restore the original kext file you saved in the first step

sudo cp /IOAHCIBlockStorage.original /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage

It took some trial and error to assemble this guide as most resources I’ve found were either incorrect or were for other macOS/OS X versions.

For other OS X or macOS versions, simply replace the search and replace function in step 2 with the following

10.7.5, 10.8.1, 10.8.2

sudo perl -pi -e 's|(\x52\x6F\x74\x61\x74\x69\x6F\x6E\x61\x6C\x00{1,20})[^\x00]{9}(\x00{1,20}\x4D)|$1\x00\x00\x00\x00\x00\x00\x00\x00\x00$2|sg' /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage

10.8.3 to 10.9.3

sudo perl -pi -e 's|(\x52\x6F\x74\x61\x74\x69\x6F\x6E\x61\x6C\x00{1,20})[^\x00]{9}(\x00{1,20}\x54)|$1\x00\x00\x00\x00\x00\x00\x00\x00\x00$2|sg' /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage

10.9.4 & 10.9.5

sudo perl -pi -e 's|(^\x00{1,20})[^\x00]{9}(\x00{1,20}\x54)|$1\x00\x00\x00\x00\x00\x00\x00\x00\x00$2|sg' /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage

Resources and references used include a gist by clarencesong on GitHub, a MacTrast post on the 2011 Trim Support Enabler 1.1 third party tool by Oskar Groth and a functional 10.6.8 patch code by MacKonsti.

Newer(est) macOS laptops can benefit from the latest version of Oskar Groth’s Trim Enabler 4 app. Although I’ve never used it, it will probably save you the headache of being on top of the latest updates/ changes to macOs.

Lenovo Y580

Lenovo Y580 Windows 10 Update with Driver Guide

The Lenovo Y580 Laptop was released in 2012 and shipped with an OEM version Windows 7 Home Premium. When Microsoft started rolling out Windows 10, it offered a free upgrade to their latest O/S.

Unfortunately, the Y580 (and many other) laptops featured many small conveniences like OneKey Recovery, mute, movie mode and special function buttons which do not work well with the Windows 10 Upgrade, if at all.

Here are the original 2012 specifications for the Y580:

Description IdeaPad Y580 Upgrade Support
CPU 3rd Generation Intel® Core™ i7-3630QM (2.40GHz 6MB Cache) (45W TDP) Support up to Intel® Core™ i7-3940XM Extreme Edition (3.0GHz-3.9GHz ) 55W TDP – Confirmed

(Will reach ~3.5-4 hours with battery saver on (CPU throttle and lower screen brightness) for office tasks.)

Operating System Windows 7 x64/ Windows 8 x64 – Home Premium  Latest Win 10 variant
Memory 8GB (DDR3) 16GB (DDR3) supported – confirmed
Graphics NVIDIA® GeForce® GTX660M 2GB with DirectX® 11
Dimensions 385mm x 255mm x 35.7 mm (15.2″ x 10.0″ x 1.4″)
Camera 1.0MP HD webcam
Display
  • 15.6″ LED backlit HD display (1366×768)
  • 15.6″ LED backlit FHD display (1920×1080)
Upgrade to FHD possible from OEM HD display – confirmed

Caveat: Backlight control reduced to 2 settings: 100% and ~20%. Requires new LCD connector cable (eBay) and new FHD panel (Online Retailer – Search for “Lenovo Y580” + model “2099” or “20132”)

Weight 2.8 kgs (6.15 lb)
I/O Ports
  • 3 x USB 3.0 ports
  • 1 x USB 2.0 ports
  • 6-in-1 card reader (SD, SD-Pro, MMD, MS, MS-Pro, XD)
  • Headphone jack
  • Mic jack
  • S/PDIF
  • 1 x VGA port
  • 1 x HDMI port
  • 2 x mini PCle (1 free)
  • Gigabit RJ-45
Storage
  • HDD: 500GB, 750GB, 1TB (5,400 rpm)
  • HDD: 500GB (7,200rpm)
  • SSD: 32GB
Network/ Connectivity
  • Intel Centrino Wireless-N 2200BGN
  • Qualcomm Atheros AR8161 PCIe 10/100/1000M Ethernet LAN
  • Broadcom or Atheros Bluetooth® 4.0
 Fn + F5 Radio switch interface not supported. Follow workaround below. All included hardware is fully supported and functional.
Keyboard Backlit AccuType keyboard  OS independent
Battery Life Up to 5 hours (6-cell battery)  Lenovo power management no longer supported – only caveat: cannot switch between fully-charged battery mode and battery protection (60% charge) modes.
Durability Features Real metal shell
Security Features
  • OneKey Rescue System
  • VeriFace face-recognition software
 OneKey Rescue System will no longer work/install. It can be restored successfully using previously burnt complete Recovery DVDs (will restore all OEM partitions, Win 7 and Lenovo software)

Updating your Lenovo Y580 to Windows 10 is a slightly frustrating process which WILL leave you without a few important features (notably WiFi). Here is how to anticipate and update to a functional state.

 

Feature Windows 10 Upgrade Status Fix and/or Workaround
 Intel(R) 7 Series/C216 Chipset
  • Generic Win 10 driver can be replaced with the Lenovo-provided Win 7 x64 Intel AHCI driver
  •  Download and install Lenovo Win 7 x64 AHCI driver
Intel(R) 7 Series/C216 Chipset USB 3.0 support
  • Native Win 10 Microsoft driver works as-is but requires appropriate BIOS settings to enable 3.0 speeds using native Win 10 driver.
  • 3.0 speed requires the following settings in BIOS -> Peripherals -> USB Configuration
  • XHCI Pre-Boot Drivers = Enabled
  • HXCI Mode = Enabled
NVidia GeForce GTX 660M
  • Default NVidia GeForce drivers work as expected – download fron NVidia
Qualcomm Atheros AR8161 PCIe Gigabit LAN 
  •  Windows 10 provides appropriate driver
WiFi Adaptor 
  • Drivers install out-of-box but digital hardware switch gets reset to OFF position
  • This cannot be reset in Windows
  • Use any live Linux distro on USB/CD to boot, toggle WiFi On/Off
  • Leave toggle ON and confirm connectivity to WiFi network
  • Reboot into Windows – you will now be able to toggle it ON/OFF using the native Win 10 notification area
  • Note that the Fn + F5 Lenovo Power Management toggle no longer works
Bluetooth Adaptor 
  •  Does not install out-of-box
  • Download and install the Lenovo Win 8.1 x64 Broadcom/Atheros Bluetooth driver.
  • Note that the Fn + F5 Lenovo Power Management toggle no longer works
Keyboard
  • Backlight – works with Fn key as expected
  • Fn Keys – all work with the exception of the wireless devices one
  • OneKey Recovery
  • Volume Mute – Works with dedicated mute key
  • Cinema Mode – Cinema mode software no longer supported
Lenovo Power Management
  •  No update available to support Win 10
  • No support for entering battery saver program (60% max charge)
  •  No workaround – use windows’ built-in power management.
  • Only 100% battery charge level is supported

Compiled from numerous sources:

BMW NCS Expert Coding

BMW vehicles have specialized modules (simple computers) responsible for different regions of the car.

Available modules include:

  • ABG – Airbag module
  • AKMB – Instrument cluster
  • DSC – Dynamic stability control
  • EWS – Immobilizer
  • FTM – Rearview module
  • GM3 – General Module 3,4,5 etc
  • IHKA – Heater/AC
  • KMB
  • LCM – Light control module
  • LWR
  • LWS
  • RAD – Radio
  • RLS – Rain/light sensor
  • SM – Seat memory

NCS was the official BMW software used both in factory and dealerships until ~2008. This covered the following chassis models:

 

NCS Expert was leaked online to the public probably in the early 2000’s and allows reading and re-coding of convenience features and other specialized vehicle settings (most of which you shouldn’t touch)

Reading and parsing the output trace files (configuration files) from each module is done with the help of a software called NCS for Dummies. It will allow reading and modification of trace files with allowed options. Modified trace files can be re-flashed onto the car with NCS Expert.

Imformation was compiled from the following sources:

  • http://ncs-expert.com
  • https://jimmyselix.blogspot.ca/2016/01/mini-cooper-coding-ncsexpert-on-windows.html

How to upgrade php 5.6 to 7.0 on Ubuntu 14.04 LTS

Upgrade your server’s php installation from 5.6.x to 7.0.x on Ubuntu 14.04 LTS

Continuing with the php upgrading series, this guide will show you how to bring your standard Ubuntu 14.04 LTS Server installation to 7.0.x. The 7-series PHP releases focus on speed. You can read about the latest new features.

Begin by adding ‘s newest (as of 2016) PPA repository and updating sources as follows:

Note: If you’ve followed the 5.5 to 5.6 upgrade guide, you already have the PPA added.

sudo LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
sudo apt-get update

Next we should list all existing php 5.6.x packages (so we know which equivalent version need to be loaded for 7.0.x):

Warning: This has been tested with Ubuntu 14.04 LTS and PHP 5.6.19 and might be valid for this release only! Use at your own risk!

Issue the following command:

dpkg --get-selections | grep php

This example gave the following output:

dpkg --get-selections | grep php

libapache2-mod-php5.6                           install
php-pear                                        install
php-xml-parser                                  install
php5.6                                          install
php5.6-cli                                      install
php5.6-common                                   install
php5.6-curl                                     install
php5.6-dba                                      install
php5.6-dev                                      install
php5.6-gd                                       install
php5.6-intl                                     install
php5.6-json                                     install
php5.6-ldap                                     install
php5.6-mbstring                                 install
php5.6-mcrypt                                   install
php5.6-mysql                                    install
php5.6-opcache                                  install
php5.6-pgsql                                    install
php5.6-readline                                 install
php5.6-soap                                     install
php5.6-sqlite3                                  install
php5.6-xml                                      install
php5.6-xsl                                      install
php5.6-zip                                      install
pkg-php-tools                                   install

Download the php7.0.x versions them like so:

sudo apt-get install php7.0 php7.0-cli php7.0-common php7.0-curl php7.0-dev php7.0-gd php7.0-intl php7.0-json php7.0-ldap php7.0-mbstring php7.0-mcrypt php7.0-memcache php7.0-memcached php7.0-mysql php7.0-pgsql php7.0-readline php7.0-sqlite php7.0-xml php7.0-xsl libzip4 php7.0-zip

Apt might also include a few additional packages, proceed (Y).

Next, disable the php5.6 apache2 module and load the php7.0 apache2 module in its place. End by restarting your apache2 server.

sudo a2dismod php5.6
sudo a2enmod php7.0
sudo service apache2 restart

All done 🙂

If you would like to support Ondřej Surý and his efforts, visit his donation page for a way to do so!

The official PHP Migration (5.6.x to 7.0.x) Notes can be found here. Additional migration details, change logs, new/ deprecated features for all other migrations are also present.

How to upgrade php 5.5 to 5.6 on Ubuntu 14.04 LTS

Upgrade your server’s php installation from 5.5.x to 5.6.x on Ubuntu 14.04 LTS

The standard Ubuntu 14.04 LTS Server installation maintains PHP 5.5.x. Upgrading your PHP installation potentially speeds up your installation and provides the latest new features.

Begin by adding Ondřej Surý’s newest (as of 2016) PPA repository and updating sources as follows:

sudo LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
sudo apt-get update

Next we should list all existing php 5.5.x packages (so we know which equivalent version need to be loaded for 5.6.x):

Warning: This has been tested with Ubuntu 14.04 LTS and PHP 5.5.9 and might be valid for this release only! Use at your own risk!

Issue the following command:

dpkg --get-selections | grep php

This example gave the following output:

dpkg --get-selections | grep php

libapache2-mod-php5                             install

php-pear                                        install
php-xml-parser                                  install
php5                                            install
php5-cli                                        install
php5-common                                     install
php5-curl                                       install
php5-dev                                        install
php5-gd                                         install
php5-intl                                       install
php5-json                                       install
php5-ldap                                       install
php5-mcrypt                                     install
php5-memcache                                   install
php5-memcached                                  install
php5-mysql                                      install
php5-pgsql                                      install
php5-readline                                   install
php5-sqlite                                     install
php5-xsl                                        install
pkg-php-tools                                   install

Download the php5.6.x versions them like so:

sudo apt-get install php5.6 php5.6-cli php5.6-common php5.6-curl php5.6-dev php5.6-gd php5.6-intl php5.6-json php5.6-ldap php5.6-mbstring php5.6-mcrypt php5.6-memcache php5.6-memcached php5.6-mysql php5.6-pgsql php5.6-readline php5.6-sqlite php5.6-xml php5.6-xsl libzip4 php5.6-zip

Apt might also include a few additional packages, proceed (Y). Next disable the php5.5 apache2 module and load the php5.6 apache2 module in its place. However, you should consider adding the compatibility PPA maintained by Ondřej Surý before restarting your apache2 server.

sudo apt-get update && apt-get upgrade
sudo LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php5-compat
sudo apt-get update
sudo apt-get dist-upgrade
sudo a2dismod php5.5
sudo a2enmod php5.6
sudo service apache2 restart

All done 🙂

If you would like to support Ondřej Surý and his efforts, visit his donation page for a away to do so!

The official PHP Migration (5.5.x to 5.6.x) Notes can be found here. Additional migration details, change logs, new/ deprecated features for all other migrations are also present.

This guide was compiled into one using pieces (new and old) from:

Compaq Presario 2200 Desktop

Compaq Presario 2200 Restoration

Prior to its acquisition by HP, Compaq produced a wide number of desktop PCs. The Compaq Presario lineup was a small form factor desktop lineup and included the 2200. It was produced between 1997 and 1998.

The original Presario 2200 specifications were as follows:

  • Cyrix Media  180 MHz CPU (66MHz Bus Speed) (GXI-180BP)
  • 16MB onboard RAM – 12MB dedicated as VRAM
  • Cyrix CX 5510 onboard GPU (CX5510Rev2)
  • Analog Devices SoundPort audio processor (AD1847 JP)
  • 2 x 8MB Fujitsu 72-pin EDO SIMM RAM
    • Expandable to 64MB (80MB total with onboard RAM)
  • 1 x 8-bit ISA expansion slot populated with a 33.6K Modem (Firmware upgradable to 56K)
  • 1.6GB IDE Quantum Bigfoot HDD
  • NEC 1.44″ FDD
  • 8X CD-Rom Drive
  • 51W Steady-state power supply

Compaq SoftPaq (OEM) drivers included:

  1. Compaq 33.6K Modem -> 56K Hardware upgrade card. Firmware after 56K add-on hardware card (SoftPaq 9451)
  2. Cyrix GX 5510 onboard video (SoftPaq 5015 – Win95/98 driver)
  3. Analog Devices SoundPort AD 1847 (SoftPaq 7341 – Win95/98 driver)

Bought originally in ’97, it saw moderate use and now, the motherboard and original CD-Rom drive 20 years later:

 

Note that the 8x CD-ROM drive was replaced with a CD-RW drive in subsequent images. This allows for burning files to CD-RW discs for transfer due to the lack of USB ports and limitations of the floppy drive.

After a careful tear-down, light brushing and vacuum cleaning, here is the partial re-assembled chassis:

Closeups of the motherboard, Cyrix CPU, RAM, Jumper settings (soldered), BIOS are as follows:

Note the excellent results obtained by dry brushing and light vacuuming. No solvents used whatsoever! The computer was never used in a high humidity environment which does account for the lack of corrosion and ease of cleaning.

Upgrading any component can be quite challenging. This includes an ISA network card, non-Compaq branded EDO SIMM RAM or even the HDD.

Upgrades and modifications:

ISA Network Card

Although some 32-bit ISA network cards have been known to work with an 8-bit ISA slot, the battery holder on the motherboard physically limits the insertion of a 32-bit board. So updates are limited to classic 8-bit network cards which (as far as I know) never offered an ethernet connector and would require an external adapter.

RAM

Any attempt with a  standard non-Compaq branded RAM will most likely result in it not being entirely usable.

The industry standard method that was generally used in the 90’s with 72-pin EDO SIMM RAM used pins 68-70 as bridged jumpers to identify the RAM size and speed to the motherboard using the Presence Detection designation. Companies like IBM, Compaq and others used a proprietary mechanism of identifying their RAM for their branded motherboards. That being said, if you have a generic EDO RAM stick of a known size, you can manually bridge the solder pads using bridging resistors (0 resistance jumpers) in the appropriate configuration to your motherboard manufacturer.

HDD

This Compaq Presario desktop seems to be capped at 8.34GB due to some limitation in the 1985-1994 Pheonix BIOS. I attempted to replace the original HDD (for a separate Win98SE installation) with a Maxtor 20GB (ca. 2003) and it was not fully recognized. A workaround at the time for those kinds of issues was to install a HDD overlay.

HDD manufacturers were aware of these mainboard limitations and usually provided a bootable floppy disk that can load the appropriate information after POST so that the entire size may be used.

Another workaround would have been a manufacturer BIOS update, however, even on the waybackmachine web archive of the original Compaq company website revealed no such update to even begin searching for. Alternatively a BIOS dump and appropriate modification should be possible.

Additional Legacy Driver Sources:

Similar teardowns:

Additional Sources and Resources:

Apache2, PHP and MySQL configuration files

Each component in a LAMP stack has its own configuration file. Apache 2 also has configuration files for virtual hosts (one for each site hosted), modules and additional configurations. In Ubuntu, the default installation locations are as follows:

Apache 2 configuration file locations

/etc/apache2/apache2.conf
/etc/apache2/apache2/sites-available/
/etc/apache2/apache2/mods-available

 

PHP 5 configuration file location

/etc/php5/apache2/php.ini

MySQL 5 configuration file location

/etc/mysql/my.cnf

E39 Maintenance Log

 KM Date Service Item Notes Parts
140.000 Replacement Bosch spark plugs
145.000 EGR system replacement All components replaced with OEM parts
170.000 Fuel filter  OEM fuel filter
171.000 Aftermarket fog light glass housings Replaced pitted originals
173.000
  • New battery
  • Oil/ filter change
  • P/S fluid change (~400 mL)
  • Oil filter housing gasket replacement
BMW OEM battery.

Mobile 1 synthetic A/T fluid used for P/S.

5W30 Castrol Syntec. OEM Mahle filter + new oil filter gasket

177.770 Wiper arm rust removal
179.000 Krown rustproofing
189.000
  • New K&N air filter
  • Brake fluid flush with ATE super-blue brake fluid
189.364 Oil/ filter change Reset Oil, distance and SII indicators

5W30 Castrol Syntec. OEM Mahle filter + new oil filter gasket

190.000
  • Upstream oxygen sensor replacement
  • Re-sealed valve cover due to oil leak
 191.000 Cleaned A/C evaporator and radioator Required removal of front bumper
195.000 Lubricated sliding components of power seats Required removal of L + R front seats
196.000
  • Coolant drained and changed with new 50/50 mix.
  • Replaced plastic coolant venting screws
OEM BMW blue fluid used with distilled water
196.665
  • Engine mounts
  • A/C belt replaced
OEM mounts and belt
198.000 Aftermarket auxiliary fan Fan speed is no longer variable but adjusted in set intervals. Noisier compared to OEM

Repaced due to overheating engine while stationary

202.000 Replaced

  • Rear ball joints
  • Rear end links
  • Rear guiding links
  • Rear upper control arms
  • Front tie rods (complete)
  • Front control arms
  • Wiper blade rubbers
203.500 Oil/ filter replacement 5W30 Castrol Syntec. OEM Mahle filter + new oil filter gasket
205.000 Replacement struts front and rear Original springs reused
209.000 Oil/ filter replacement 5W30 Castrol Syntec. OEM Mahle filter + new oil filter gasket
218.000 ABS sensor cleaning Removal and cleaning of all 4 magnetic metal fillings causing ABS error
219.000
  • Replacement Bosch alternator
  • Brake pads
  • Brake rotors
  • Brake fluid flush
  • Parking brake shoes
  • K&N clean and re-oil
OEM Bosch alternator at reduced price. Build seemed genuine but voltage regulator suspicious

OEM brake pads, rotors and fluid

223.000
  • Oil change
  • IAC, MAF, TB cleaning. K&N A/F clean/ oiled
  • Wiper blade rubbers
  • Headlight/ hood gaskets L + R
  • Spark plugs
  • Cabin air filters L + R
 5W30 Castrol Syntec. OEM Mahle filter + new oil filter gasket
227.000 Spark plug coil boots All-round engine smoother RPMs and accel.
227.800 Driver seat twist/ motor fix
  • Rear brake pads and dust cover replacement
  • Parking brake adjustment
  • Cracked radiator replacement
  • Water pump
  • Electronic thermostat
  • Front tie rods
All OEM replacements

 

How to upgrade MySQL 5.5 to 5.6 on Ubuntu 14.04 LTS

Does your SQL installation meet minimum requirements?

The standard Ubuntu 14.04 LTS Server installation installs MySQL 5.5 by default using the following command:


sudo apt-get update
sudo apt-get install mysql-server

However, certain new web applications and services require at least MySQL 5.6. This includes the latest version of Magento 2.0.4 Community Edition. After following a few guides and crippling my existing installation I’ve decided to share what worked and what didn’t. (This makes the difference between 5 minutes and 5 hours 🙂 )

Warning: This has been tested with Ubuntu 14.04 LTS and is valid for only this release! Make sure to backup your database as outlined in case things go bad. If they do, read the bottom section ;). And of course, use at your own risk!

Start by making a backup of your database files using the following shell command:


sudo mysqldump --lock-all-tables -u root -p --all-databases > /home/USERNAME/dump.sql

I chose to dump the entire SQL into my /home/USERNAME folder. Feel free to place this file at your convenience.

Next list all packages that are related to your current MySQL 5.5 installation:


USERNAME@computer-name:~$ sudo dpkg --get-selections | grep mysql

[sudo] password for USERNAME:

libdbd-mysql-perl                               install
libmysqlclient18:amd64                          install
mysql-client-5.5                                install
mysql-client-core-5.5                           install
mysql-common                                    install
mysql-server                                    install
mysql-server-5.5                                install
mysql-server-core-5.5                           install
php5-mysql                                      install

Take note of these packages and remove them all like so:


sudo apt-get remove libdbd-mysql-perl libmysqlclient18:amd64 mysql-client-5.5  mysql-client-core-5.5 mysql-common mysql-server mysql-server-5.5 mysql-server-core-5.5 php5-mysql

Reading package lists... Done
Building dependency tree
Reading state information... Done

The following packages were automatically installed and are no longer required:
  libaio1 libdbi-perl libterm-readkey-perl

Use 'apt-get autoremove' to remove them.

The following packages will be REMOVED:
  libdbd-mysql-perl libmysqlclient18 mysql-client-5.5 mysql-client-core-5.5
  mysql-common mysql-server mysql-server-5.5 mysql-server-core-5.5 php5-mysql
0 upgraded, 0 newly installed, 9 to remove and 3 not upgraded.

After this operation, 94.8 MB disk space will be freed.

Do you want to continue? [Y/n] Y

Note the apt-get autoremove at the very end!

Almost there, now it is time to reinstall the newer version:


sudo apt-get update
sudo apt-get upgrade
sudo apt-get install mysql-server-5.6

When prompted, reset or leave your root MySQL password. And you’re done!

How NOT to upgrade MySQL 5.5 to 5.6 on Ubuntu 14.04 LTS

Here is what did not work and resulted in a partial, broken installation that made downgrading and reinstalling challenging:


sudo apt-get update
sudo apt-get upgrade
sudo apt-get install mysql-server-5.6

Follow the proper instructions in the main guide to remove package files in a neat and complete way followed by a complete reinstallation. If not, you will end up with a broken installation of either version. In case you need to fix something that went wrong start here:


USERNAME@computer-name:~$ sudo dpkg --get-selections | grep mysql

[sudo] password for USERNAME:

libdbd-mysql-perl                               install
libmysqlclient18:amd64                          install
mysql-client-5.6                                install
mysql-client-core-5.5                           deinstall
mysql-common                                    install
mysql-server                                    install
mysql-server-5.5                                deinstall
mysql-server-core-5.6                           install
php5-mysql                                      install

Using the same dpkg | grep command, list all files of all MySQL installation. You will see something like the above (fictitious example but same idea). Make a list of all packages you find here and, like the guide above, use apt-get remove to get rid of them all:


sudo apt-get remove libdbd-mysql-perl libmysqlclient18:amd64 mysql-client-5.5  mysql-client-core-5.5 mysql-common mysql-server mysql-server-5.5 mysql-server-core-5.5 php5-mysql

Reading package lists... Done
Building dependency tree
Reading state information... Done

The following packages were automatically installed and are no longer required:
  libaio1 libdbi-perl libterm-readkey-perl

Use 'apt-get autoremove' to remove them.

The following packages will be REMOVED:
  libdbd-mysql-perl libmysqlclient18 mysql-client-5.5 mysql-client-core-5.5
  mysql-common mysql-server mysql-server-5.5 mysql-server-core-5.5 php5-mysql
0 upgraded, 0 newly installed, 9 to remove and 3 not upgraded.

After this operation, 94.8 MB disk space will be freed.

Do you want to continue? [Y/n] Y

If you are desperate to get things back to the way they were before on MySQL 5.5, delete the following “.flag” file that was generated by the 5.6 upgrade attempt


sudo su

cd /var/lib/mysql

rm debian-5.*.flag

And re-install default MySQL 5.5:


sudo apt-get update
sudo apt-get install mysql-server-5.5

If your data is gone, re-import the backup dump you made prior to beginning like so

 	
mysql -u root -p < /path/to/dump.sql

At this point, either leave it as it is or attempt to upgrade as per the main guide at the top of this page.

Food nutrient databases

Ever wonder what is in your food?

Many countries have food nutrient databases that allow searching for macro- and micro-nutrient content of thousands of food ingredients or meals. Micro-nutrients are synonymous with trace minerals and elements. This group is also known to include vitamins.

Nutrient reference value databases are useful for general self-directed research for those suffering from chronic diseases and/or deficiencies. Guidance from a health physician is recommended.

For a more universal perspective here are a few international nutrient reference value databases created for public use by a handful of international government health ministries. With a few exceptions, the databases are free unless otherwise noted.

Online databases

For most other countries where food data tables are available or health publications, check the International food composition table/ database directory, maintained since 1988, by the Food and Agriculture Organization (FAO) of the United Nations.

For a compiled data from multiple countries from all over the world, once again see the FAO’s food composition database.

Let’s Encrypt free SSLs – Apache on Ubuntu 14.04 LTS

Thanks to the efforts of the Internet Security Research Group (ISRG), the Let’s Encrypt project was developed and successfully launched! What does this mean for internet users? The Let’s Encrypt project provides server administrators with a free, automated, and open certificate authority”.

The recommended linux client is called certbot and offers full integration with apache on ubuntu (as well as other OSs)

As of this writing, I’ve experienced some issues with the fully automated --apache flag due to an issue with augeas lens not parsing apache virtual host files correctly. As I have few sites to enable, I’ve opted for the manual or --webroot method.

Specifying a domain, you are able to validate your domain and obtain your SSL file to the default location /etc/letsencrypt/live/. Here you will find all your certificates listed by full domain name like so: www.DOMAIN.TLD. The certificates will be privkey.pem, cert.pem and chain.pem.


cris@ubuntu:~$ wget https://dl.eff.org/certbot-auto
cris@ubuntu:~$ chmod a+x certbot-auto
cris@ubuntu:~$ ./certbot-auto certonly --webroot -w /var/www/DIRECTORY/ -d www.DOMAIN.TLD -d DOMAIN.TLD

The above will generate a set of SSL certificates for -d (domain) using -w (working directory) to automatically verify the domain. These will be located in the default installation directory as mentioned above and following certificate generation.


cris@ubuntu:~$

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at
   /etc/letsencrypt/live/www.DOMAIN.TLD/fullchain.pem. Your cert
   will expire on 2016-11-23. To obtain a new or tweaked version of
   this certificate in the future, simply run certbot-auto again. To
   non-interactively renew *all* of your certificates, run
   "certbot-auto renew"
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

The generated ssl .pem certficate files can be entered into apache virtual host files as they are and do not require the following conversions:


cris@ubuntu:~$ openssl rsa -outform der -in privkey.pem -out CertificateKeyFile.key
cris@ubuntu:~$ openssl x509 -outform der -in cert.pem -out CertificateFile.crt
cris@ubuntu:~$ openssl x509 -outform der -in chain.pem -out CertificateChainFile.crt

Once the Apache virtual host file is set up in the following format, all you need to do is renew the certificate every 3 months and you’re all set!


    SSLEngine On
    SSLCertificateFile /etc/letsencrypt/www.DOMAIN.TLD/cert.pem
    SSLCertificateKeyFile /etc/letsencrypt/www.DOMAIN.TLD/privkey.pem
    SSLCertificateChainFile /etc/letsencrypt/www.DOMAIN.TLD/fullchain.pem

I recommend donating to both cerbot development and the Let’s Encrypt initiative for their awesome work.

The renewal process consists of issuing the following commands. The first is a dry run to make sure everything is working correctly, while the second can be invoked manually or via cron.


cris@ubuntu:~$ letsencrypt renew --dry-run --agree-tos
cris@ubuntu:~$ letsencrypt renew

Some extra reading about Apache configuration can be found on the Let’s Encrypt community site.

Replace original masonry code in PinBin theme

Since the WP 4.6 update, PinBin’s masonry post arrangement no longer worked on my website.

My solution was to remove the enqueued masonry js file in functions.php and replace with the following:

wp_enqueue_script( 'masonry', '//cdnjs.cloudflare.com/ajax/libs/masonry/3.1.2/masonry.pkgd.js' );

As described on David DeSandro’s masonry homepage, he outlined the following initialization (among others) method.

In PinBin’s index.html file, place the following towards the end of the file:


script type="text/javascript" 
/* Make sure to add the < > above */
    jQuery(window).load(function() {
             // MASONRY Without jquery
         var container = document.querySelector('#ms-container');
         var msnry = new Masonry( container, {
             itemSelector: '.post',
             columnWidth: '.ms-item',                
         });
    });
    /script 
/* Make sure to add the < > above */

Note that the itemSelector .post was chosen based on the items that we want masonry.js to act on within the original PinBin theme.

I’ve also styled the PinBin masonry code to be perfectly responsive in portrait and landscape mode (using .post and .ms-item as itemSelector and columnWidth respectively) for a wide range of devices.

Feel free to use the following under CC-BY-SA 4.0 licensing.



/* ------ Masonry Mobile styles for PinBin WP Theme ------ */
/* -------------- CC BY-SA 4.0 wordpress.archive.cristarta.com ------------- */

/* For the following device(s): Nexus 10 L */
@media only screen and (min-width: 1024px) and (max-width: 1280px) {
	#ms-container {
		width: 82%;
		margin-left: 11%;
		margin-right: 8%;
	}
	.ms-item {
		width: 8%;
	}
}
/* For the following device(s): iPad L */
@media only screen and (min-width: 801px) and (max-width: 1024px) {
	#ms-container {
		width: 95%;
		margin-left: 5%;
		margin-right: 0%;
		max-width: 973px;
	}
	.ms-item {
		width: 4%;
	}
}
/* For the following device(s): Nexus 10 P */
@media only screen and (min-width: 769px) and (max-width: 800px) {
	#ms-container {
		width: 82%;
		margin-left: 12%;
		margin-right: 6%;
		max-width: 656px;
	}
	.ms-item {
		width: 4%;
	}
}
/* For the following device(s): iPad P */
@media only screen and (min-width: 737px) and (max-width: 768px) {
	#ms-container {
		width: 84%;
		margin-left: 10%;
		margin-right: 6%;
		max-width: 645px;
	}
	.ms-item {
		width: 4%;
	}
}

/* For the following device(s): iPhone 6 Plus L */
@media only screen and (min-width: 733px) and (max-width: 736px) {
	#ms-container {
		width: 88%;
		margin-left: 8%;
		margin-right: 4%;
	}
	.ms-item {
		width: 4%;
	}
}
/* For the following device(s): Nexus 5X/6P L */
@media only screen and (min-width: 668px) and (max-width: 732px) {
	#ms-container {
		width: 96%;
		margin-left: 4%;
		margin-right: 0%;
		max-width: 657px;
	}
	.ms-item {
		width: 5%;
	}
}
/* For the following device(s): iPhone 6 L */
@media only screen and (min-width: 641px) and (max-width: 667px) {
	#ms-container {
		width: 94%;
		margin-left: 4%;
		margin-right: 2%;
	}
	.ms-item {
		width: 5%;
	}
}
/* For the following device(s): Nokia N9/ Galaxy S5 L */
@media only screen and (min-width: 569px) and (max-width: 640px) {
	#ms-container {
		width: 98%;
		margin-left: 2%;
		margin-right: 0%;
		max-width:628px;
	}
	.ms-item {
		width: 5%;
	}
}
/* For the following device(s): iPhone 5 L*/
@media only screen and (min-width: 481px) and (max-width: 568px) {
	#ms-container {
		width: 54%;
		margin-left: 24%;
		margin-right: 22%;
	}
	.ms-item {
		width: 8%;
	}
}
/* For the following device(s): iPhone 4 L*/
@media only screen and (min-width: 415px) and (max-width: 480px) {
	#ms-container {
		width: 64%;
		margin-left: 19%;
		margin-right: 17%;
		max-width: 308px;
	}
	.ms-item {
		width: 5%;
	}
}
/* For the following device(s): iPhone 6 Plus P */
@media only screen and (min-width: 413px) and (max-width: 414px) {
	#ms-container {
		width: 78%;
		margin-left: 12%;
		margin-right: 10%;
	}
	.ms-item {
		width: 5%;
	}
}
/* For the following device(s): Nexus 5X / 6P P*/
@media only screen and (min-width: 376px) and (max-width: 412px) {
	#ms-container {
		width: 79%;
		margin-left: 12%;
		margin-right: 9%;
	}
	.ms-item {
		width: 5%;
	}
}
/* For the following device(s): iPhone 6 P*/
@media only screen and (min-width: 361px) and (max-width: 375px) {
	#ms-container {
		width: 84%;
		margin-left: 9%;
		margin-right: 7%;
	}
	.ms-item {
		width: 5%;
	}
}
/* For the following device(s): Nokia N9/ Galaxy S5 P*/
@media only screen and (min-width: 321px) and (max-width: 360px) {
	#ms-container {
		width: 87%;
		margin-left: 7%;
		margin-right: 6%;
	}
	.ms-item {
		width: 5%;
	}
}
/* For the following device(s): iPhone5/ iPhone 4 P */
@media only screen and (max-width: 320px) {
	#ms-container {
		width: 97%;
		margin-left: 1.5%;
		margin-right: 1.5%;
	}
	.ms-item {
		width: 5%;
	}
}

Media query set

I’ve recently had to come up with a series of media queries to cover a handful of mobile device sizes. Feel free to use the following code under CC BY-SA 4.0 license.

Sample code includes the following devices (note: P and L designate Portrait and Landscape respectively):

  1. Nexus 10
  2. iPad (All)
  3. iPad mini
  4. iPhone 6 Plus
  5. Nexus 5X
  6. Nexus 6P
  7. iPhone 3/4/5/6
  8. Nokia N9
  9. Galaxy S5

Each size was taken from Google Chrome Developer tools mobile view. Any unique styling can be tested using that tool for your convenience when using the media queries below.


/* ------------------- Mobile styles --------------------- */
/* -------------- CC BY-SA 4.0 wordpress.archive.cristarta.com ------------- */
/* For the following device(s): Nexus 10 L */
@media only screen and (min-width: 1024px) and (max-width: 1280px) {
}
/* For the following device(s): iPad L */
@media only screen and (min-width: 801px) and (max-width: 1024px) {
}
/* For the following device(s): Nexus 10 P */
@media only screen and (min-width: 769px) and (max-width: 800px) {
}
/* For the following device(s): iPad P */
@media only screen and (min-width: 737px) and (max-width: 768px) {
}
/* For devices with screen size lower than 767px */
@media only screen and (max-width: 719px) {
}
/* For the following device(s): iPhone 6 Plus L */
@media only screen and (min-width: 733px) and (max-width: 736px) {
}
/* For the following device(s): Nexus 5X/6P L */
@media only screen and (min-width: 668px) and (max-width: 732px) {
}
/* For the following device(s): iPhone 6 L */
@media only screen and (min-width: 641px) and (max-width: 667px) {
}
/* For the following device(s): Nokia N9/ Galaxy S5 L */
@media only screen and (min-width: 569px) and (max-width: 640px) {
}
/* For the following device(s): iPhone 5 L*/
@media only screen and (min-width: 481px) and (max-width: 568px) {
}
/* For the following device(s): iPhone 4 L*/
@media only screen and (min-width: 415px) and (max-width: 480px) {
}
/* For devices with screen size lower than 480px */
@media only screen and (max-width: 479px) {
}
/* For the following device(s): iPhone 6 Plus P */
@media only screen and (min-width: 413px) and (max-width: 414px) {
}
/* For the following device(s): Nexus 5X / 6P P*/
@media only screen and (min-width: 376px) and (max-width: 412px) {
}
/* For the following device(s): iPhone 6 P*/
@media only screen and (min-width: 361px) and (max-width: 375px) {
}
/* For the following device(s): Nokia N9/ Galaxy S5 P*/
@media only screen and (min-width: 321px) and (max-width: 360px) {
}
/* For the following device(s): iPhone5/ iPhone 4 P */
@media only screen and (max-width: 320px) {
}

Static DHCP router settings for Ubuntu 14.04 LTS server

Having set up your Ubuntu 14.04 LTS server installation, you will now need to allow incoming connections to your installation.

This portion of the tutorial series will cover basic and advanced DHCP router settings for your local area network (LAN).This guide assumes that you have a router (Eg. Cisco Linksys, D-Link, Apple AirPort, etc) between your home devices and your cable or DSL modem. Here is what you will achieve using this guide:

  1. How to determine your IP address
  2. Enter administrative page of router
  3. Identify server hardware on LAN
  4. Assign static DHCP IP address to server
  5. HTTP/ HTTPS port forwarding to your server

Lets being!

How to determine your IP address

If you have an existing, fully functional internet installation, then the simplest way to determine what your ip address is by accessing an online service like icanhazip.com and writing this value down.

Enter administrative settings page of router

Generally, the administrative interface of your LAN router is reachable by opening any browser (from a computer on your network) and entering one of the following gateways:

  • 192.168.1.1 (Cisco Linksys)
  • 192.168.0.1 (D-Link)
  • Downloading Apple AirPort Utility

Once logged in, you will be greeting with an interface similar to this one (Cisco Linksys E-series router)

linksys@750

Routers use something called a Dynamic Host Configuration Protocol (DHCP). This is a client/server protocol that automatically provides an Internet Protocol (IP) host with its IP address and other related configuration information on your home network. The problem comes with IP lease expiry and power resets; devices may not receive the same IP address again. This is generally not a problem unless you are trying to connect to the same device using an outdated IP address.

To overcome this, you can assign or “reserve” a static LAN IP address for your server.

Identify server hardware on LAN

To assign a static IP to a LAN device, you have to identify it first. If you have a large number of devices on the network, this can be quite challenging so head over to your Ubuntu 14.04 LTS server setup and type the following in the command line

cris@ubuntu:~$ ifconfig

eth0      Link encap:Ethernet  HWaddr 00:00:00:00:00:00
          inet addr:192.168.1.146  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::208:74ff:fec8:97ee/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:21284 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5205 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:7764197 (7.7 MB)  TX bytes:371049 (371.0 KB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

Take note of your Ubuntu installation’s LAN IP address and MAC address identified by ” inet addr: ” and “HWaddr” respectively.

Assign static DHCP IP for server

Go back to your router administrative panel and find DHCP reservations. Here you can manually enter the MAC address and IP address you obtained in the command line or, depending on your router, identify the existing entry based on the same information and select add client. Below are examples from the Cisco Linksys E-series router.

Router and LAN settings for server

Router and LAN settings for server

HTTP/ HTTPS port forwarding to your server

Now that your server has a static routing IP, you need to open the following 2 ports for your server’s LAN IP address. Ports 80 and 443 are used for HTTP and HTTPS respectively.

Head to your router’s port forwarding settings page. You will only need to set up single port forwarding and it is generally found near or within application or gaming settings.

Continuing with the Cisco Linksys E-series router example. This is the page obtained under the single port forwarding submenu item of Applications and Gaming.

Port Forward@750

Here you enter the static ip address you set up for your server, select port 80 as the external and internal ports, TCP protocol and, if required by your router, enable rule.