jb… a weblog by Jonathan Buys

More Scout Tips

March 13, 2013

Eventually I’m going to need to compile this into a proper help doc, but for now, documenting Scout with Scout will do.

Scout handles pages just a little differently than posts. New pages do not show up on the home page, and are not organized into subfolders based on date. Pages are converted into HTML and saved in the root of the site directory, right next to index.html. To create a page, add a new post, but before the title of the page add the characters @@ . That is two “at” symbols followed by a space. For example: @@ Contact.

Secondly, the default theme that ships with Scout, the theme of this site, is my own creation that I’ve cobbled together over the past few years. What I hope to see are a few people more talented than I create some really great themes. In fact, assuming Scout is successful, I plan on hiring a designer to do just that. However, there are a number of hurdles to overcome before that happens.

To create a Scout theme, create a folder with the following files inside:

  • atom.xml
  • atomTemplate.xml
    • The two xml files are for creating the site RSS feed.
  • base.css
    • Should contain all of the site CSS
  • default.html
    • The standard HTML template for the site.
  • indexTemplate.html
    • Wraps each post in a div with an id of “posts”.
  • post.html
    • Creates the page template for each post
  • robots.txt
    • Not currently used, but probably should be.
  • screenshot.png
    • A nice screenshot of the post at 400x341 pixels.
  • toc.html
    • The template for building the archive or table of contents.

Scattered throughout the files listed above are strings that look like: YYYY_SCOUT_SOMETHING_YYYY. These are the Scout “Y Codes”, as in, “why are they so ugly?” I was looking for something that was unlikely to be reproduced anywhere else, and this was the first thing that came to mind. I currently have the following Y codes defined:

  • SCOUT_5ATOMPOSTS
  • SCOUT_AUTHOR
  • SCOUT_CONTENT
  • SCOUT_CSS
  • SCOUT_CURRENTDATE
  • SCOUT_CURRENTYEAR
  • SCOUT_POST_CONTENT
  • SCOUT_POST_DATE
  • SCOUT_POST_TITLE
  • SCOUT_POST_URL
  • SCOUT_SUBTITLE
  • SCOUT_TITLE
  • SCOUT_URL

Hopefully, the titles of the codes are self-explanitory, but as I have time I will be documenting them properly. For now, you can probably take a look at how the files in default.stemplate are arranged. Scout looks for these codes in the template and replaces them with the proper data from the posts to generate the site.

Lastly, you should never feel like you need to save your work in Scout. Scout automatically saves your work at various intervals. For example, whenever Scout looses focus as the main window, or whenever a new post is chosen, or when a new view is looked at, Scout automatically saves the current post as a plain text markdown file saved in ~/Library/Application Support/Scout/Posts/. If you like you can watch the file being written to in the finder or as you use the application. Likewise, if you have a markdown file that you would like Scout to know about, you simply need to name it according to the naming convention of YYYY-MM-DD-HH-MM-SSSS##Title_Of_Post.markdown and drop it into this directory. Next time Scout is restarted it will treat this file as its own.

Scout is intended to give you control over what you write without getting in your way about it. I know there are going to be some rough edges, but as we progress I’m sure they’ll get worked out.


Beta Testing Scout

March 12, 2013

Well, as much as I’d love to procrastinate for the rest of eternity, the time has come for Scout to take it’s first baby steps out of it’s private testing ground and out to a few interested folks who would be brave enough to beta test.

Alt Text

I’m honestly very happy with how Scout is turning out so far. It seems very stable, and now that I’ve worked out a few annoying bugs it is as easy to use as I’d hoped. Here is a quick rundown of supported features:

  • Markdown Editing - Scout is built for Markdown.
  • Post Previews - The post is rendered into the chosen theme, so what you see in the preview should be exactly what you see when published online.
  • Media Manager - A nice grid of the pictures Scout knows about.
  • In-line Image Preview - Speaking of images Scout knows about, dragging and dropping an image onto the text editor will create the markdown code for inserting the image in the post, and clicking on the text will show a pop-up preview of the image.
  • Themes - Scout supports a very easy theming model that I’m hoping will attract web designers.
  • Text Editor Themes - A few nice built-in themes. I generally use Solarized Light.
  • A Very Nice Full Screen Editor - Where I spend all my time in Scout.

Since I’m shooting for 1.0 here, there are a couple of features that I’ve intentionally left out because they were simply not there yet.

For one, no syncing support just yet. I have the inner structure to support syncing over Dropbox, or any other form of file syncing, but in practice it is a bit janky, so it will not be supported in 1.0.

Secondly, Scout will only publish to a folder on your hard drive. It will not publish to the web. I’m working on integration with Site44, but as with syncing support, it’s just not quite polished enough to include in the 1.0. With that being said, I’m hosting this site with Scout and Site44, I just choose the Site44 folder with the publish file picker. Works well, but could be smoother. Maybe that’s a 1.1 or 1.2 enhancement.

Anyway, I would be grateful if you would beta test Scout for me. If you are interested, drop me a line on twitter. I’ll get right back to you.


Real Music

February 1, 2013

My grandparents house was outside of town, at the foot of the mountains, surrounded by woods. Papa kept his guitar in a black case under his bed, along with his violin. Sometimes, after dinner, if we grandkids begged and pleaded enough, Papa would get his old guitar out and play us a few tunes. They were simple folk songs, sang without any of the southern drawl common in country music. One I remember the most was about his mama sending him to town to buy a chocolate ice cream cone. The little house would spring to life those nights, we would be warm from the fire, and full from Grandma’s cooking, and listen to the simplest, most honest music I have ever heard.

Papa tried to teach me how to play, and I think if I had not been so young and stubborn I would have listened to him. He would tell me where to put my fingers, I would get it wrong, and he would grab my fingers and try to put them where they were supposed to go. It didn’t work out, and so far I have only learned a few basic chords. Right now my guitar sits in the corner of my office, staring blankly at me through it’s black case, waiting for me to bring it to life.

Sometimes a friend will come over who knows how to play, and I’m always amazed at how he can call such beautiful music from the strings of the guitar that I can only coax out a basic tune from. Years ago this friend and few other sailors who shared a place in Virgina would get together to write, play, and even try to sing. For now, learning to play guitar is still on my to-do list, but appreciating honest music has always been close to my heart.

The other day I was helping my daughter do the dishes, and we were taking turns picking songs to listen to while we washed. She would pick out one pop song after another, and as she did I realized that pop music hasn’t changed in at least twenty years. It is still as synthetic and manufactured as ever, pandering to the lowest common denominator. I struggled to find something that we could both enjoy, but almost every song I chose was coldly marked as “weird”.

She has a point, a lot of it is strange. Strange, and a bit raw, unprocessed, analog. I have, so far, 22 albums of the Grateful Dead, most of them live bootlegs from the seventies. There is something about the energy of the live shows, how I can close my eyes and almost be there. Sometimes you can hear the crowd yelling out asking for a song, the Dead hear it and when they start playing you can feel the energy spread through the crowd like wildfire, the beat of the drums matched by clapping hands. There was nothing scripted about these old shows, the Dead would just get up there and start playing.

This is real music, a person and an instrument coming together to create something beautiful. From Papa’s strumming to the Dead’s wall of sound, there runs in my musical preferences a common thread of musicianship, of jamming for the love of the song. I was browsing through the Archive’s library of Grateful Dead shows the other day when I saw mention of a Grateful Dead cover contest. That mention led me to YouTube, where I found one of the best covers of one of my favorite Dead songs:

The Giving Tree Band had me captivated as soon as I heard the violin, but when the steel guitar and the piano started, I was there. It’s not just the song, although it is a fantastic song, and it is not just that they have these instruments, the band appeals to me because it sounds sincere. It is hard (for me at least) to explain the difference in this recording and any other, but I think it has a lot to do with the lack of post processing. I believe I’m hearing the musicians real voice, not a digitized representation of it that’s been leveled and artificially harmonized. I’m hearing the banjo, and the electric guitar as the musicians intend their instruments to be heard.

I love music, even if I would sometimes rather drive in silence. I like to listen to music that relates to me, that’s played by people who might just drop by for a cup of coffee to catch up on old times. Music that makes me feel at home. Music that reminds me of the smell of burning pine, the taste of pumpkin pie fresh on my lips, the sound of Papa’s guitar, and knowing deep in your heart that you are warm, safe, and loved.


Paperman

January 31, 2013

Just beautiful.


Electrogent's 50 Rules

January 30, 2013

One of my favorite things about the Internet is finding a little treasure trove of writing and style that I previously did not know existed. Electrogent is one of those little gems, and his list of 50 rules for his son is full of timeless advice.

Thanks to science, we have all sorts of polymers, synthetics, polyesters, crystalline, and other man-made materials for making life a little better. However, few materials are as awesome, timeless, and useful as leather.

Travel the world… but then come home. Your mother misses you.

You should strive to become an expert in everything like Galileo. The old adage “shoot for the moon and even if you miss you’re still among the stars” applies here. Even if you try and fail to become a great master in all fields of study, you will still attain great knowledge across many disciplines and become a well-rounded person. Even though failing is sometimes necessary, there is basically no way to fail in this pursuit because anything you learn is a success in itself.

Life is meant to be a quest of continuous self-improvement, becoming a little better every day. Electrogent gets it.

Don’t miss his fantastic gallery.


Details

January 29, 2013

Thought of the week:

I don’t like this “top ten” business. It’s the bottom ten that I like. I think you’ve got to go for the little things, the stones that make up the wall.

– Donald Knuth


Vim Power

January 28, 2013

vim_iconNo server, desktop, or laptop install is complete without Vim, and yet, there are times when I still see questions pop up on IRC about how to do basic editing of config files with vi. I remember, years ago, asking some of the same questions of an older Unix guru, and asking why I should bother learning such an eccentric and “outdated” text editor. His answer has stuck with me, he said “Because it is the only text editor guaranteed to be on every server, and some day you will need it, and have no other alternatives.” Vim, short for “vi improved” is ubiquitous, but it is also so much more, and the time you spend learning it will be repaid to you tenfold in productivity.

Vim is designed to be run from the command line, without a mouse. To get around in a file, Vim uses three different “modes”, where the same keys might do very different things, depending on which mode you are in. From my experience, this is the biggest obstacle of learning Vim, wrapping your head around what mode you are in, and how to navigate the text.

When you first launch Vim, you are in normal mode. Normal mode does not allow you to edit the text directly, but allows you to move the cursor around the text using the keyboard. The basics of what you need to know are:

  • j - Move the cursor down one line
  • k - Move the cursor up one line
  • l - Move the cursor to the right one character
  • h - Move the cursor to the left one character

Once you have the cursor where you want it, you can press “i” to enter the next mode, “insert”. Insert mode behaves more like other text editors, where the keys you press show up as text characters in the file. When you are done editing, you return to normal mode by pressing “Esc”. This is a good start for getting used to how Vim works, and over time, those keys will become ingrained as muscle memory, you might find yourself inadvertently reaching for the escape key after typing in a web form.

Moving around one line or one character at a time is fine, but time consuming. What if you would like to move the cursor down five lines? In that case, you would enter “5j” in normal mode. What if you know exactly what line number you would like to jump to, say line 42? Enter “42G” in normal mode, and you will jump down to that line. Or, if you would like to jump straight to the end of the document, you could just enter “G” by itself. I do this quite a bit, jumping between “1G”, the first line of the document, and “G”, the last. If you would like to move 10 characters forward, you would enter “10l” in normal mode. Same to move back, “10h”

What if you just moved down ten lines, and would like to move down another ten lines? You could enter “10j” again, but it would be faster to use another Vim shortcut, the humble period. Hitting “.” in normal mode repeats the previous command. So, whatever you did last, hitting “.” will tell Vim to do it again.

Hitting “i” in insert mode will allow you to start inserting text, however, there are a few other options as well.

  • a - Append, or, start adding text right after where the cursor is
  • o - Create a blank line on the line below the cursor, move the cursor to this line, and enter insert mode.
  • O - Same as above, but the new line goes above the cursor, not below

Once you have the basics of when and how to insert text, moving around the text becomes more important. Luckily, Vim knows text well, and has a few tricks here as well.

  • w - Move the cursor ahead one word
  • b - Move the cursor back one word
  • ( - Move the cursor back one sentence
  • ) - Move the cursor forward one sentence

What about copy and paste? Vim has that covered as well, but instead of “copying” text, you “yank” text with the “y” command. To yank the current line, which means to copy the current line, you press “yy”. To paste the line, move the cursor to where you would like it and press “p” in normal mode.

So, now that you can fly around your text with ease, and insert new text at will, what are you going to do about the plethora of typos? A few more normal mode commands to commit to memory are:

  • d - Delete one character, word, sentence, or the entire file if you like
  • r - Replace one character
  • R - Replace all the characters till you hit escape, just write right over them

To use the delete command, you can either place the cursor over the text you would like to delete and press “d”, or you position the cursor at the beginning of a string of characters you would like to delete, for example, to delete one word, you press “dw”. To delete five words, you press “5dw”. To delete a sentence , you press “d)”. To delete the entire file, you could jump to the beginning of the file: “1G”, and delete to the end: “dG”.

And if you make a mistake? No problem, Vim keeps a detailed record so you can undo the last command with “u” in normal mode.

So, you can jump around the file, insert text, and delete text. How do you save the text? To do this, we need to enter a third mode, command mode. To enter command mode, you must first be in normal mode, and then press “:”. You should see the cursor move to the very bottom of the window next to a colon, waiting for you. To save the file in the current working directory, you would enter:

:w FileName.txt

If your file already has a name, then simply entering “:w” will work.

That’s most of what you need to know to become proficient with Vim, but of course, there is so much more. I’ve barely scratched the surface of what Vim can do on its own, not to mention Vim’s vibrant community of users and developers who have extended Vim through plugins. It is through the plugins that some real magic can start happening. However, to avoid asking on IRC how to edit a text file, this should have you covered. Finally, when you are finished editing, jump into command mode and enter “wq!”.


Meta

January 26, 2013

You get good at something by doing it repeatedly. I’ve been writing on this site for six years now, but with little direction or topic. I’ve gotten good at not making anything of the site, which is not where I wanted to be when I wrote about why I kept this site in 2011. I’ve not kept to a regular schedule, or a common theme, so I am not surprised to see that the only traffic I have going to the site is my own, and a few that found the site from Google. The preceding statement will make the next seem a bit ridiculous, but bear with me.

I’m starting a weekly sponsorship program for the site. When you sponsor a week of posts on jb, your product post will appear in the main feed three times, Monday, Wednesday, and Friday. Your product or service will also be mentioned in the site header for the week. Sponsoring jb will expose your product to a small, but growing, audience of creative and technical professionals. Consider this your opportunity to “get in on the ground floor”.

I have, for the past six years, been practicing finding my voice, my interests, and honing my writing style. I have also been deciding on the topics that interest me, that I’m passionate enough to write about, and that I care enough to share with the world. This is a site about quality, quality in our things, how we choose them, what we decide to accept into our lives, and what we spend our time on. I want to shine a light on the goods and services that I find exceptional.

I am also putting up some barriers to what I will write about here. I will not write about systems administration topics, or anything dealing with the general topic of open source software. I already have a venue for those topics, so they are out of scope here. If an open source application that I use is outstanding in some way or another, I might cover it here, but not on the merits of it being open source. Personal and family subjects have been mostly taboo since I started, and will remain so now. I will also not talk about politics or religion. These barriers are mostly to keep myself on track.

This is also a site about the pursuit of excellence in all that we do. This site is about using things that are worth having, and spending our time building things that are worth selling. The previous years were a warm up, the main game starts now, this is a great place to start reading.


Cutting Corners

January 21, 2013

After reading the MacSparky piece on craftsmanship, I’m reminded of how I like to look at my career as a systems administrator. I find that there are times when things that are not quite right just bother me. Like when there are inconsistencies or one-offs scattered throughout the environment I am responsible for. There may well be perfectly logical reasons why some systems are monitored and some are not, why some are registered with configuration management and others are not, but in my mind it is these little inconsistencies that add up and make your work look sloppy.

A craftsman is not sloppy. They are careful, competent, precise, and thorough. It is knowing that the little details matter, if to no one else but you, the accumulation of details is what defines the quality of your craft. It is knowing what the right tool for the job is, it is knowing when to use the power tools, and when to do it by hand. It is knowing that every corner you cut will come back to you in the end.

Cutting corners is unacceptable for a professional sysadmin. It doesn’t matter if you consider yourself “devops” or an old school neckbeard, you must decide to do the right thing and make sure that all of your bases are covered. I like to think of the environment like the internal workings of a clock. There are lots of tiny little gears, but when they all work together, you can feel the system ticking happily along.

Your profession matters less than how you approach your work. Do you do it sloppily, haphazardly, or as a craftsman?


Misunderstanding NSString

January 19, 2013

So, while I was debugging the first post using Scout, I found an oddity in NSString. I was building the links between the posts using stringByAppendingPathComponent, to join the site’s base URL with the path component of the individual post. Unfortunately, that method seems to be stripping one of the forward slashes off of the http:// string, which screws up building links.

To test it, I created a blank Xcode project, and added this method to the App Delegate:

-(void)awakeFromNib
{
NSString *first = @"http://first";
NSString *second = @"second/part.html";
NSLog(@"first + second = %@", [first stringByAppendingPathComponent:second]);
}

And, sure enough, here is the output from that method:

2013-01-03 19:26:02.388 NSStringTester[39861:303] first + second = http:/first/second/part.html

A quick search through Scout’s source files shows that I’m using stringByAppendingPathComponent 53 times. Looks like I’ve got some work to do.

Also, this is a good time to point out that when you are doing web development, it is very important to test with multiple browsers. Safari hid the problem, Firefox did not.

Finally, it turns out that this is not actually a bug in NSString, but a bug in my understanding of this method. My thanks to Matt Yohe who was kind enough to point out my mistake on Twitter.

@ibuys @eridius also: “Note that this method only works with file paths (not, for example, string representations of URLs).”
  — Matt Yohe (@mattyohe) Thu Jan 3 2013 7:34 PM CST

I’m still considering filing this as a bug, but I can see where they are coming from. Double slashes would not work for a file URL, but if they are already parsing the string for something like that, why not just check for “http” as well?