Category Archives: opensource

setting up vim on windows

So you want to make the plunge and check out what that awesome Vim editor is all about on a Windows machine? I did about a year ago, and this time I actually stuck with it. I tried it 2 times before already, but I gave up every time after a few hours or days because of the steep learning curve and the fact that nothing seemed to work the way I’m used to.

The goal here is to get Vim set up on a Windows box, make it work like a Windows app and make it look like something you aren’t afraid of being seen with (that default layout, euhm, seriously…).

installing Vim on Windows

The easiest way to install gVim (the non-console version) on Windows is by using the Vim Chocolatey package. It installs the Cream Windows flavored Vim for you from Sourceforge and sets up your system path so you can run “vim” and “gvim” to start the editor from the command line if you want to.

Chocolatey itself is like apt-get for Windows. It’s a NuGet based software package manager and if you’re a software developer or have to install systems a lot, I’m sure you’ll love it.

To install using Chocolatey, type this from a command shell (run in administrator mode):

    choco install vim

Easy isn’t it?
If you really don’t want to setup Chocolatey (but you should really) you can also get the Windows binaries from vim.org, or the Cream ones. You’ll get the Cream editor with that based on Vim, but I didn’t want that cause it’s not quite pure Vim anymore (not modal for example).

first steps

Before you start configuring Vim you should start with getting to know it. Whatever comes next will be a lot easier once you know how to move around, save files etc. You know, those typical things you do in a text editor anyway.
So basically you have to RTFM. Or at least, the short version of it.

Find the Vim tutor in your start menu and run it. Once you’ve completed that, you know enough to get around in Vim and find out how to get help for other stuff. Also, don’t bother with doing it the hardcore way. Just learn Vim at your own pace, use the cursor keys and the mouse if you want. You’ll pick up more advanced stuff as you go along.
Just like this guy said.

configuring Vim

Vim uses vimrc configuration files to store settings. There is a default vimrc file in your Vim installation folder, but you shouldn’t touch that one because it can be overwritten when you install a Vim update. Your own settings go into a new _vimrc file containing only the things you want. You can “source” or include other vimrc files, to avoid duplication or organize your configuration.

On a Windows machine this goes into your user folder (c:\users\username\_vimrc).

To see and edit your current vimrc (the one use by vim when it starts) type:

    :edit $MYVIMRC

Once you’ve created your own config file, the above command will automatically open it. So let’s do just that, like this. “e” is short for “edit” btw:

    :e ~\_vimrc

That tilde character (~) stands for the path to you home folder, which on Windows is normally set to c:\users\<username>.

On Windows the folder  ~\vimfiles is used to store custom plugins. I put my vimrc in ~\vimfiles and source it from the ~\_vimrc file. That way I easily sync my whole setup to another machine by simply copying the whole vimfiles folder. So my ~\vimrc file contains only this line.

source ~\vimfiles\nj-vimrc.vim

You can keep everything in _vimrc of course if you want.

You can test Vim statements from the command bar before you put them in your vimrc file. A handy way to test and see if it really does what you want it to without having to restart Vim and reload your configuration.

making Vim behave like a Windows editor

If you install the Windows gVim version this will normally be setup in your vimrc configuration file automatically, but it’s always handy to know what settings are making the magic happen.
Vim doesn’t use the typical Windows key binding like CTRL-S to save, CTRL-C,V,X to copy, paste and cut. As a hardcore Windows user you expect these to work for all applications, no matter how geeky they are. If you check out the original vimrc in the Vim installation folder you’ll see the same statements as below.
You can copy these into your own vimrc file.

" Activate all the handy Windows key-bindings we're used to.
source $VIMRUNTIME/mswin.vim

behave mswin

Or you can source the original config in yours:

source $VIM/_vimrc

Now your Vim should (still) behave pretty much like a regular Windows editor, making things a lot easier to use it for all your basic editing.

making it look good

gvim_fugly

Man, it does look ugly doesn’t it? All white and with that terrible font? Now let’s make it look pretty so you don’t have to be ashamed of all those hipsters sporting their fancy Sublime.

This depends on your personal preference of course, but I like it when my editor doesn’t look like it’s from the 80’s. I pasted some of my esthetic config changes below. Each has some comments on it explaining what they do. Use the help feature (:h ) if you want to find out more, and remember to only put things in your vimrc that you understand.

" Display line and column number in bottom ruler.
set ruler

" Display the line numbers.
set number

" Activate syntax highlighting.
syntax enable

" Set a nice theme.
color slate

Check out all the themes you have installed by using CTRL-D (auto-complete) after you typed in :color on the command bar.

if has("gui_running")
  " Set a nicer font.
  set guifont=Consolas:h11:cDEFAULT
  " Hide the toolbar.
  set guioptions-=T
endif

gvim looking pretty

You can exclude hiding the toolbar, but I just find it ugly and never use those buttons anyway. This is very minimal, and there are plenty of other themes and plugins available to change Vim’s appearance, but that’ll be for another post. For more vim customization tips, check out what I have in my _vimrc file.

Hopefully this gets you going in the wonderful world of the Vim editor on Windows. Just keep at it I’d say and feel free to drop any questions or remarks in the comments.

Edit: replaced the KicksassVim Chocolatey package with the Vim one because the first doesn’t seem to be updated any longer.

cool geek (dev) stuff I ran into lately

... "Mr. Droopy Eyes!"

I’ve had this list around for a while and though that most people would probably have heard of this by now so I didn’t see the point in posting about it.
Until last weekend someone on twitter was happy to find out about Chocolatey. So I guess not everybody knows these little gems yet, hence this blog post!

  • Chocolatey: a Windows packages manager of sorts. A bit like apt-get on Debian. It allows you to install a bunch of Windows software and tools from the command line. It’s pretty cool and is super handy to get a (developer) box up and running in no time. It’s also handy to keep your installed package up-to-date with the “cup all” statement. Sweet.
    There’s lot’s of good stuff in the gallery already, so you’ll probably find your favorite tool in there. If not, you can add it yourself because it’s built on the NuGet package manager system, or browse what’s available and find some new gems you didn’t know about yet.
  • I haven’t really used Boxstarter myself yet, but if you’re planning on using Chocolatey for some serious VM Windows installer magic, it might come in handy. It builds on top of Chocolatey and allows 100% uninterrupted Windows installs. Thought it was worth mentioning.
  • ScriptCS: one of Glenn Block & co little open source coding adventures. He thought it would be cool to use C# and the .NET framework to run scripts on Windows using the Roslyn compiler API. No need for Visual Studio, project files, compilers or anything like that. Just the scriptcs executable and a text file with your C# script code. Much like Node.js or Python for example. You know, scripting languages.
    Turns out this idea took off like a rocket in the community and has all sorts of cool features by now, like Nuget integration and script packs for reusability. It’s awesome.
  • dotnetfiddle.net : It’s jsfiddle for C# code. It’s a web site where you can type some C# code in a console application, run it and see your output instantly. Great of small bits of test code. It even has intellisense support so it’s easier if to use than LinqPad for this kind of tests apps if you don’t know all the statements by heart.
  • devdocs.io: all web dev docs in one place and easily searchable. Contains docs for thing like the HTML5 spec, JS, HTTP, HTML DOM and the most popular frameworks like Ember, Backbone, Angular, Knockout and Underscore. Also language like Python, Node, Ruby etc. In short, useful stuff for any web developer working with a modern stack.

Image by James Vaughan, cc-licensed.

how to protect your privacy online

Who Are You Looking At?

With the whole NSA PRISM storm blowing over the internet I thought it would be nice to compile a list of free and open source software I know that can help in safeguarding your privacy as an alternative to proprietary software or online cloud services which are not to be trusted with your personal data.

Hosting everything yourself is one way to go like the folks at unhosted.org suggest, but it isn’t free as it will a) cost you some money and b) usually quite some time to set everything up. Not everyone has the technical knowledge to do this either, so a list of open source software and trustworthy services for the masses would be great.

Turns out prism-break.org is just that kind of list, so that saves me the trouble of compiling it myself. Nice. Here’s another one with mostly the same items on it. Mostly.

Photo by Caneles, cc-licensed.

windows rescue kit on a usb stick

Attempt Repair Install

While cleaning up an old machine I was first using CCleaner from Windows to wipe some partitions because DBAN crashed for some reason on it. To clean some of the Linux partitions on the drive which Windows can’t access, I dropped them so I could re-add them as NTFS partitions for further wiping. Problem was I forgot those partitions where also hosting my master boot record, so when I rebooted to confirm my partition changes… I ended up with a unbootable system.

Oops.

Now I had to find a way to wipe those disks from Linux, but first I still wanted to get access to my WinXP setup. I could have just nuked it from orbit (read: boot from a Linux Live CD and shred it) but I was just wondering if I would manage to get it to boot again, just in case I do this on a system that really matters some day. So I started browsing to the ISO’s available on the Universal USB Boot installer and ran into the awesome Trinity Rescue Kit.

I installed it on a very small USB drive (265MB) I had lying around and managed to rewrite me a Windows boot record with the tools supplied from the text-based menu. Nice! I also noticed that it has a bunch of disk rescue tools on board like a backup tool, full NTFS support, the Midnight Commander explorer for file recovery and a Windows password reset tool (hackedy-hack). On top of that it also has a virus scanner on board, ways to set up network file shares and good, detailed documentation.

This distro is certainly one that is getting a nice spot on my PC CPR tool belt. Without exploring all the goodness Trinity has to offer I’m sure it’s a huge time saver if you need to help out with a unbootable system or one seriously infected with trojans or virii. You can even use this to set up a headless file share server in no time if you want.

Good stuff.

Photo by lilbambi01, cc-licensed.

google reader replacement for geeks

Newspaper dog thinking RSS

Google Reader is quitting on us and there doesn’t seem to be an alternative if you don’t want something that tries to make your feeds look all fancy and shiny eye-candy-ish like Feedly or most of the alternatives I saw.

The things I loved in Google Reader are:

1. Accessible from anywhere (which means web-based basically), so desktop based RSS readers didn’t cut it.
2. I can use it from my Android phone, either with an app or straight from the website.
3. I can skim feeds quickly and star or tag articles I want to read later.
4. The read-later articles need to be imported into Instapaper, using something like IFTT.

I started looking at some open source solutions because I didn’t want to end up getting shut down again. In the least the services needed to allow me to import & export feeds easily in case it does bail out.

I noticed a few open source applications running on PHP that are interesting but only one of them is still actively developed and has a decent user base. So Tiny Tiny RSS is what I ended up testing out.
It’s pretty close to Google Reader (which makes sense because it’s an RSS aggregator and reader after all) but it isn’t pretending to become it, or implement every GR features. It’s sailing its own course, but since it’s pretty damn close I thought I’d give it a shot.

So here comes the geeky bit:

Since this is a web app and not a web service, you have to host it yourself.
So this means getting the code, uploading it to your server, setting up the database and configuring it.

If that didn’t scare you off, all of this is nicely explained in this lifehacker post and on the TT-RSS installation notes. So you’re pretty safe there. Recently the software was updated to enable it to run on a shared hosting server, so you can basically run it anywhere from now on.
If I wouldn’t have my own hosting I’d try to get it running on a NearlyFreeSpeech site to try it out for cheaps. You can set up a PHP site quick and cheap over there if you have the know-how.

There’s and Android application on the market you can try for 7 days for free to connect to your instance of Tiny Tiny RSS (after you open up the API settings in the configuration) and it works great. It costs only a few bucks so I figured I was willing to pay that to the author of this fine piece of work that’s available to the world for free after all.

It also supports starring and tagging posts, and it allows you to expose your starred items as an RSS feed so you can pull that into IFTT for syncing with Instapaper.

There you have it. All requirements are met with free software (except the Android app bit) and a bit of geeky work on your part to get things set up and running. So far things are running great and I didn’t run into any issues yet.
You can set this up for multiple users, so if you have friends that are also orphaned by Google Reader you can share your instance with them.

Photo by stylianosm, cc-licensed.

securely wiping your hard drive without dban

Technologic

Well if DBAN doesn’t cut it for some reason there’s always a more native Linux way to do this.

Step one is getting a Linux live CD, DVD or USB stick and boot from that. I used the Debian Live CD myself, which boots into character mode so you don’t end up with XServer not getting your video settings right.

Once you’re in a shell, you can use the shred command to wipe your HD’s data by overwriting it a number of times with random data. I found that out by reading a post by a lad named Jason on the topic which was a nice help. I only had to add the “sudo” call in front of the command to actually allow it to get write access to the disk on Debian.

First figure out what partition/drive you want to wipe by running:

cat /proc/partitions

Then, in my case, I had to run this to wipe sda:

sudo shred -fvz -n 6 /dev/sda

The -fvz basically means, [f]orce write permissions, [v]erbose output so you can see the wiping progress and write [z]ero’s on the last run to hide the wiping. -n 6 tells it to do 6 runs of random data writing.

Using DBAN is still the easier way to get this done, but if that’s causing you trouble you can use this as a backup wiping measure.

Photo by Hugo Chinaglia, cc-licensed.

donating bandwidth to open source

Skogafoss waterfall, iceland

If you’re like me and you have a big fat internet pipe entering your home then you probably have a lot of unused upload bandwidth at the end of the month. In fact, if you have one of those flat-rate unlimited bandwidth kind of packages which you lucky foreigners seem to have in abundance, then you have (in theory) a lot of unused bandwidth… always.

So how about using some of those gigs for a good cause? How about seeding some awesome and freely available open source software and content so others can get faster access to it. That wat you save the lads hosting those big ISOs from their servers some bucks by taking the load off their upload stream.

The solution is simple, boot up your favorite torrent client (uTorrent for example) get a few torrented downloads for the open source causes you feel like contributing to and seed away!

Good stuff to give bandwidth to are:

  • The Ubuntu Linux operating system. Seed the iso’s of the latest version.
  • Other free OS’s such as Debian, Suse, FreeBSD or whatever flavour you fancy.
  • Google’s Project Gutenberg, sharing a  DVD worth of free and open ebooks. It feels good to share a library of content from your machine, trust me. Also great to browse through yourself btw.
  • The free content (cc-licensed mostly) from clear-bits. Pick some stuff you want to check out yourself, music, video’s, games, anything and just remember to keep that torrent up for seeding. You won’t have a lot of downloads on these usually as they are only fetched sporadically, but keeping the seed up is like giving the other a thumbs up if you like his stuff.
  • Recently archive.org also put up a lot of its content in torrent form.

Be sure to check back on those OS releases now and then so you don’t end up seeding a dusty old version, but other than that, your torrent client is giving back without you having to do any effort. How sweet is that?

Photo by Massimo Margagnoni, cc-licensed.