jon wear's personal website

New direction for my blog

10 July 2017

Hey all, my job changed a while back. I'm no longer a full time developer(another post for another time), although I still code on occasion.

My wife and I started fostering two brothers in September of 2016. So we went from 1 kid to 3 kids. Fostering is without a doubt one of the best things I've ever done with my life (this too warrants its on post, probably posts).

Since I don't go out as much these days, I found myself getting interested in something equally nerdy, card magic...

So...future posts will probably have more to do with that than with various tech related things. I still find tech interesting (especially golang), but I'll be consuming that content as opposed to (very occasionally) creating it.

Here's the outtakes from me trying to make a card trick tutorial video back in December. The finished product isn't that good, but I thought the outtakes were funny.

Comment on my subreddit.

By Jon Wear

Your own Go blog

19 September 2015

This post is based on a talk I gave at the Philly Go Meetup on September 8th .

Now that I have my blog running using the same blog engine that uses, I thought I'd write up a post to explain how I did it.

Get a server

You gotta host it somewhere. I used I got a Linux server with enough power to run my lowly blog:

  • 4 Cores @1.3GHz
  • 2GB memory
  • 50 GB SSD
  • 1 public IP
  • Costs €2.99/month which is currently $3.34

Turn it on and ssh in. Be sure to run:

apt-get update
apt-get upgrade

Now you have an up to date server.

Install Go servers use ARM processors so I found it easiest to just install Go on the server and do my builds there. You could install Go 1.5 locally, target your build and copy it up to your server however you wish. But that's not how I did it.

apt-get install golang

As of now that installs version 1.3.3:

go version go1.3.3 linux/arm

Be sure to set your GOPATH

Get the code

Download the code from here:

I recommend that you make your own git repo with the release code. Be sure to keep the BSD license in place.

From inside the directory run:

go get

Build the binary

go build blog.go local.go rewrite.go

Now you could launch the freshly built binary, but you don't have a way to get to it from the outside yet.

Install nginx

apt-get install nginx
service nginx start

Make sure you see the nginx startup page by navigating to the public IP address of your server.

Configure nginx

Our blog binary is going to be listening on port 8080. We want to serve requests/responses on port 80. We need to tell nginx to proxy between 80 and 8080.

Put this inside the html { } section of nginx.conf file.

server {
 listen         80;

 server_name    IP_Address_or_URL;

 access_log   /var/log/nginx/blog/access.log ;
 error_log    /var/log/nginx/blog/error.log info ;

 location / {

Daemonize our blog binary

Simple right? We're almost there. We could start our go binary right now by just invoking it from the command line, but if it crashes for some reason we want it to start back up. If we reboot our server, we want the blog server to start up again without us having to do it. So let's daemonize.

If you've never seen a System V script before, this may make you a little glassy eyed, but don't worry, it's mostly boiler plate. There's only one thing to change, the dir= part. Put in the path to the directory that contains the blog binary there. Keep the enclosing double quotes.

# Provides: blog
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start daemon at boot time
# Description:       Enable service provided by daemon.


name=`basename $0`

get_pid() {
cat "$pid_file"

is_running() {
[ -f "$pid_file" ] && ps `get_pid` > /dev/null 2>&1

case "$1" in
if is_running; then
    echo "Already started"
    echo "Starting $name"
    cd "$dir"
    if [ -z "$user" ]; then
        sudo $cmd >> "$stdout_log" 2>> "$stderr_log" &
        sudo -u "$user" $cmd >> "$stdout_log" 2>> "$stderr_log" &
    echo $! > "$pid_file"
    if ! is_running; then
        echo "Unable to start, see $stdout_log and $stderr_log"
        exit 1
if is_running; then
    echo -n "Stopping $name.."
    kill `get_pid`
    for i in {1..10}
        if ! is_running; then

        echo -n "."
        sleep 1

    if is_running; then
        echo "Not stopped; may still be shutting down or shutdown may have failed"
        exit 1
        echo "Stopped"
        if [ -f "$pid_file" ]; then
            rm "$pid_file"
    echo "Not running"
$0 stop
if is_running; then
    echo "Unable to stop, will not attempt to start"
    exit 1
$0 start
if is_running; then
    echo "Running"
    echo "Stopped"
    exit 1
echo "Usage: $0 {start|stop|restart|status}"
exit 1

exit 0

Start the service!

We're almost there!

Now, at the terminal prompt on your server type:

service blog start

Your blog server should be running. Check your IP address http://YOUR_IP and you should see the sample content. Set your domain via DNS to your IP and you're all done.

Comment on my subreddit.

By Jon Wear

Self Description - Text

9 February 2015

One of the comics that has really stuck with me over the years is this one:

The part that inspired me to write some Go code wasn't the image itself, but the hover text which reads as follows:

"The contents of any one panel are dependent on the contents of every panel including itself. The graph of panel dependencies is complete and bidirectional, and each node has a loop. The mouseover text has two hundred and forty-two characters ."

That was clever. A bit of text that includes the length of the the text within the text itself. So, I wrote some program that does it for any text up to 1,000 characters. It ignores trailing spaces, but other than that, you type and it will append the length of the text (including the length of the text).

I went about it this way:

Calculate the text for a given integer ("one" for 1, "twelve" for 12, "thirty-seven" for 37) & store the length of that text representation. You can find the loop for this here and the actual functions that convert number representations to text representations in this file.

Next, I call up my old buddy brute force. For every text length between 1 and 1,000, I take the text submitted (for example, "Hello World!") and I add the text representation of the current loop integer. Then I check to see if the actual length of those two bits of text concatenated together equal the length (number wise) of the text form of the number. If they are equal, great! I have a match and return it. In this case:

Hello World! This text is fifty-nine characters in length.

It all happens here:

func ProcessText(text string, items []TextLengthItem) string {
    firstParts := []string{"This text is %v characters in length.", "Text is %v characters long.", "Text is %v characters in length."}
    result_template := "%v  %v"
    textLength := len(text) + 2
    for _, firstPart := range firstParts {
        for _, item := range items {
            length_sentence := fmt.Sprintf(firstPart, item.Text)
            if textLength+len(length_sentence) == item.Value {
                return fmt.Sprintf(result_template, text, length_sentence)

    return "No match found."

Make a simple bit of formatting text "%v %v". That's two place holders separated by 2 spaces (thus the + 2 on line 4). Add the text to position one, add the text of the number to position two, and then see if the total length matches the numeric value of the number you put in position two.

There are more elegant ways, I'm sure. Even for brute force, you could decide to start your brute loop with the length of the submitted text instead of 1.

That's almost all there is to it. One thing I discovered is that sometimes, certain lengths of text just won't match up. You can check everything and nothing will give you that nice recursive bit of text. I got around that by giving more than one boiler plate phrase. Instead of just using, "This text is %v characters in length."

I use two more phrases that say the same thing but have different over all lengths.

firstParts := []string{"This text is %v characters in length.", "Text is %v characters long.",
"Text is %v characters in length."}

So far one of these three phrases has caught every possible length between 1 & 1000. You can tweak the code to go higher if you want.

Code & installation instructions can be found here:

By Jon Wear

Life without a .Net

23 September 2014

I wrote code exclusively on the Microsoft platform from 1997 until late 2013. Sixteen years of ASP, ASP.Net, Visual Basic (4,5&6), VB.Net, wonderful C# and lots of MS SQL Server. I could take a pile of computer parts, assemble them into a server, load the current flavor of Windows Server, IIS and MS SQL Server, and assorted .Net Frameworks. Then I could design a database, write the code(C#, assorted JavaScript add-ons), put it all together and Ker-Pow, a working software application/website/platform thingy.

And those applications worked! And there were always more .Net jobs waiting for more things to be built. And then, one day, while looking at Visual Studio 2013 I realized, I can't do this anymore. I tried to slog through. I know that everyone feels burnout from time to time, but I was starting to get a little worried at the thoughts going through my head.

Do you still want to be a software developer? What else can I do?

I had recently moved from a startup (using .Net) to a big multi division company that had an Information Technology Department. You know the kind of place I mean. A cube farm that spanned an entire city block. Bookshelves full for Wrox & MS Press titles. Motivational slogans. Well stocked Keurigs. Glass walled conference rooms. End tables for network printers that had the \\unc\\ taped to the front. My title was Senior Software Webgineer or some such. The company was so big in fact, that the job I was hired to do had already been contracted out by the department that originally contacted IT. Nobody told the hiring manager. So after my on-boarding, there was not much for me to do. I went to a few hackathons on the weekends. That helped some, but the main problem was I didn't want to work in the .Net-corporate-IT-business-causal world anymore. There was nothing wrong with the people at the company, it was all me. I was tired of the dress code, the culture and the tech. But at the same time I was scared to leave it. It was all I knew. That was part of what was bugging me.

I went to a meet-up for the relatively new programming language called Go (golang). I had been messing around with the language in my free time just to break the .Net monotony. The company that hosted the meet up said they were hiring and to talk to them if interested. I was. I knew this place would be different from what I had done in the past. I also knew that I had zero skills in the tech stack they used. At that point I'd written maybe 100 lines of Go, and they were primarily a Python/Django shop with a few projects in Go. But I told them of my interest anyway and they suggested that I submit a resume. I did. Two interviews later I got the offer. I was sitting in my cube in Corp-IT-Ville when I got the email. I raised both hands in the air (clinched fists I think) and hissed, "Yessssss!"

I started out with new company with about 100 lines of Go code experience and a crash course in the Django tutorial. But man, what a curve. If it was just the language differences, that would have been easy enough, but it was more than that. No Windows machines. All developer machines were OSX. And the development environment? Well they used a tool called Vagrant, which housed a Linux build via Virtual Box with MySql and Gunicorn and Celery and Nginx and can you check out this feature branch and submit a PR that we can review? Lots of command line...commands. My head was spinning. I was asking questions and Googling. A lot. I found myself thinking, "If this were on Windows, I'd do this thing this way!" But I wasn't on Windows. Every day I was learning new things, which was great, but I was also finding out about new things that I did not know anything about.

And that was the worst part. After about five months, I still was not able to turn things around as fast as I wanted to in my new job, but I also wasn't up to speed with the Microsoft world either. New versions of C#, SQL Server and Visual Studio were released. I did not know what the new features were. I was trapped between the two worlds and I couldn't be productive in either of them like I wanted to be. So what's a developer who is in over his head to do?

Slog through it. Day after day. Google dumb questions. Ask dumb questions. Get no where. And then one day something makes a little bit of sense. Slowly, I learned how to make changes to code that caused errors but...they were errors that I was expecting to see. That's the Eureka moment. When you can break source code in expected ways, soon you can make it do new things. Things like, new features or bug fixes. It's all the same thing, modifying the behavior of the code so that it responds the way it should.

Now I code in Go(golang) and Python. I can form my thoughts into these new languages and produce thing that work. Both of these languages have made me a better overall developer because they force me to think about code in different ways. My pull requests still generate some chatter about how things could be improved, but then that's what pull requests are for. Occasionally I'll get a, "oh, I didn't know you could do that" from some one. It's cool when that happens, and not because it means I'm a big shot (ha!). It's cool because, after having a team of developers patiently answer my questions for almost a year, it's nice to be able to give back, if only just a little bit.

To wrap this up, the journey was more than worth it. Writing software is as fun as it's ever been. It's hard to be a beginner in a field where you thought you knew a lot, but it's a necessary step if you want to continue to grow.

By Jon Wear

Simple Git configurations for beginners (like me)

15 February 2014


As the shores of Microsoft disappear over the horizon, I find myself using tools that I used to think of as convoluted command line hacks and black magic. Things like Git. Of course, now that' I've used Git for several months in a for real multi-user multi-location environment, I love it. Not only do I use it, but I'm comfortable enough now that I don't even use the GUI's. I'm all CLI like the real hipster programmers.

I use Git and Github a lot these days. It's cool and all but there were the inevitable hickups along the way. Lots of Googling. Here's a list of things that I wish had been all in one place when I started. I provide this for others(my future self included) who might be new to Git/GIthub and want to lessen the learning curve a bit. These tweaks assume you already have Git installed, a free Github account and an SSH key. If not, create an account at Github and follow these steps to create an SSH key. Moving on...

These are the problems I ran into early on and how they got fixed plus a few tweaks.

Every time I do a git push to a repo on Github, I get asked for username and password.

This is most likely because you did a git clone from HTTPS and not SSH. I'd post a screen shot but the UI will probably change at some point. Look on the github repo page, find the clone URL and make sure that you are copying the one for SSH. More Info.

I make changes on my local branch, but when I push to Github it says, "Everything is up to date" even though it's not.

Instead of doing git push, do

git push origin <branch name>

as in:

git push origin newfeature

More info

I get asked for a pass phrase every time I do a push or pull.

On the command line type: - eval $(ssh-agent) <enter> - ssh-add <enter>

Helpful git aliases

You can run these at the command line to make typing git commands a little easier.

  • $ git config --global checkout
  • $ git config --global branch
  • $ git config --global commit
  • $ git config --global status

git commit becomes git ci. git checkout becomes git co and git branch becomes git br. (These aliases were taken from Scott Charon's book Pro Git).


It's nice to have some color on the command line. Set this so that the git diff, git status and other commands return some color variation to make things easier to read.

  • $ git config --global color.ui true
  • More Info

One more thing

Instead of doing git commit -m 'message' all the time, you can do a git commit -av which will launch the default text editor, let you view the changes that are going into the commit AND type the commit message. I like using Sublime, so updated the git config to do so.

git config --global core.editor "subl -n -w"

More Info

If you see anything wrong, let me know. Present and future me thanks you, but not past me. Past me is a corner cutting jerk.

By Jon Wear

See the index for more articles.