Corey Goldberg
Blog - Technology, Programming
September 7, 2018
Python - Using Chrome Extensions With Selenium WebDriver
July 6, 2017
LG G6 - Quick Charge 3.0 Not Working?
The following conditions must be met, or else the G6 steps down power during charging and you will not get a proper QC 3.0 charge:
- battery must be below 80% capacity
- screen must be turned off
- screen saver mode must be disabled
The LG G6 has a Snapdragon 821 SoC that supports Qualcomm's Quick Charge 3.0 technology for rapid charging. However, I haven't been getting very fast charge times on my G6. I tried the stock charger/cable and even several QC-compatible 3rd party accessories. While the G6 showed a "Fast Charging" notification, it didn't seem very fast at all. It also seemed to charge faster over wireless (Qi) than with a charger and cable attached!
So I bought a QC-compatible USB multimeter to test the voltage and current the G6 was drawing during a charge. Just as I suspected, I was *not* getting a Quick Charge at all. The adapter that comes with the G6 is supposed to be able to charge at 9V/1.8A, but I couldn't see it draw anything beyond a 5V/0.5A. After much frustration and troubleshooting, I realized I had my G6 configured to run Screen Saver mode during charging. After disabling the Screen Saver, I finally saw it charge at the full 9V/1.8A!
Also note:
- when the "Fast Charging" notification is displayed, it just means a QC compatible charger/cable was detected, not that it's actually charging at QC 3.0 speed.
- Screen Saver setting is located at: Settings > Display > Screen saver
February 2, 2017
Batch Convert Images from PNG to JPEG
First, install ImageMagick and GNU Parallel. For example, on Debian/Ubuntu you would run:
$ sudo apt-get install imagemagick
$ sudo apt-get install parallel
Once these are installed, `cd` to the root of the directory tree containing your images, and run:
$ find . -iname "*.png" | parallel convert -quality 95% {} {.}.jpg
This shell pipeline will:
* recursively search under the current directory
* match files that have the [case-insensitive] `.png` extension
* convert each PNG image to JPEG format at 95% quality
* save the new image with the file extension changed to `.jpg`
Once converted, you can delete the original PNG images with:
$ find . -iname "*.png" | parallel rm {}
March 9, 2016
What The Heck Happened To Conky? (I'm rolling back to 1.9)
However, Conky 1.10 is extremely buggy and has made incompatible changes to it's config syntax since the 1.9 release.
The changes from conky 1.9->1.10 made for an incompatible disaster and conky is now totally borked in the current Ubuntu 16.04 repos. Bugs have been reported... but, while maintainers and devs figure out issues, I need my old conky back!
So I just reverted to the old `conky-std` 1.9.0 in Ubuntu 16.04, and I'm back in business for now.
Here is how I did it:
First, let's see which conky version is in installed on my 16.04 (Xenial) machine:
$ conky -v | head -n 1 | cut -d" " -f 2
1.10.1
so, I removed this borked conky and purged it's configurations and leftover dependencies:
$ sudo apt-get remove --purge conky-std && sudo apt-get autoremove
I wanted conky version 1.9, which is not in the Ubuntu Xenial repos. So I snagged the package that shipped with Trusty:
$ wget http://security.ubuntu.com/ubuntu/pool/universe/c/conky/conky-std_1.9.0-4_amd64.deb
once I had the .deb package downloaded, I installed it with `gdebi` rather `dpkg` so it would also install the necessary dependencies:
$ sudo gdebi conky-std_1.9.0-4_amd64.deb
we should now be back in business. Let's check the version that is installed:
$ conky -v | head -n 1 | cut -d" " -f 2
1.9.0
score!
One final task is pin the package at the 1.9.0 version so future package updates don't revert us back up to the bad version:
$ sudo apt-mark hold conky-std
done!
I'm back running conky 1.9 like a boss for now. I hope the upstream situation gets sorted soon.
TLDR:
$ sudo apt-get remove --purge conky-std && sudo apt-get autoremove
$ wget http://security.ubuntu.com/ubuntu/pool/universe/c/conky/conky-std_1.9.0-4_amd64.deb
$ sudo gdebi conky-std_1.9.0-4_amd64.deb
$ sudo apt-mark hold conky-std
November 29, 2015
Ubuntu - Changing the bootsplash screen
For as long as I can remember, every time I install the proprietary NVidia display driver, my bootsplash gets borked. It just displays a black screen, then a few flickers of the Ubuntu logo or NVidia logo, then the desktop is presented.
It seems that simply resetting the default plymouth theme fixes this issue:
$ sudo update-alternatives --config default.plymouth
apply changes:
$ sudo update-initramfs -u
Here is how to switch the bootsplash to [my favorite] the solar theme:
$ sudo apt-get install plymouth-theme-solar
$ sudo update-alternatives --config default.plymouth
$ sudo update-initramfs -u
then reboot!
more info:
https://wiki.ubuntu.com/Plymouth
April 27, 2015
Linux - Simulating Degraded Network Conditions
I will give examples using 2 tools that alter a network interface's properties. The tools are: NetEm and Wondershaper.
NetEm is an enhancement of the Linux traffic control facilities that allows you to add delay, packet loss, duplication, corruption, reordering, and more to outgoing packets from a specified network interface. NetEm is controlled by the command line tool tc, which is part of the iproute2 package and included in most Linux distros.
Wondershaper is a traffic shaping script that allows you to throttle network transfers on a specified network interface. This is useful for testing latency when bandwidth is limited.
Examples:
tc/NetEm:
add fixed 250ms delay to all outgoing packets on Ethernet interface eth1:
 $ sudo tc qdisc add dev eth1 root netem delay 250ms
turn it off:
$ sudo tc qdisc del dev eth1 root netem
Wondershaper:
limit bandwidth of eth1 interface to 256kbps upload and 128kbps download:
 $ sudo wondershaper eth1 256 128
turn it off:
$ sudo wondershaper clear eth1
August 31, 2014
rsync for file sync and backup - storing my peronal media
You do backup all of your important files, right?
TLDR: Dropbox + NAS + Local Storage + rsync = my backup strategy.
I have a lot of data that is important to me. Mostly: documents, code, images, music, and videos. I currently have about 1.2TB stored. This is an overview of how I store and backup my data.
About rsync:
rsync is a great file synchronization and file transfer program. Since being announced in 1996, it has become a standard Linux utility, included in all popular Linux distributions (and other Unix-like systems).
I have a Dropbox with an 11GB quota. This suffices for storing my documents, code, and images. It nicely syncs them to to all my computers. I can easily access this data from outside my LAN on any device I own.
Then I have a NAS as my main storage within my LAN. It is a 2-bay enclosure, with 2 2TB hard drives inside that are in a RAID configuration. I can easily access all of my media from any computer or device on my home network. I also have a secondary NAS attached to my network, purely for backup/disaster situations.
To complete the storage picture... on my main workstation, I have a 2TB hard disk mounted as a secondary data drive.
Storage Overview:
- Dropbox
- 2 NAS servers mounted as drives on my main workstation (using SMB)
- Main workstation with 2TB Hard disk mounted internally
- Gigabit Ethernet LAN
So, that's the given hardware setup. I use a shell script to actually run my backup. It is initiated from the main workstation (scheduled from cron).
The script follows this workflow:
- local Dropbox gets rsync'ed to my primary NAS
- primary NAS gets rsync'ed to my local workstation's data drive
- primary NAS gets rsync'ed to my backup NAS
I have ~20k files (~1.2TB) in my archive. The first time running the backup job was slow (several hours), but subsequent backups are extremely fast. This is due to the rsync algorithm, delta encoding, and compression. If not many files changed since my last backup/sync, differential backups take only a few seconds or minutes.
Besides not having a offsite copy for disaster recovery, I like this system, and it makes me sleep well knowing my data is safe and recoverable.
Any flaws?
January 11, 2014
Python - Fixing My Photo Library Dates (Exif Metadata)
I have a large image library of photos I've taken or downloaded over the years. They are from various cameras and sources, many with missing or incomplete Exif metadata.
This is problematic because some image viewing programs and galleries use metadata to sort images into timelines. For example, when I view my library in Dropbox Photos timeline, images with missing Exif date tags are not displayed.
To remedy this, I wrote a Python script to fix the dates in my photo library. It uses gexiv2, which is a wrapper around the Exiv2 photo metadata library.
The scipt will:
- recursively scan a directory tree for jpg and png files
- get each file's creation time
- convert it to a timestamp string
- set Exif.Image.DateTime tag to timestamp
- set Exif.Photo.DateTimeDigitized tag to timestamp
- set Exif.Photo.DateTimeOriginal tag to timestamp
- save file with modified metadata
- set file access and modified times to file creation time
* Note: it does modifications in-place.
The Code: