Changing Fonts on Your WordPress Site

This week I decided to change the font I use on this web site. Why? When I first showed the site to my wife and a few other people they thought the domain name was pronounced ox-craft. As in oxen.

Oops. My attempt at a cleverly geeky domain name didn’t go quite like I planned.

Nope, this site is not about oxen related arts and crafts.  At least not yet. Of course, who knows what the future holds?

The domain name is an incorporation of the notation for hexadecimal integers zero-x,  0x, pronounced “hex” and the word “craft” which would be pronounced “hex-craft”. (More info on zero-x  here.)

A big source of confusion has to do with the fonts available in WordPress. The number “0” and the letter “O” look very similar on most screens in commonly used fonts. This is one reason zero-x is used frequently in computer programming. The slashed zero is a much clearer representation of zero than the slash-less version.

So, I thought I would experiment. Maybe using a font with slashed zeros would be less confusing?

I found one of the fonts I was looking for at https://www.fontsquirrel.com and the other hosted on the creator’s Github page. Make sure to check the licenses. Fonts are protected legally. Some you have to pay for and others are freely available.

When it comes to changing fonts in WordPress the first thing you have to do after finding a font you like is figure out how to access the font files.

You have two choices:

Tell your visitors web browser to import the fonts from a remote server every time they visit,

-OR –

 You host the font on your server with your website.

The first option is pretty easy. One of the readily available plugins will have you up and running in minutes.  Accessing a remote server though can really bog down your site. Slow loading web site are bad for reader experience.

Then there is the privacy thing. Google sees enough of our lives as it is, they don’t need to see when you read this site. (No, I don’t use Google Analytics anymore either.)

Good news!

Hosting fonts is pretty straight forward. I was going to write up the whole process for you. Instead go to Elegant Themes. B.J. Keeton did a really nice write up here.

The short story is you:

  1. Download the font files you want to use,
  2. Upload the font on your web server using FTP or with a file manager through cPanel.
  3. Copy and paste some bits of css code into your style.css and custom.php files,
  4. and, you are done!

After you get a font you like check out your web site with different browsers. Get some help from your friends. Different device and browser combos can display your font differently.

In my case, the fonts I decided on are Inconsolata and  Inconsolata-LGC. Unfortunately, the slashed zero doesn’t show in all browsers. For example, the Silk browser on my Kindle and the browser on my Android phone don’t render the zero with a slash. The font though still looks appropriately geeky .

Learning to Break Encryption with Python

Lately, I’ve been giving cryptopals (http://cryptopals.com) another shot.  Spring 2016 was my first try and I had made my way to Challenge 6. Not completely happy with my progress I took a break. A long break.

Why am I doing these challenges?

Cryptopals is one of the ways I am using to expand my knowledge in the information security realm. Big take away so far, as I work my way through the challenges I am developing an appreciation for how easy something like writing your own encryption is to screw up.

As they say on the web site:

People “know” this already, but they don’t really know it in their gut, and we think the reason for that is that very few people actually know how to implement the best-known attacks.

Anyway, now I am back at it and getting ready to play with Challenge 11 after starting over from the beginning. I am using Python this time.  I may do these challenges yet again to learn a new language. Not sure which.

Compared to last year this time through is going much smoother. The math and related logic was straightforward for me conceptually or implementing the first time.  My biggest stumbling block was getting confused by what Python modules to use to work with the text data and what they were doing. It was pretty bad.

Going back and forth between Base64, Hex, and ASCII in Python ended up being a mess the way I was going about things. I don’t even want to remember how convoluted my code was at the time.  With a little clarity of thought, really don’t know what I was smoking last time, using the base64 module from the Python Standard Library and bytes() method has really cleaned up the messy bits.

To see my progress: http://github.com/0xcraft/cryptopals

Why am I REALLY doing these challenges?

Patterns.  As you can see from this website I am mixing some rather diverse interests. Software engineering, databases, computer troubleshooting, meditation, mystical experiences and practices, tarot cards, and more.

The world is information.  Patterns of information.  DNA, matter, communication, art, whatever we want to conceive in our minds or can observe is all a pattern made up of some deeper something. Something more fundamental.

Learning to break encryption, or compromise websites (I like to play on hackthissite as well), or software or who knows what is just another way to explore and learn about an observable pattern. Encrypted data is a pattern.  The plain text data is the pattern under the observable pattern.

Windows 8.1 Taskbar Freezing or Unresponsive

Are you having problems with your Windows taskbar freezing? This is a rather perplexing problem.  In my research I found out freezing taskbars are both somewhat common and appear to happen randomly.  After helping a client with a freezing workstation I wanted to share what we found.

There are a few common symptoms you may experience when your taskbar freezes:

  • The clock might have stopped updating the time.
  • The taskbar icons are non-responsive even though you can click the icons on the desktop to launch programs.
  • Hovering your mouse over the taskbar icons won’t shift focus to the icon you’re hovering over.

My client had a Windows 8.1 workstation with a frequently freezing taskbar. The taskbar would become unresponsive at least once an hour or more. Typical times it would freeze:

  • After startup,
  • During account login at any time of day,
  • If the taskbar hadn’t been used for a while, and
  • If the computer was idle for some period of time.  Idle time could be 5 minutes or longer though typically 20 minutes.

Getting Your Windows Taskbar Working Again, Quick Fix

After doing quite a bit of reading online and some experimenting I found the following helped our situation.

First, getting the taskbar working again quickly:

  1. Ctl-Alt-Del -> Task Manager -> Restart explorer.exe worked to unfreeze without rebooting the workstation.
  2. Double tapping the Windows key, between Ctl and Alt on my keyboard, would also unfreeze the taskbar.

Fixing the Problem

As for actually fixing the problem we needed to do some cleaning, repairing, and settings changes in the system.  While we weren’t technically removing malware a recent third party software update apparently installed a search engine toolbar and possibly other programs which were unwanted.  More importantly this extra software was taking up quite a few resources. Enough to cause noticeable problems on the workstation, certainly for the taskbar.

The following were what we needed to do to get the taskbar to stop becoming unresponsive:

  1. Malware – We used Malwarebytes to find and remove some unwanted software which was installed during a product update.  The new software was using up resources and possibly contributing to the problem.
  2. After cleaning up the malware and unwanted programs using Malwarebytes I used Tweaking.com’s Windows Repair tool to look for and repair problems. Malware and other unwanted programs can make changes to systems setting which can cause problems even after the software has been removed.
  3.  Task Scheduler – Two settings in some of the tasks needed to be changed to keep the taskbar from freezing.  This appears to have been the primary fix needed.
    • Configure For – There were tasks configured for operating systems other than the OS on the workstation.  We changed those to match.
    • Triggers – Some tasks had triggers to check for updates.  Some also had errors in the XML files defining their update schedule. One in particular, Microsoft Office, had an error in the configuration file and was checking for updates. A lot. Every 30 minutes during the day in addition to an overnight check. I deleted the daytime task from the scheduler leaving the overnight task.

 

 

Making My Emacs Start Fast(er)

In the choice of editors to use I finally decided to go with Emacs. (I really like Vim, too!) As I wade back into the deep end of the software and databases pool Emacs looks like a good fit for me. I like the idea of being able to work with Python, SQL, Matlab, check my email, write blog posts and organize my life all from one application. Especially, now that I have some key bindings that make sense for me!

With that settled I got hit by the start up time optimization obsession. There’s something very attractive about vim/vi’s instant start up time. As I followed the path of spending hours to cut 1/2 second I discovered something. I was learning to use Emacs better while learning how to make it start fast.

Two Basic Approaches For A Faster Starting Emacs

In my quest for a fast starting Emacs I came across two basic approaches. Optimize various aspects of your .emacs or run Emacs as a service (see Resources below.)

Which works pretty well. This approach is definitely fast! All the time consuming parts of starting are done when your computer boots. The only thing I didn’t like was that the buffers were the same for each frame started. I could probably adapt. Maybe down the road I’ll try it again.

The second approach is what I’m lumping all the different ways to optimize and construct your .emacs file. In this approach a tool I found really helpful is Profile-DotEmacs (see Resources below.) Profile-dotemacs highlights the slowest parts of your .emacs load process including garbage collection (GC). I also used emacs-init M-x emacs-init for comparison.

What popped up immediately was how (require ‘) really slowed down things. Lazy loading to the rescue. Using autoload and with-eval-after-load in your .emacs you can defer loading packages until later in the startup process or when they are needed. Using Emacs Package is handy here because it handles autoload for you.

There’s a trade off because package-initialize takes quite a while relatively to load. Using use-package is supposed to help with this by loading only specific packages. Except it looks like you miss out on some of the convenience of allowing Package to manage things. I’m still working out whether or not I want to give up the convenience and use use-package. Sounds pretty effective though.

How Fast?

Here are my start up times. for Emacs 24.5 . Start ups times were checked when the cache was cold right after booting the computer and after Emacs had been loaded a few times.

Emacs Start Up Times
Timing Tool Cold Warm
Profile-DotEmacs 1.71 sec 0.49 sec
emacs-init 4.1 sec 1.5 sec

System details: GNU Emacs 24.5.1 (x86_64-redhat-linux-gnu, GTK+ Version 3.17.8) with ~ 30 packages. Toshiba Satellite, AMD A6-3420M APU , 6Gig ram running Fedora 23

The top 3 things that made my Emacs start faster:

  1. Deleting packages! Packages were loading that I didn’t need or were redundant functionally with other packages.
  2. Minimize use of (require ‘…) I was using require for packages that were already being loaded by default! All I needed to do was adjust settings for those packages with Emacs. Saved quite a bit of time. Autoload and eval-after-loading are also helpful.
  3. Raised the garbage collection (GC) threshold from 800k to 20M. Emacs garbage collection happens when the threshold is reached. Raising the limit saves a lot of time that was spent on GC. At the end of my .emacs I set it back to the default value.

There were some other approaches I used or at least experimented with during this process. Offloading some the GUI settings to X, adjusting cache pressure, and a couple others were interesting to experiment with but didn’t give as much return.

My current major bottlenecks:

  1. package-initialize
  2. Loading the theme.
  3. Whatever happens after .emacs loads. I turned off default.el which loads after .emacs. Somehow working with .Xresources might be helpful here though I’m not sure I want to customize outside of Emacs.

Summary

I’m happy with the time I’ve spent reducing load time for Emacs. Some benefits I got from the exercise:

  • I learned a little about how Emacs works under the covers. Including see lots of code other people have written is very helpful in beginning to develop an intuition regarding Emacs.
  • And I got to practice using Emacs to make Emacs faster. My Emacs keyboard skills have definitely improved and I’ve got some reasonable key bindings to work with now.
  • Lastly, there’s a psychological factor involved in start up time for me. I feel better not having to wait. Even 1 second can interrupt flow if I stop and restart Emacs. Granted, I can go all day before shutting down. Knowing I can restart fast though does feel good.

Additional Resources:

ProfileDotEmacs
Advice on Reddit for Speeding up Emacs. Great advice in comments, too!
Running emacs –daemon
Emacs and .Xresources

Retro Mac Mini Headless Server Hack

One of my projects this week was to put a Mac Mini I bought in 2006 back to work. It’s been taking up space in a box in the garage for a few years. Okay, the Mini doesn’t take up much space. There’s a lot of computer in a small form factor. Feels kind of wasteful not to be using it for something.

The Project

What am I going to do with the Mini? I’m not sure. Some ideas I’ve been tossing around:

  • Printer and Backup Drive Server – Give everyone access to one printer and have a central computer to run remote backups to a removable hard drive.
  • Remote Database Server
  • Development Server – A place to test web sites, software projects …?
  • Home Security Monitor – Attach some wireless cameras and sensors then get texts or login from Istanbul to see what’s happening around the house.
  • Base Station for Roaming House Drones – I have dreams of autonomous blimps monitoring (with video feed) Peanut’s whereabouts.

As you can see he even looks like trouble! 

Most of these ideas mean I need access to the Mini remotely. Remote could mean from a smart phone in the bedroom in the middle of the night checking on the garage or front door. Or logging in from Hawaii. Having some flexibility to place it in an out of the way location or a small space would be handy. Next to the printer or in a closet. For most situations I’m thinking about a monitor, keyboard, and mouse would be inconvenient space-wise.

Headless Mini Software

The Mini needs to be accessible remotely from a laptop, tablet, or smart phone. And I don’t want the machine trying to upgrade software everyday either. No need for iTunes, Word, etc….

I decided to go with Linux. Debian has an installer specifically for old Mac Minis. Apparently there’s some bugs or something in the firmware. The Debian installer worked flawlessly. I was very impressed.

For remote connection I did some experimenting and decided to go VNC4server. I don’t have it setup yet for secure connection with SSH tunneling. Doesn’t look too hard though. Starting the server with the -localhost option is important. All the details are being put in shell scripts. I’ll log in and start the server manually for security purposes with the scripts.

The only real trick to this whole thing was getting the Mini to boot without a monitor attached. I banged my head on this for a few hours! The darn thing would reboot when I sent the command on a remote connection. It was working with the monitor attached and not rebooting when I disconnected the monitor. After doing some Googling I discovered Apple designed the machine so it had to have a monitor attached to it to boot!

The solution has been floating around the Internet for a while. Depending on the model you just need some tape and a resistor. A friend suggested using a gum wrapper and duct tape. I went with a 100 ohm resistor a friend gave me instead. The ends go into pins 2 and 7 at least for older models. I did see people using pins 1 and 6 also. For newer Macs I think. The picture shows pins 2 and 7 on my Mini being used. Pins 1 and 6 are the next pins over to the right.

After trying it out I trimmed the leads a bit, stuck them back in and taped the whole thing down with packing tape. Well, at one point I did fumble the resistor. Those buggers are invisible on carpet!