Image Optimization-Quick Script

Posted by JD 03/24/2016 at 19:01

When sharing images or publishing them to a website, reducing the file size, especially when a human cannot tell the difference, is smart for many reasons.

Convert is part of the ImageMagick package which has been around for decades.

$ more img-opt
#!/bin/bash
QUAL=40   # 40 is safe. 20 often works too for even smaller files

for img in "$@"; do
  NEW=${img/%.???/-opt.jpg}
  echo " Working on $img ..."
   /usr/bin/convert -quality $QUAL  "$img"  "$NEW"
done
# Rename ... perhaps.
echo "rename 's/-opt.jpg/.jpg/g' "

Don’t forget to chmod +x img-opt after creating the file. I’d place it in either /usr/local/bin or ~/bin/ .

Rename is part of perl and amazing, but I prefer to wait until I’ve manually reviewed the results most of the time.
Input files and globbing by the shell dictate that filenames cannot have spaces. I’m lazy and it is really easy for me to prevent spaces in filenames, so this and all other scripts I create make that assumption.

Typical use is:
$ img-opt D*g

This will glob all the files beginning and ending with D/g and run the convert/optimization on each in turn. New files ending in -opt.jpg will be the result – even if files already have that name, those characters will be replaced. Safety.

Other image file types can be input, but only jpg output is possible.

I’ll work in a temporary directory, with copies of the original image files. Then I use an image viewer to quickly look through all the files and delete the originals. If everything looks good, I’ll rename all the files en-mas, before pushing them to a web site or adding to an email attachment.

This script shows some simple techniques to run the same process over a bunch of files using input file globbing. That is extremely powerful. The input list of files can come from anywhere:

  1. the shell, using globbing
  2. a file with a list of files
  3. another command like ‘find’
  4. pipes …

Very powerful.

Be aware that globbing on Unix systems is VERY different from globbing on Windows. The *.* stuff on Windows is never needed on Unix. Extensions don’t matter on Unix.

Sorry EC2 Amazon Visitors

Posted by JD 02/07/2016 at 20:00

I’d like to apologize to people using Amazon EC2 to visit this blog. Sadly, a few hundred of your peers decided to be abusive, so I was forced to block most of EC2 subnets from access.

Having hundreds of IPs in the EC2 IP range crawling this site constantly just cannot be allowed. It isn’t like we post articles more than once a day – sometimes not even once a month.

I apologize if you have been blocked due to this. Not much can be done, I’m afraid.

Real World SSD Performance

Posted by JD 01/09/2016 at 15:00

Yes, SSDs tend to be faster than other storage. That is true, but unless you look deeper at the specs, you may end up with poor performance. Let me explain. This is a general knowledge article. Without a huge sample size, anything beyond generalizations don’t mean anything.

Win10 Not Seeing Samba Servers

Posted by JD 10/31/2015 at 02:00

The fix stolen from here

  1. Run Windows PowerShell as ‘Administrator’ on the Win10 box
  2. Enter the following commands:
    1. sc.exe config lanmanworkstation depend= bowser/mrxsmb10/nsi
    2. sc.exe config mrxsmb20 start= disabled
    3. reboot

14.8% Obama-Care Rate Increases in 2017!

Posted by JD 10/25/2015 at 02:00

Update for 2017. Just signed up for a new plan. My current provider is not offering any plans here anymore. 14.8% increase over 2016! 281% higher than I paid in 2014 plus the deductible is much higher and the coverage is much worse. Almost 3x more money and zero better options. No question to me why the democrats didn’t win the last presidential election. Their decisions on this are costing me thousands more yearly.

2016 Update: Just received the insurance paperwork for 2016 and my Hi-Deductible plan costs are increasing 13.75%!

In 2015, I was forced into a plan that raised the deductible 50% and costs 217% more than it cost in 2014.

My real monthly rates:
| 2014 | $148 |
| 2015 | $321 |
| 2016 | $365 |
| 2017 | $419 |

I’m not alone.

Thank you President Obama. Nice job.

Real World FIDO-U2F Use

Posted by JD 10/21/2015 at 01:00

FIDO-u2f is a newish standard to provide low-cost security devices as a second form of authentication. The normal way this works is

  • userid
  • password
  • on-time token (OTP or U2F or Oauth)

This provides added assurances that a week password won’t lead to account compromises. The U2F protocol makes the setup and daily use of a small USB device fairly simple.

Also, u2f is cross-platform primarily because it acts like a keyboard as far as the OS thinks, so Linux, OSX and Windows are each supported.

That’s the theory. Everyone seems to forget a few minor details.

Below I spell out what I’ve learned when setting up a Yubikey u2f device for use at a few online accounts. Google accounts, dropbox and github are the main accounts, but because google is an authenticator for many other online accounts, those are indirectly secured as well.

A YubiKey NEO firmware v3.3.x will be used as well.

Quickly Share Text

Posted by JD 10/19/2015 at 20:00

cat file.txt | curl -F 'sprunge=<-' http://sprunge.us

Simple.

It returns a sprunge.us URL that can be shared world-wide that contains “file.txt”. Sprunge is like pastebin.com, they just have an easy to use API.

Microsoft Is Firing Their Customers 4

Posted by JD 09/08/2015 at 19:00

5/2016 Updated below:
Pressing the X to close the update will cause the update to occur according to a slashdot article. Desperate. Really desperate. Also, they’ve added a new recommended patch, so anyone with automatic patching will be screwed. Need to add more more patch to the ignore list.

When you run a small business, one of the lessons to learn is that sometimes you need to fire some customers. This is mainly due to bad pricing in an initial contract when we just start out. The rates in early contracts don’t usually reflect the real-world, competitive rates from other competitors.

As a small biz gets other clients, those new clients are usually given higher rates. That can make service providers less-than-happy dealing with other clients for less money.

3/2016 update – Microsoft is back at it pushing Win10 advertising as part of critical updates which aren’t critical.

So – back to Microsoft and their situation …

Why You Should Care About Phone Metadata

Posted by JD 09/06/2015 at 18:00

Saw this over at Schneier’s Security site.

How your phone tracks your every move

His phone was leaving traces about 3x an hour and it wasn’t just GPS coordinates.

It is an ABC (Australian) report. They asked normal people to look at some metadata to figure out what they could know about a person. Bingo!

Be afraid. Be very afraid.

For everyone who doesn’t have an issue with this – fine. Send me all your emails, texts, tweets, G+ posts, FB posts, all contacts in every device you own, a list of everything you watch on TV, through Netflix, popcorn, all the torrents and photos from the last 6 months. After all, you don’t have anything to hide. Oh – and I don’t want just the nice, sanitized stuff. Send it all.

After all, you have nothing to hide.

Here’s what the public found in his metadata.

His final thoughts:

Having strangers poring over your data can be an unnerving experience but whether we’re aware of it or not that’s increasingly the case in the world we live in.

Getting Comprehensive System Information

Posted by JD 09/05/2015 at 16:00

Updated 2020 – a few better commands
Updated 2017 – tested on Ubuntu 16.04.

When you ask for computer help, the people who you ask could really use some basic information about the computer. That information includes

  • CPU
  • Memory
  • Video
  • Networking
  • Disk, partitions, LVM

Basically, I find myself asking for this same information over and over, day after day. The more accurate and detailed the provided information is, the better. However, gathering the information needs to be easy for the beginner too. That is the attempt here. Simple and easy to use for everyone, while not being so hard to audit that people have to make a huge leap of faith to trust it.