Avocode

The bridge between designers and developers

ALWAYS BE IN SYNC
Share with a link and instantly get updates from your designer.
No more e-mail attachments or huge PSD uploads.

WEB & NATIVE APP
Preview and inspect PSDs on the web or use the native app
on any platform - Mac, Windows or even Linux.

EVERYTHING FROM A PSD
Choose anything from a PSD and get exactly what
you need – CSS, SVG, images, fonts or colors…

You know, I am starting to get that “designer” itch again. I am not a designer; but, I can pull something outta my ass every once in a while. Going to try to get a private beta to see if I can use this for some projects as well.

#HatTip ForgetFoo

Leave a comment

Bitcoin’s IRS-blocking ‘Dark Wallet’ Launched Today

Hyper-Anonymising Bitcoin Service ‘Dark Wallet’ Launches Today

I first heard about this Dark Wallet protocol a few months ago when New York state announced they are regulating Bitcoin. And recently when the IRS announced it is retroactively taxing Bitcoin as property, the community brought up the Dark Wallet system again.

I have bitcoin and do not plan on paying any tax on it. I didn’t “buy” any amount using taxable USD, and don’t see a need for “regulation.” Trying to tax my Bitcoin is basically using a gun to say I need to pay a tax on the open-source software I write: it has value to a select few, and is completely useless to most.

The alpha version of Dark Wallet – the hyper-anonymising bitcoin wallet – goes live today.

Created by Amir Taaki and Cody Wilson, Dark Wallet provides new tools for financial privacy, including in-built coin mixing and ‘stealth’ wallet addresses.

As well as making it easier for people to disguise their transactions from the government, Dark Wallet is also a torpedo aimed at those in the bitcoin community who have embraced co-operation with regulators.

Conceived last year and partly funded by $50,000 raised on Indiegogo, the wallet was developed by unSystem, a collective of anarchist bitcoin developers. It represents an ethos that has been largely excluded from the mainstream discourse around bitcoin.

In January of this year, Circle CEO Jeremy Allaire told CoinDesk that bitcoin was “absolutely” moving away from its libertarian roots, and described attempts to avoid the regulation of bitcoin as playing into the hands of “anarchists and criminals”.

And I personally liked this little nugget from the related article…

If your goals are to create a sort of shadow financial system that runs in offshore jurisdictions and is attractive for anarchists and criminals, then maybe [regulation] is not important.

The power to tax involves the power to destroy.

~E

Leave a comment

The Static Blog Boom

There is a new movement taking place in web development over the last few years. It is called static sites. Just as it sounds, it is simply a collection of .html, .css, .js and images that serves up a complete site. What you may not know is that there are literately 100s of frameworks out there that generate these static sites for you from a single common theme/template.

Static Site Generators

I stumbled upon a collection of these frameworks here:

http://staticsitegenerators.net/

This is pure opinion, but it would seem that most of these frameworks came out of the Linux/OSX world from developers that needed to generate a static site for this or that. Those that did it often, needed a way to regenerate a whole static site by just changing, say, the header area.

I know that after my recent conversion to Octopress (aka Jekyll) I have been brainstorming about my own static site generator. As you can see in the link above, I am not the only one that had a similar thought.

Advantages to Static Sites

If you sit back and think about it, there are a number of advantages for running a static site.

Hosting costs

Can you really get any cheaper than free? GitHub pages can host your static site for free. If you really want to pay for something, then upload your static site files to Amazon S3 file storage and serve your site from there – for about $0.25/mo for 1000 uniques.

Security

You never have to worry about someone hacking your site. No SQL injection, XSS, CSRF attacks.

Even if someone was to gain access to your hosting account, there is no database or code to hide backdoors in.

Defacing

If someone gains access to where you are storing the files and defaces the site, just redeploy – which overwrites everything.

Simplicity (aka Serenity)

It is just a bunch of html, images, css and js files. You really can’t get any simpler than that.

How a static site becomes dynamic

The real power behind these static sites is the interactions that the end user have on your site using 3rd party remote widgets. It makes your site seem fairly dynamic by giving recent information. Just to give you an idea, here are a few widgets built into most of these frameworks:

  • Flickr photo albums, single photos
  • Disqus commenting system
  • Google Forms/Surveys (aka Contact Us, product support, etc)
  • Stackexchange Profile
  • GitHub Profile
  • GitHub Repo browser
  • Twitter feed, single quotes
  • Sitemap generators

…and a lot more. By using these widgets, and carefully skinned to look like your site, it creates a dynamic site of sorts that continually updates even it really is a static site.

I use Google Forms here on my site as an example for my Contact page. It looks and feels like I actually did something on the backend to send me an email – I didn’t.

Customizing the generated output

Almost all of these frameworks support plugins and extensions allowing for customizing the generated site to your preferences. Basically these plugins work like this.

  • Parse article/post content, usually on some plain-text form like Markdown
  • Process categories and tags
  • Redirects by creating /old-url/index.html kind of pages
  • Code highlighting
  • Pagination

And so on. Perhaps an indicator of the quality of the framework is the article/post/page parser with its extensions built into it, and how extensible it is. Take Octopress for example, it has butt load:

  • blockquote
  • code
  • date
  • GitHub gist
  • img
  • pullquote
  • video

Creating your own tag is fairly straight forward using a well documented Liquid Template parser for ruby.

Speeding up writing is key (for me at least)

I am now free to write my thoughts in any place I can write notepad. I insert things like {% blockquote %} and write a small blurb and I’m done. I’ve been wanting to switch to Markdown since I started using it with Unfuddle many many years ago, and now I can.

If this post made you think about making more sites static, drop me a line in the comments below.

~E

Leave a comment

Ting’s Drop Your Data Challenge

Ting tries to bring your mobile data into focus

"Ting Drop Your Data"

On May 5 we’re launching a “Drop your Data” contest and challenging you to use as little mobile data as you possibly can. While we want you to think about reducing your data usage, we don’t mean using your smartphone less – there are many ways to conserve data without sacrificing your mobile phone experience. Take simple steps like connecting to Wi-Fi at home and at work, downloading your favorite audio and video podcasts automatically on Wi-Fi and so on.

The contest will be set up in two, week-long intervals and will utilize Onavo Count (Android/iPhone), a nifty data reporting app. The first week, you’ll use your smartphone as you normally would, and then for the second week, work on cutting down your mobile data usage! Open to customers and non-customers alike, all participants will be entered in a random draw to win $1,000 cash or one of three $150 Ting credits!

Don’t want to use Onavo Count? That’s fine. You can use the native data counting options on your phone or another counting method. Just ensure that the screenshots you submit clearly show the time period and your mobile data use (not Wi-Fi or Wi-Fi plus mobile data) for the time period.

If you’re not currently a Ting customer, you’ll also receive service credit for your percentage of data savings from the first week to the second. In other words, if you cut your mobile data use by 74%, you’ll receive a $74 Ting credit.

"save mobile data"

Stay tuned for complete details inside this blog post on Monday, May 5.

Even though I’ve carefully been monitoring my data usage for years because I value battery life over “always connected” distractions, I’ll be entering this contest to see if I can drop it even further. Challenge accepted.

I’ve been a Ting user for nearly 1 year now, have saved over $1000 (which already paid for our new phones, canceling our contracts, and then some) and cannot live without the real-time stats and alerts they have.

I like how they invite people that are not Ting users to enter the contest as well.

~E

Leave a comment

Is Microsoft Still Building Their Own CPU?

I was going through some old posts during my import and found where I mentioned that Microsoft was to build their own CPUs for the next-gen Xbox after the 360 – nearly 8 years ago (yes, the Xbox 360 is almost 9 years old).

The Xbox One’s CPU component brings Microsoft’s architecture of choice back to x86, just like the first-generation Xbox. This time, the company kicked IBM to the curb and opted not to jump into another Intel/Nvidia love triangle. Instead, it put a ring on AMD’s finger, tapping the same source for general-purpose and graphics computing IP. At the same time, Sony was courting AMD’s semi-custom division as well. Both competitors ended up sharing a bed, but due to NDAs was never caught laying down.

Microsoft had Intel for Xbox 1st gen. Then IBM for the 2nd gen. For the 3rd gen Xbox One and PS4, we all know they went with AMD now.

So this got me thinking… Chuck Thacker is still at Microsoft. It does take a while to design and produce your CPU. I wonder if Microsoft will drop that bomb in the next decade.

It’s sad because after the Zune fiasco, with Zune software no longer compatible with the Zune players, I’m left with $600 in media players that are worthless and useless cause I can’t sync any music to them. So I don’t think I’ll ever go back to Microsoft products after that. It was one too many low blows over the last decade.

In related news, a buddy of mine sums up how the Xbox One vs PS4 has played out over the last 6 months:

~E

Leave a comment

Please Put Your Blog Under Source Control

There are many benefits to both your readers and yourself if you were to put your blog under source revisions. I would go as far to say that you own it to the community to publish all revisions of your blog that was ever public for pure archiving reasons.

Revision those files you linked to

Recently I setup my hacker’s blog and I had a need to import my old blog posts from CommunityServer. The steps were a bit hackery itself as I had to get data out of CS and into a format that one of the common importers of Jekyll/Octopress could read from. I chose BlogML to export as that seemed to have the oldest support (my CS blog was 9 years old).

Finding that old file that no one cares about any longer

After spending a few days off and on tweaking the exported BlogML data, I basically found only a single BlogML importer for Jekyll. This is why I chose this route to begin with. So, when it came time to perform the import guess what? The blogml.rb ruby script links were all broken!

Then I had a thought: if the author of the script was running Jekyll/Octopress, especially on GitHub pages, then perhaps there is a revision history.

I had to dig through about 2 years of commits; but, I found it!

Commit 30ef1570f0 for blogml.rb from author

You can even backup a folder and see his entire snapshot of his blog during the import process.

Thank you Philipp Küng for revisioning your blog.

Changing blogging platforms

What if you are switch blogging software every 5 years? Keep old snapshots and revisions of your old site in tags and refer to them in your change revisions. Even if you don’t keep the same technology, having an old copy around for public reference can be useful to the community.

Domain expiration, hosting company goes under, etc

So your domain expires or got snatched up by a squatter? Or your hosting company pulls the plug? At least having a revision available will allow you the flexibility, even if you don’t continue a blog any longer.

Updates, changes and redactions

Opinions online can be heated and made in jest. You may have published something that you wish you didn’t. Or after some nice comments are posted, you update the post. Maybe a DMCA takedown request forced you to remove a piece of content. Wouldn’t it be nice to know and show the revision history of your post?

I know that me for one is going to stop with the dozen tiny edits for spelling and grammar because of this. Who knows, it may cause me to actually think before publishing.

And FYI, you can see each revision of each post and page I make to my site here.

Backups

Similar to the above, having a full backup you can take with you can be advantageous.

Personally, I not only publish my source code here at GitHub; but, I also have an additional remote added for BitBucket and always do the following:

1
2
3
4
> git add .
> git commit -m "fixed spelling and corrected a quote"
> git push backup source
> git push origin source

Now, you can do this for any source code sure. It’s these next steps that make it viable.

1
2
3
4
> rake deploy
    ^- this publishes the live site to GitHub pages
> cd ./_deploy
> git push backup master

Yep, I also deploy a 2nd copy to my BitBucket account. Even though it will never be used as a real site, it’s a full backup of the live site in the master branch.

The Optopress command rake deploy also pushed it up to GitHub pages on master – that’s how it “publishes.” So all I have to do is make a quick backup. What’s even nice is the script does a pull request as well, to keep the _deploy folder in sync so when I do perform a backup, it’s all there. I am new to git branch tracking; so, I may have to tweak that last command by forcing -f up the push to backup if it gets out of sync or something.

Finally, having multiple copies of your repo online and publicly accessible can help with…

Government seizers

All too often, governments are taking domains and peoples’ hosting accounts in the name of DMCA and copyright infringements. Oh, and free speech as well.

Why not publish your blog open source?

The last step to further solidify your published site and source would be automate a bittorrent release for every deployment. Doesn’t seem to far out of reach with these snapshots readily available.

Death

What if you were to pass away? Would your annual payment to your domains continue for decades? What about the fee you pay your hosting company? Same as the previous reason, publishing it may very well keep it going for a long time even if the domain is gone, people can still get to the source.

Especially at a place like GitHub pages.

Why not?

I hope I sparked some food for thought and I would like your opinions on the matter.

I cannot come up with solid reasons for not to publish your blog open source. I know at first I wrestled with the idea that:

Wait, my database connection strings would be publicly visible. I can’t do that.

Then it hit me that Octopress/Jekyll is completely static – there are no database connection strings. Q

My secret keys for my 3rd party integrations may be exposed.

Actually not. Twitter, Disqus, LinkedIn and so on all use public kesy/ids to identify you with their widgets. Even Flickr allows for a vast array of public apis.

You would only need private keys on your site if you were programatically pushing or changing content elsewhere in a write-permission need. But again, this was planned as a static site – no problem here.

I have private downloads I don’t want others to see.

Ok, this one did get me. I do have private downloads of password-protected files on my old site.

I have to think back to the longevity of my blog – do I want the downloads archived forever? Short answer, no.

~E

Leave a comment

Old Pics Have Moved

If you are reading this, then I get to say this:

I moved my blog, and the photos didn’t go with it.

You can try browsing the images in my Flickr set called Blogs for the one you were looking for; but alas, I didn’t upload all photos (sorry Venna White fans).

Fret not. If you really need that photo, just use the contact button at in the header and/or footer of this site and send me the link you want the photo(s) for.

~E

Leave a comment

The Wacom Intuos3/4 Is Incompatible With the Lenovo Helix

I recently abandoned my 14 year dedication to Dell laptops in favor of the Lenovo Helix ultrabook/tablet. In doing so, I needed a stylus for the active digitizer as the one that came with the Helix just isn’t going to work for diagramming and sketching.

Research: Styluses for the Lenovo Helix

I had a problem: I was obsessed for days reading every blog, review and comment and watching every video I could find online to figure out what stylus would work with the Wacom Active Digitizer that is built into the Helix.

Sadly, I couldn’t find a straight answer.

Wacom ZP501ESE Intuos3 Special Edition Grip Pen

This is the pen I decided on. It arrived today and I immediately ripped it open only to find out it didn’t work. And yes, I removed the OEM stylus cause there is a switch that disables the digitizer when the pen is inserted to save battery.

So which one?

Now that I am armed with new search queries e.g. Lenovo Helix Intuos3 doesn’t work, I’ve found new pages with additional info that I wish I’d found in the first place.

Usually I am diligent enough to find these errors ahead of time. But, I failed this time around and I’m having fun writing on my new Octopress blog – so, why not whip up a quick post to let others know.

I found this thread that was the most helpful in figuring out which stylus to get. Specifically, this post:

FYI, the Wacom Penabled Digitizer system is not compatible with Intuos, Cintiq, and Bamboo Tablet pens.

Any other Wacom Penabled Tablet PC Pen will work (as mentioned, Series 7 slate, Asus EP121, Lenovo ThinkPad Tablet 2, Lenovo X61 - X230T series, Fujitsu T900 series, Motion F5t, Wacom Bamboo Feel pens to name just a few).

Additionally the Wacom Pen Display Pens will work (eg DTU- series).

These pens come in different shapes, sizes and button configurations, but the pen must match up with the digitizer system that is built into the tablet and many people aren’t aware that Wacom have different systems.

The Penabled system is not as advanced as the Intuos or Cintiq unfortunately (fewer pressure degrees, no tilt angles etc), but still very impressive and useful.

Well, there we have it. NewEgg, a return is coming!

~E

Leave a comment

Octopress and Posh-Git - Oh My

As announced previously, I’ve recently converted my blog over to Octopress. This was not without a few stumbling blocks on Windows using Posh-Git. I’ve also recently started to suspect some issues with Posh-Git now that I am using it on a daily basis.

In this post, I am documenting the procedure for future installs on Windows; and, maybe I can help someone else who runs across the same issues.

Ruby on Windows? No, Yari on Windows

This is my first exposure to Ruby. I know, I’ve been closed off to anything non-.NET since, well, .NET in 2002. With that the first steps to getting ruby installed. A few quick searches yielded some issues with Windows and Ruby and Octopress, until I ran across Robert Anderson’s Octopress install.

They key point to this type of installing is this golden snippet:

Use yari instead of RVM/rbenv

Scott Muc has written yari which lets you switch between Windows Ruby versions.

Once all dependencies are fixed up, it’s onto following the setup guide over at Octopress:

http://octopress.org/docs/setup/

> rake setup_github_pages

Now, I am going to use GitHub Pages for my static blog hosting. Those are the instructions I am going to focus on here and below.

The next step is to call the task to setup your repo for GitHub deployments. Just take a quick gander a what it does, as listed on the Octopress install guide:

  1. Ask for and store your Github Pages repository url.
  2. Rename the remote pointing to imathis/octopress from ‘origin’ to ‘octopress’
  3. Add your Github Pages repository as the default origin remote.
  4. Switch the active branch from master to source.
  5. Configure your blog’s url according to your repository.
  6. Setup a master branch in the _deploy directory for deployment.

If that sounds like a lot, wait until you see what actually does happen below. So, we’ll run it and look at the output:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
C:\gd\code\eduncan911 [master +2 ~1 -0 !]> rake setup_github_pages
## Set the codepage to 65001 for Windows machines
Enter the read/write url for your repository
(For example, 'git@github.com:your_username/your_username.github.io.git)
           or 'https://github.com/your_username/your_username.github.io')
Repository url: git@github.com:eduncan911/eduncan911.github.io.git
fatal: remote origin already exists.
Added remote git@github.com:eduncan911/eduncan911.github.io.git as origin
Set origin as default remote
Master branch renamed to 'source' for committing your blog source files
rm -rf _deploy
mkdir _deploy
cd _deploy
Initialized empty Git repository in C:/gd/code/eduncan911/_deploy/.git/
'My Octopress Page is coming soon
'hellip' is not recognized as an internal or external command, operable program or batch file.
[master (root-commit) f1e0e3f] Octopress init
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 index.html
fatal: remote origin already exists.
cd -

---
## Now you can deploy to git@github.com:eduncan911/eduncan911.github.io.git with `rake deploy` ##
C:\gd\code\eduncan911 [source +2 ~3 -0 !]>

Btw, kudos to the developers of Octopress to put this much output in the build processes – makes things much easier to debug than the vast majority of scripts you run.

But doh! We have our first stumbling blocks. We have a number of errors to work out here, three exactly.

Fortunately, line 7 is an extremely common problem when working git. Unfortunately though, the common fixes doesn’t seem to work with any Posh-Git install I’ve used to date.

Before we get to that though, let’s take a look at the ruby task to see exactly what is going on before we jump to any conclusions.

RakeFile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
desc "Set up _deploy folder and deploy branch for Github Pages deployment"
task :setup_github_pages, :repo do |t, args|
  if args.repo
    repo_url = args.repo
  else
    puts "Enter the read/write url for your repository"
    puts "(For example, 'git@github.com:your_username/your_username.github.io.git)"
    puts "           or 'https://github.com/your_username/your_username.github.io')"
    repo_url = get_stdin("Repository url: ")
  end
  protocol = (repo_url.match(/(^git)@/).nil?) ? 'https' : 'git'
  if protocol == 'git'
    user = repo_url.match(/:([^\/]+)/)[1]
  else
    user = repo_url.match(/github\.com\/([^\/]+)/)[1]
  end
  branch = (repo_url.match(/\/[\w-]+\.github\.(?:io|com)/).nil?) ? 'gh-pages' : 'master'
  project = (branch == 'gh-pages') ? repo_url.match(/\/([^\.]+)/)[1] : ''
  unless (`git remote -v` =~ /origin.+?octopress(?:\.git)?/).nil?
    # If octopress is still the origin remote (from cloning) rename it to octopress
    system "git remote rename origin octopress"
    if branch == 'master'
      # If this is a user/organization pages repository, add the correct origin remote
      # and checkout the source branch for committing changes to the blog source.
      system "git remote add origin #{repo_url}"
      puts "Added remote #{repo_url} as origin"
      system "git config branch.master.remote origin"
      puts "Set origin as default remote"
      system "git branch -m master source"
      puts "Master branch renamed to 'source' for committing your blog source files"
    else
      unless !public_dir.match("#{project}").nil?
        system "rake set_root_dir[#{project}]"
      end
    end
  end
  jekyll_config = IO.read('_config.yml')
  jekyll_config.sub!(/^url:.*$/, "url: #{blog_url(user, project)}")
  File.open('_config.yml', 'w') do |f|
    f.write jekyll_config
  end
  rm_rf deploy_dir
  mkdir deploy_dir
  cd "#{deploy_dir}" do
    system "git init"
    system "echo 'My Octopress Page is coming soon …' > index.html"
    system "git add ."
    system "git commit -m \"Octopress init\""
    system "git branch -m gh-pages" unless branch == 'master'
    system "git remote add origin #{repo_url}"
    rakefile = IO.read(__FILE__)
    rakefile.sub!(/deploy_branch(\s*)=(\s*)(["'])[\w-]*["']/, "deploy_branch\\1=\\2\\3#{branch}\\3")
    rakefile.sub!(/deploy_default(\s*)=(\s*)(["'])[\w-]*["']/, "deploy_default\\1=\\2\\3push\\3")
    File.open(__FILE__, 'w') do |f|
      f.write rakefile
    end
  end
  puts "\n---\n## Now you can deploy to #{repo_url} with `rake deploy` ##"
end

Let’s step through what this task does to our repo:

RakeFile
1
2
# If octopress is still the origin remote (from cloning) rename it to octopress
system "git remote rename origin octopress"

Ok, no problem. We are renaming origin. But what you don’t know is with Posh-Git, when you rename origin, it seems creates an empty origin! So, when the next system command executes:

RakeFile
1
2
3
4
if branch == 'master'
  # If this is a user/organization pages repository, add the correct origin remote
  # and checkout the source branch for committing changes to the blog source.
  system "git remote add origin #{repo_url}"

We get our first error, fatal: remote origin already exists.

Ok, back on task of what the RakeFile is doing to move forward.

RakeFile
1
2
3
4
5
6
7
8
9
10
11
  puts "Added remote #{repo_url} as origin"
  system "git config branch.master.remote origin"
  puts "Set origin as default remote"
  system "git branch -m master source"
  puts "Master branch renamed to 'source' for committing your blog source files"
else
  unless !public_dir.match("#{project}").nil?
    system "rake set_root_dir[#{project}]"
  end
end
  end

Interesting. I haven’t seen this in my git-ninja code before. A quick Google and we come up with this SO answer on how to setup master to track a remote branch:

You can do the following (assuming you are checked out on master and want to push to a remote branch master):

Set up the ‘remote’ if you don’t have it already

# git remote add origin ssh://…
Now configure master to know to track:

# git config branch.master.remote origin
# git config branch.master.merge refs/heads/master
And push:

# git push origin master

So now we have master tracking a remote branch and on line 29, we’ve renamed master to a new branch called source (which also switches us to source for future commands).

Continuing…

RakeFile
1
2
3
4
5
6
7
8
9
10
11
12
  jekyll_config = IO.read('_config.yml')
  jekyll_config.sub!(/^url:.*$/, "url: #{blog_url(user, project)}")
  File.open('_config.yml', 'w') do |f|
    f.write jekyll_config
  end
  rm_rf deploy_dir
  mkdir deploy_dir
  cd "#{deploy_dir}" do
    system "git init"
    system "echo 'My Octopress Page is coming soon …' > index.html"
    system "git add ."
    system "git commit -m \"Octopress init\""

Ah, we are create a new directory (_deploy by default Octopress config) and by calling git init we create a new bank repo! This was not clear to me as to why at first, until I got things working. You’ll see why in a bit.

And look here, on line 46, we have our 2nd error in the output. It would seem this is a parsing typo on Windows machines. So, we never get this index.html file! No biggie, we’ll be replacing that very shortly anyways.

Let’s move forward.

RakeFile
1
system "git branch -m gh-pages" unless branch == 'master'

This is my first Ruby playground, so I am not exactly sure what this line does. I would say we create a branch called gh-pages, but that is for GitHub Projects (for corporate accounts), not our GitHub Pages that we using here.

I suspect the unless branch == 'master' is what prevents this line from running on my installation.

RakeFile
1
2
3
4
5
6
7
8
9
10
system "git remote add origin #{repo_url}"
rakefile = IO.read(__FILE__)
rakefile.sub!(/deploy_branch(\s*)=(\s*)(["'])[\w-]*["']/, "deploy_branch\\1=\\2\\3#{branch}\\3")
rakefile.sub!(/deploy_default(\s*)=(\s*)(["'])[\w-]*["']/, "deploy_default\\1=\\2\\3push\\3")
File.open(__FILE__, 'w') do |f|
  f.write rakefile
end
  end
  puts "\n---\n## Now you can deploy to #{repo_url} with `rake deploy` ##"
end

Finally we are at the end. Let’s see, back on line 48 we are sitting in a new directory called _deploy with a new clean git init. So, on line 50 we add a remote for origin…

And get our 3rd and final error, that we have already seen before.

fatal: remote origin already exists

As I mentioned earlier, this is most likely because Posh-Git already creates an origin and never leaves an empty remote.

I’ve seen this fatal: remote origin already exists error all too often and it usually means you already have an origin and cannot add another one. Usually git on Linux allows you to fix with a set of simple and meaningful commands:

1
2
3
4
5
# pseudo code, not actually used during this install guide
$ git remote add temp user@my-url.com/repo.git
$ git remote rm origin
$ git remote add origin user@my-url.com/repo.git
$ git remote rm temp

But this has never worked for me using Posh-Git. When trying to remove origin with Posh-Git, you get a new and blocking error:

1
2
C:\gd\code\eduncan911 [source +2 ~3 -0 !]> git remote rm origin
error: Could not remove config section 'remote.origin'

Searching online basically leads you to a dead end in that this normally works using other versions of git. I did stumble upon a related SO question about remotes using set-url, which lead me to come up with this solution:

1
2
3
4
C:\gd\code\eduncan911 [source +2 ~3 -0 !]> git remote -v
octopress       git://github.com/imathis/octopress.git (fetch)
octopress       git://github.com/imathis/octopress.git (push)
origin

As you can see, the rake setup_github_pages has renamed our origin to octopress. But Posh-Git seemed to have created another empty origin and it won’t the script add one. Let’s fix that:

1
2
3
4
5
6
C:\gd\code\eduncan911 [source +2 ~3 -0 !]> git remote set-url --add origin git@github.com:eduncan911/eduncan911.github.io.git
C:\gd\code\eduncan911 [source +2 ~3 -0 !]> git remote -v
octopress       git://github.com/imathis/octopress.git (fetch)
octopress       git://github.com/imathis/octopress.git (push)
origin  git@github.com:eduncan911/eduncan911.github.io.git (fetch)
origin  git@github.com:eduncan911/eduncan911.github.io.git (push)

There we go. Let’s rake that setup_github_pages script again, shall we?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
C:\gd\code\eduncan911 [source +2 ~3 -0 !]> rake setup_github_pages
## Set the codepage to 65001 for Windows machines
Enter the read/write url for your repository
(For example, 'git@github.com:your_username/your_username.github.io.git)
           or 'https://github.com/your_username/your_username.github.io')
Repository url: git@github.com:eduncan911/eduncan911.github.io.git
rm -rf _deploy
mkdir _deploy
cd _deploy
Initialized empty Git repository in C:/gd/code/eduncan911/_deploy/.git/
'My Octopress Page is coming soon
'hellip' is not recognized as an internal or external command,
operable program or batch file.
[master (root-commit) 27d2dd5] Octopress init
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 index.html
fatal: remote origin already exists.
cd -

---
## Now you can deploy to git@github.com:eduncan911/eduncan911.github.io.git with `rake deploy` ##

Well crap. We still get that fatal: remote origin already exists on line 17 error after all we did!

Ah, but remember what I said earlier about a directory called _deploy? They are making a new repo and setting up the origin manually.

So, we have to set that origin ourselves again.

1
2
3
C:\gd\code\eduncan911 [source +2 ~3 -0 !]> cd .\_deploy
C:\gd\code\eduncan911\_deploy [master]> git remote -v
origin

This is just checking to see what was there and as we suspected the git remote add origin command in the task did not work.

You may also notice that when you change directories to the _deploy new repo, we are on master now of a different repo. We were previously on `source’ branch of the root repo from the previous scripts.

So let’s fix that up.

1
2
3
4
5
6
C:\gd\code\eduncan911\_deploy [master]> git remote set-url --add origin git@github.com:eduncan911/eduncan911.github.io.git
C:\gd\code\eduncan911\_deploy [master]> git remote -v
origin  git@github.com:eduncan911/eduncan911.github.io.git (fetch)
origin  git@github.com:eduncan911/eduncan911.github.io.git (push)
C:\gd\code\eduncan911\_deploy [master]> cd ..
C:\gd\code\eduncan911 [source +2 ~3 -0 !]> 

There we go. All fixed up and ready to continue. Make sure to change directories cd .. to backup to where you were before continuing.

At this point, it is not necessary to run the rake setup_github_pages again because the script continues even with errors, as we’ve seen above. The last part of the script seems to modify the RakeFile. We’ll leave that for another topic as we want to keep hacking on our new blog to get it up.

To the keen observer, you may notice that we have two branches of the same repo:

git@github.com:eduncan911/eduncan911.github.io.git
# master
# source

The first part of Octopress’ instructions for github actually branches what you cloned from Octopress’ github
into a source branch. Ok, check.

But recall that we created a sub-directory called _deploy and we git init a new clean repo there. It was
already set to master, and finally we made its origin the same as our original source.

What this means is now you will have two branches with completely different code. Your source branch is what
you will work from, commit to and push up. While the Octopress ruby framework will handle the generation of the
static site and deployments to the master branch.

The last piece to remember is that GitHub Pages will only use the master branch to serve your static site.

Sweet! Our website (aka master branch) will be nice and clean based on this _deploy directory, whereas
our source branch will be the work committed.

rake generate

This runs without issue.

rake deploy

Aw shit, it would seem we still have some issues because this task generates errors:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
C:\gd\code\eduncan911 [source +2 ~3 -0 !]> rake deploy
## Set the codepage to 65001 for Windows machines
## Deploying branch to Github Pages
## Pulling any updates from Github Pages
cd _deploy
fatal: No remote repository specified.  Please, specify either a URL or a
remote name from which new revisions should be fetched.
cd -
rm -rf _deploy/index.html

## Copying public to _deploy
cp -r public/. _deploy
cd _deploy

## Committing: Site updated at 2014-04-03 22:58:56 UTC
[master 5257cf9] Site updated at 2014-04-03 22:58:56 UTC
 61 files changed, 1118 insertions(+)
 create mode 100644 assets/jwplayer/glow/controlbar/background.png
 ...(snip)...
 create mode 100644 sitemap.xml
 create mode 100644 stylesheets/screen.css

## Pushing generated _deploy website
fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

## Github Pages deploy complete
cd -
C:\gd\code\eduncan911 [source +2 ~3 -0 !]>

We got two errors to sort out. Let’s take a look at the first one.

fatal: No remote repository specified. Please, specify either a URL or a remote name from which new revisions should be fetched.

Humm, this sounds like a git pull was issued. Let’s take a look at the ruby commands for this. Again, thanks to the great output from the developers, a quick search in the RakeFile finds this code.

RakeFile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
desc "deploy public directory to github pages"
multitask :push do
  puts "## Deploying branch to Github Pages "
  puts "## Pulling any updates from Github Pages "
  cd "#{deploy_dir}" do
    system "git pull"
  end
  (Dir["#{deploy_dir}/*"]).each { |f| rm_rf(f) }
  Rake::Task[:copydot].invoke(public_dir, deploy_dir)
  puts "\n## Copying #{public_dir} to #{deploy_dir}"
  cp_r "#{public_dir}/.", deploy_dir
  cd "#{deploy_dir}" do
    system "git add -A"
    puts "\n## Committing: Site updated at #{Time.now.utc}"
    message = "Site updated at #{Time.now.utc}"
    system "git commit -m \"#{message}\""
    puts "\n## Pushing generated #{deploy_dir} website"
    system "git push origin #{deploy_branch}"
    puts "\n## Github Pages deploy complete"
  end
end

Ah hah, there marked on lines 5 and 6 is the git pull for the _deploy directory. Smart, they are pulling down any changes you may have made manually to your static pages. For example, using GitHub’s edit file feature to edit a file directly in the browser.

I wonder why that didn’t work because as you recall, we setup the origin correctly. Let’s figure out why.

1
2
3
C:\gd\code\eduncan911 [source +2 ~3 -0 !]> cd .\_deploy
C:\gd\code\eduncan911\_deploy [master]> git remote -v
origin

Wha… We already set this before. What happened? Well, I can tell you that it is because I re-ran the rake setup_github_pages a 2nd and 3rd time. If you recall from the setup_github_pages take, it doesn’t care if you have an existing deployment directory or not – it blows out and creates it again!

So, just go add the origin again. facepalm

1
2
3
4
5
6
7
C:\gd\code\eduncan911\_deploy [master]> git remote set-url --add origin git@github.com:eduncan911/eduncan911.github.io.git
C:\gd\code\eduncan911\_deploy [master]> git remote -v
origin  git@github.com:eduncan911/eduncan911.github.io.git (fetch)
origin  git@github.com:eduncan911/eduncan911.github.io.git (push)
C:\gd\code\eduncan911\_deploy [master]> git remote -v
C:\gd\code\eduncan911\_deploy [master]> cd ..
C:\gd\code\eduncan911 [source +2 ~3 -0 !]>

Before we continue, let’s take a quick look at that second error. Scrolling down to line 18 in the same ruby task above we see a git push origin master being executed.

Because we had no origin set correctly, this would cause yet another error. We got that fixed already though with the above git remote set-url --add command.

Let’s try to deploy again now that we fixed the _deploy folder.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
C:\gd\code\eduncan911 [source +2 ~3 -0 !]> rake deploy
## Set the codepage to 65001 for Windows machines
## Deploying branch to Github Pages
## Pulling any updates from Github Pages
cd _deploy
Warning: Permanently added 'github.com,192.30.252.131' (RSA) to the list of known hosts.
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master

cd -
rm -rf _deploy/assets
rm -rf _deploy/atom.xml
rm -rf _deploy/blog
rm -rf _deploy/favicon.png
rm -rf _deploy/images
rm -rf _deploy/index.html
rm -rf _deploy/javascripts
rm -rf _deploy/robots.txt
rm -rf _deploy/sitemap.xml
rm -rf _deploy/stylesheets

## Copying public to _deploy
cp -r public/. _deploy
cd _deploy

## Committing: Site updated at 2014-04-03 23:21:58 UTC
# On branch master
nothing to commit, working directory clean

## Pushing generated _deploy website
Warning: Permanently added 'github.com,192.30.252.131' (RSA) to the list of known hosts.
Counting objects: 79, done.
Delta compression using up to 12 threads.
Compressing objects: 100% (72/72), done.
Writing objects: 100% (79/79), 186.45 KiB | 0 bytes/s, done.
Total 79 (delta 1), reused 0 (delta 0)
To git@github.com:eduncan911/eduncan911.github.io.git
 * [new branch]      master -> master

## Github Pages deploy complete
cd -
C:\gd\code\eduncan911 [source +2 ~3 -0 !]>

Humm, a few warnings about no tracking information for the remote branch, which we renamed to be source from master if you recall from earlier. I think this is normal because we haven’t pushed source up yet.

git push origin source

Now, let’s see if we can fix the tracking information for our source branch by pushing our changes up.

1
2
3
git add .
git commit -m 'initial commit of source branch'
git push origin source

Seems like we are good here.

Let’s head over to our GitHub Page and see what’s there in the repo. What’s this? My master is a nice and clean static site? Sweet!

github.com/eduncan911/eduncan911.github.io/tree/master

And lookie here, the source branch has the source!

github.com/eduncan911/eduncan911.github.io/tree/source

I’m sticking a fork in her and calling it… These may be normal warnings with the way the remote tracking is handled as I don’t have a lot of experience with that part of git.

It’s all downhill from here

If you have stuck with me this long, I have some good news – you’re done! Time to start blogging!

You can read the rest of the deployment guide from here as they have some useful tips. Also, make sure to commit your work (they mention this too).

My last piece of advice after you get the hang of things and create a few test posts is to look into these commands.

1
2
3
rake generate   # Generates posts and pages into the public directory
rake watch      # Watches source/ and sass/ for changes and regenerates
rake preview    # Watches, and mounts a webserver at http://localhost:4000

You’ve already run rake generate; but, take a look at the other two.

rake watch is nice to auto-generate files as you change them.

rake preview is even better! It will watch for and auto-generate your site; but, more so it runs a very lightweight tiny webserver (much less tiny than IIS!) in the background where you can open a browser and hit refresh to your heart’s content.

I advise everyone to do that to keep the number of commits down because once you have a few 100 pages, that generate and deploy is going to take a long while. Might as well get into the habit early!

~E

PS: I am thinking of renting a Macbook Pro because of the time lost with stuff like this under Windows. Argh…

Leave a comment

My Hackers’ Blog

Three years, 11 months and 22 days… That’s how long it has been since my last blog post.

When I originally launched this blog, I was using the software I originally wrote for CommunityServer back in 2004 and 2005. Ever since then I have dreamed of grand visions of new blogging software. Tinkering with new design patterns, following Ken Robertson’s advice of trying out new frameworks with the concept of an Hello Blog, where you create a blog using whatever language you want. While that was all said and good, I never got around to finishing any of them good enough to launch them live.

Enter Octopress: A blogging framework for hackers

For those that haven’t heard about it, go read about it. In short, it uses Ruby to create a static blog for you to upload anywhere. Yes, just raw .html files and css/js/image files. And, that’s about it.

1
2
git clone git://github.com/imathis/octopress.git octopress
cd octopress

You write your posts in MarkDown, and be done with it. There are all sorts of little hacks shortcuts when writing posts that I am going to have a lot of fun with.

1
2
rake preview
# now open browser to eduncan911.local:4000/

When you go completely static, interesting opportunities start to emerge… You no longer need a “web host” – all you need is a place to dump your files online somewhere.

1
rake deploy

Enter GitHub Pages

GitHub allows you to host static pages in a public repo. I’ve been hosting my code.eduncan911.com there for years.

A few Google searches revealed I wasn’t the only one who thought this way. If I create a static blog, I can just host it at GitHub. At first I stumbled upon Jekyll which gives you full control over markup, css, etc. But here I was in the same position – writing code. I found that Octopress is built upon Jekyll; but, it already has a default theme, css, plugins, etc.

The best part is they have step-by-step instructions on how to publish it straight to GitHub Pages. It really can’t get any easier than this, for any hacker skill level.

1
2
3
git add --all
git commit -m "new post: My Hacker Blog"
git push origin source

That’s right, this blog is hosted at eduncan911.github.io. They have instructions on setting up a CNAME (in my case though, an ALIAS for the root eduncan911.com domain) and that’s it, you’re live.

As a matter of fact, go browse my site just like the old “directory browsing” method. If you want to see the source code in how I generate the site, switch branches to source to check that out. Tip: most of that is Octopress. Drill into the /source/ directory to see the raw nit-n-gritty fun stuff.

I will admit though, it took some tinkering to get Octopress setup and working correctly on Windows with PoshGit and PowerShell.

The way forward

There are a number of plug-ins, and there is some work I want to do to the asides (right column). But I am liberated to no longer wait, and just do.

Most of all, being just raw MarkDown, I can write from any device now: tablets, smart phones, anywhere. And, being on GitHub, I can just browse to my source branch and create a new file to start blogging. There are instructions for a C.I. server to take callbacks from GitHub, and to publish it on the site after commits. Yep, very fun stuff…

~E

Leave a comment