The Blog of Tom Webster

Chronic Ranter, Reviewer, and Developer. I speak only for myself, opinions are my own.

ntpdate_ng

  2016-04-18 04:05:21 PDT

I've been learning Go recently (the programming language, not the game) and ran into a small, annoying problem that I could fix nicely with some code. Perfect opportunity to build a golang binary and try out the language for a simple use case.

My problem was that on a particular network I often use NTP traffic is completely blocked, and the particular machine I'm using has a horrible internal clock. Each week this machine drifts by 90 seconds. It's a stationary machine, always attached to the ntp-blocking network. While this isn't a huge deal, I sometimes work with time-sensitive code relating to time-based security tokens, and 90 seconds (let alone 30) completely throws this off. I needed a way to set my system clock regularly, without watching the time on my phone and hitting Enter at the perfect time to send the date -s command.

I've built a small utility (Linux and Windows support for now) that uses the HTTP Date Header and either the date command on Linux or the w32 API on Windows to set the time. The program runs in about 0.3 seconds, which is good enough for my use case, I need time accurately set within a couple seconds. Basically how it works is that it grabs Google's homepage by default (you can use a flag to set your own URL) and uses the date header to set the system clock. Obviously you'll need administrator permissions for this all to work correctly. I've designed the program to not pollute system mail with useless messages if you run it in cron.

You can grab the binaries here:

And you can see the source code and readme on the project's GitLab page. As usual, it's MIT Licensed.

As with any of my projects, if you'd like to make this better or find a bug, head over to the GitLab page and send a merge request or put in an issue.

A huge thanks to VividCortex for their golang w32 API library.

Update

Apparently this has been done before with htpdate and the HTTP Time Protocol. I won't remove the project, but if you're looking for something a bit more polished and professional, htpdate is the better constructed tool for this purpose.

Fix WebEx Screen Share in Debian

  2016-03-07 03:07:31 PST

In Debian, I was able to get the WebEx java applet to launch in Iceweasel with the help of OpenJDK, but I couldn't get screensharing to work properly. It just never came up when someone was sharing their screen and it wouldn't let me share my own.

Go ahead and install some 32-bit libraries, this should help:
Note: You must have multiarch enabled on your machine for this to work: sudo dpkg --add-architecture i386; sudo apt-get update

sudo apt-get install libgtk2.0-0:i386 libglib2.0-0:i386 libglib2.0-0:i386 openjdk-7-jre-headless:i386 libpango-1.0-0:i386 libpangoft2-1.0-0:i386 libpangox-1.0-0:i386 libxft2:i386 libxmu6:i386 libxt6:i386 libxv1:i386 openjdk-7-jre

Then launch your meeting again. Hopefully screensharing should work. I have heard reports of this not helping with meeting audio issues, but I don't use WebEx audio, I can't comment on that.

If that doesn't work, figure out what else you're missing with the help of this AskUbuntu post.

In case that post ever goes away, I've mirrored the steps here:

From this post, here is a step-by-step method that might work:

  1. Install JDK.
  2. Configure Java plugin for browser (no need for a 32-bit JDK or Firefox).
  3. Start a WebEx to create .so files inside $HOME/.webex/????/.
  4. Check for unresolved .so dependencies: ldd $HOME/.webex/????/*.so > $HOME/check.txt
  5. Search for missing libraries: grep "not found" $HOME/check.txt | sort | uniq
  6. Review the libraries; for example: libasound.so.2 => not found libjawt.so => not found libXmu.so.6 => not found libXtst.so.6 => not found libXv.so.1 => not found
  7. Find the corresponding packages: sudo apt-get install apt-file sudo apt-file update
  8. Locate that package that contains the missing libraries: apt-file search libXmu.so.6 apt-file search libjawt.so
  9. Install the missing libraries, for example: sudo apt-get install -y libxmu6:i386 sudo apt-get install -y libasound2:i386 sudo apt-get install -y libxv1:i386 sudo apt-get install -y libxtst6:i386 sudo apt-get install -y libgcj12-awt:i386

Additional Sources

http://ubuntuforums.org/showthread.php?t=2184620

Command Line Twitch TV Browser

  2016-02-09 07:59:40 PST

Updated: 2016-03-02 - Audio-only functions, easier to change preferred game/language/quality, added MIT license.

I've been watching a fair amount of Dota 2 on Twitch.tv, but I wanted to watch in VLC, rather than taking up a browser tab. I did a small amount of research and discovered Livestreamer. It's a really simple command line utility that launches various live streaming services in VLC, with a super simple syntax: livestreamer twitch.tv/day9tv best.

But then I ran into an annoyance...

I don't watch just one Dota 2 channel. I watch a wide variety of channels depending on who's streaming. I found myself still opening a browser tab, heading to the Dota 2 game page and deciding what channel to watch. Pretty annoying for what should be a command-line-twitch-tv-vlc-launcher. So I did what any other programmer would do: I wrote a tiny crappy little thing to fix the problem.

I can run this script (which I've placed at ~/bin/watchtwitch) with watchtwitch and instantly get a nice menu of who's streaming right now:

1) moonducktv (20281)
2) attackerdota (1931)
3) beyondthesummit (657)
4) y0nd (298)
5) dannygamingnc (204)
6) rexitus (176)
7) dotacapitalist (172)
8) theexel80 (33)
9) xxgodzillaxx (28)
10) dotkaember (19)
Choose your channel:

From there, I hit a number, press Enter, and I'm watching Dota. Pretty rad. You will need livestreamer, on Debian, you can accomplish this with a simple sudo apt-get install livestreamer. You'll need ruby in some form to use this script. You'll also need the Twitch gem, so run gem install twitch.

I've updated this script to use some variables at the top, so it's easier to modify for your preferred games. You can also pass --audio-only while running the script to get an audio-only stream. It's great if you can't watch, but want to listen in to the action.

To get an audio-only stream, use it like this: watchtwitch --audio-only.

Grab the code below, it's really simple if you want to change your preferred language or game:

#!/usr/bin/env ruby

# Requires 'livestreamer': https://github.com/chrippa/livestreamer
# Requires Twitch Gem: https://github.com/dustinlakin/twitch-rb

# Set default options here. You can change these to find different game streams,
# different languages, or set a different stream quality.
GAME = "Dota 2"
LANGUAGE = "en"
QUALITY = "best"

# If "--audio-only" is passed to watchtwitch, we'll set AUDIO_ONLY to true. This
# will force an audio-only stream. This is useful if you are in a situation
# where you can't watch a stream, but would like to listen in and keep up.
if ARGV[0] == "--audio-only"
  AUDIO_ONLY = true
else
  AUDIO_ONLY = false
end

# Import the Twitch gem
require 'twitch'

# Create a new Twitch object
t = Twitch.new

# Initialize our counter and channels array
i = 0
channels = []

# Use the Twitch API to grab all Dota 2 English streams.
# Cut down the list to the top 10 streams, ordered by number of viewers
# Then, for each of those streams...
t.streams(:game => GAME, :language => LANGUAGE)[:body]["streams"][0..9].each do |stream|
  # Increment the counter
  # This will be useful when asking the user which channel to pick
  i += 1
  # Make an empty hash
  # This will hold all of the channel information
  channel = {}
  # Set the channel ID to our counter
  channel[:id] = i
  # Set the channel name
  # This gets used by `livestreamer` later
  channel[:name] = stream["channel"]["name"]
  # Set the number of viewers
  # This is only used to show the user how popular a particular stream is
  channel[:viewers] = stream["viewers"]
  # Push our channel hash into the channels array
  channels.push(channel)
end

# For each channel (all 10 of them)...
channels.each do |channel|
  # Print out the channel ID (from our counter), the name, and the number of viewers
  puts channel[:id].to_s + ") " + channel[:name] + " (" + channel[:viewers].to_s + ")"
end
# Ask the user which channel they'd like to watch
puts "Choose your channel:"
STDOUT.flush
# Grab the user's input
choice = $stdin.gets.chomp
# Start livestreaming whatever choice the user makes We'll execute a native
# binary "livestreamer" (hopefully it's in your path) with the url
# "twitch.tv/channelname", livestreamer has a twitch.tv plugin, so it can figure
# out what to do with that URL. We then set the stream quality, I've chosen
# "best" here, because it's pretty, but you can choose something more sane if
# you have bandwidth constraints or are on a metered connection, check out the
# variables up top. By default, livestreamer launches VLC to play the stream,
# but you can check out it's documentation if you have a better idea. If you
# pass "--audio-only" to watchtwitch, it will use an audio-only stream.
if AUDIO_ONLY
  exec "livestreamer twitch.tv/" + channels[choice.to_i - 1][:name] + " audio"
else
  exec "livestreamer twitch.tv/" + channels[choice.to_i - 1][:name] + " #{QUALITY}"
end

This code is MIT Licensed. Use it however you want.

Tips for installing Arch Linux on Macbook Pro

  2016-01-29 04:19:39 PST

Some pointers on installing Arch Linux on a Macbook Pro. I don't use Arch anymore, but this might be helpful for someone. In these examples, I'm using pacaur instead of pacman for the AUR integration. Check out this page in the Arch wiki for more information on pacaur.

Wifi

pacaur -S broadcom-wl-dkms - I use the dkms version to keep things stable.

Backlight

Set this in /etc/rc.local: setpci -v -H1 -s 00:01.00 BRIDGE_CONTROL=0

LTS Mode (more stable)

LTS Kernel Installation

pacaur -S linux-lts linux-headers-lts nvidia-lts, then use dkms versions of modules to build against your new kernel. Then use sudo grub-mkconfig -o /boot/grub/grub.cfg to create a new boot menu. LTS should be at the top, but if not, you can add these options to /etc/default/grub to make grub save your last boot option:

GRUB_DEFAULT=saved
GRUB_SAVEDEFAULT=true
GRUB_DISABLE_SUBMENU=y

General Kernel Modules

Enable the dkms service to automatically build kernel modules when the source updates. Only install dkms versions of modules.

Virtualbox Host DKMS

Use dkms install vboxhost/$(pacman -Q virtualbox|awk '{print $2}'|sed 's/\-.\+//') -k $(uname -rm|sed 's/\ /\//') to install the virtualbox host modules using dkms.

Mechanical Keyboards

  2016-01-23 18:40:10 PST

Introduction

Mechanical keyboards. Oh hell yes. Clickity clackity. I will type on nothing else as long as I live, given that I have the choice. In this post, I'm going to tell you about two keyboards that I've bought and have been using for a while and why you should take out a second or third mortgage just to type on these beautiful pieces of modern machinery.

The first question you might be asking is "Why mechanical?". It's honestly a hard thing to answer. It's just something you have to feel to truly know the difference. I like to spend my money where I spend my time, and most of my waking hours are spent in front of a screen bashing on a keyboard. Just the feel alone is well worth the money.

The best way I can describe it is this:

Would you rather spend 8 hours a day sitting in this:

or this:

After typing on a mechanical keyboard for a while, every other keyboard feels like using that plastic lawn chair for extended periods of time. The best way I've heard it described is that all other rubberdome (non-mechanical) keyboards feel like typing on mashed potatoes, a very apt comparison.

CODE Keyboard

The first mechanical keyboard I bought was the CODE Keyboard with Cherry MX Clear switches. The keys aren't too heavy, but they have a nice spring to them. If you're a heavy typer like myself, you'll want to get some o-rings to help dampen the sound a bit. I ended up getting the red ones, but I may switch to blue to help enhance the sound dampening. After a while using it, my shift key started to squeak, so I picked up this tube of lubricant and it fixed it up perfectly. Also, any keyboard of mine is going to have a red escape key, it just has to be done.

Later on, I got backlight color covers to try out, but I ended up sticking with the white backlight.

CODE Keyboard parts list and price breakdown:

Unicomp Ultra Classic Black Buckling Spring USB

The second mechanical keyboard I bought was the Unicomp Ultra Classic. If you've ever used the classic IBM Model M keyboard, you know exactly what you're getting into. This keyboard is a buckling spring board, and the only difference I can see in this and the classic Model M is that the housing is a bit smaller, the color scheme is different (if you chose black like I did), and it has a USB connection (but you can get a PS2 connection instead). It's heavy, it feels fantastic, and I only have one small complaint: The rubber stoppers on the bottom slide a bit, unlike the CODE Keyboard. I think bigger rubber stoppers would help aleviate this problem, but it isn't like the keyboard just slides around everywhere, it's a subtle tiny problem.

This keyboard feels and sounds (IBM Model M sounds, but it's the same thing) absolutely amazing. The buckling springs are nice a crisp, you know when you've pressed a key and accidental presses don't happen. The key springs are heavy enough that you can rest your fingers on the keys, completely dead-weight, without accidentally pressing down a key. The keys spring back nice and crisp, ready for orders.

The keys look fantastic as well, the glyphs are created using dye sublimination, which means you cannot wear the prints off of the keys, as the plastic of the keycaps are stained with that particular glyph. The result is that the keys will continue to look nice for the next few decades.

Probably the greatest feature of this keyboard is the price, a mere $84 for the keyboard. You're not gonna get a backlit keyboard that will fly you to space or get you to the top of /r/mechanicalkeyboards, but what you are going to get is a fantastic keyboard with a great feel, that will be absolutely reliable for a decade or more. Well worth the money all by itself.

But that didn't stop me from adding a small number of additions: A red escape key, and a tux keycap set to replace my Windows keys.

But wait! There's more! These are made in the USA. In Lexington, Kentucky to be exact. Also, I recieved a key that was the wrong size in my Tux Key Set, so I emailed customer service, got a reply crazy fast, and they shipped me the proper key right away. Great customer service, no bullshit, no jumping through hoops, just making people happy quickly and easily. I'm very impressed.

Unicomp Ultra Classic parts list and price breakdown:

Which do I like better

I have to say, I do much prefer the Unicomp keyboard. It's crazy loud, it's not fancy, there's no backlighting, but it just feels great and the price is unbeatable for a well-respected and well-made mechanical keyboard.

Mechanical Keyboard Resources

Page: 4 of 32