2009
07.13

I’ve just ported InfiniteRed’s IR_black color scheme that I use in vim to highlight.js. And now I am the first ever person using it in the blog :) Here you can see some ruby code highlighting and there goes some JavaScript. I’ve also tested it with CSS (looks just fine, trust me). Haven’t tested with any other languages (sorry).
Get it here and please tell me about any glitches or ugliness with it.

2009
07.13

I should say I like vim very much. It’s extremely configurable, has a lot of useful plugins. It’s also cross-platform and available in almost all modern UNIX distributions which means that it’s equally accessible from the very beginning on a Mac OS X powered MacPro and a humble low-end garage server (running Linux, of course :) ).

While there is a number of GUI versions of vim (gVim, MacVim), I personally use the console version. The main reason for that is that I often ssh to remote servers (including my office computer when at home) – and use vim on-the-spot.
Console vim on OS X

Customizability is what makes vim much more than just a text editor.
Customizing vim includes:

  1. Grabbing a nice color scheme
  2. Getting some plugins that would simplify your everyday work
  3. Binding of commonly used keys
  4. Realizing your desired functionality in vimscript

My preferred color scheme is IR_Black. In order to be able to use it in Terminal vim, you will also need the corresponding Terminal color scheme. Todd Werth describes the installation process.
While the TextMate users are enjoying the beautiful color schemes, vim people are porting them. Among the ports are the Zenburn color scheme, VibrantInk and Twilight.

If you are a fan of pixel fonts, Terminus is a good font that is both crisp and easy on eyes. If you are not, then may be the excellent Monaco font is your friend.

The plugins that are featured in the screenshot include NERD Tree and MiniBufExplorer. The others that I also use and recommend are NERD Commenter and vim-git-branch-info.

Vim.org includes thousands of plugins, including a great Rails plugin, project plugin, code browser and much more.

Damian Conway has recently published a tutorial on vimscript on the IBM developerWorks portal, so check it out if you want to become a power user of vim (Part 1, Part 2).

Bram Moolenar, vim author, has made a speech concerning effective text editing with vim.

If you are new to vim, feel free to check out my .vimrc on github and modify it to your needs.

2009
07.10

Some of you may be running into the same problem while trying to compile ruby 1.9 on OS X with iPhone SDK installed:

ld: in /usr/local/lib/libstdc++.6.dylib, file is not of required architecture
collect2: ld returned 1 exit status
make[1]: *** [.ext/i386-darwin9.6.0/enc/encdb.bundle] Error 1

This odd error is produced by iPhone SDK, which installs ARM libraries in /usr/local/lib.
You can easily work this around by specifying proper LDFLAGS for make:

$ make LDFLAGS="-L. -L/usr/lib"
2009
05.11

This should work in any UNIX distribution having libtiff and imagemagick installed.
My friend gave me a pack of high-res scanned images, almost 300 Mb in size.
I wanted to make them smaller and to combine them into one pdf.

That’s what I came up with (after some research):

$ find . -name "*.JPG" -exec convert -format TIFF -resize 33% -quality 100 {} {}.TIFF \;
$ tiffcp *.TIFF big.TIFF
$ tiff2pdf -o big.pdf big.TIFF
2009
04.30

Ok, so I guess it’s time now for the first almost non-technical post in this blog.
I should say that I’ve always been very excited about the idea of netbooks, these full-featured laptop computers that are light and small enough to carry them everywhere you go.

Being a geek, I see a tremendous amount of use cases for such devices. If I had a netbook (and I’m thinking about getting HP Mini 2410), I would use it as a satellite machine, that would contain clones of my actual projects and documents (git clones, i guess :) ) – so that would allow me to realize some bright ideas on the move. Or in the places, where my desktop computer (actually, a 17” MacBook Pro) would be impractical to take. Yes, desktop, because this awesome laptop is way too hige and heavy, though I completely adore it for numerous reasons ;)

Today computer-related mass media keeps discussing the possibility of a MacBookMini release. I am pretty sure that Apple will release such kind of device and I’m also sure that it will be very unlike most current netbooks.

Read More >>

2009
03.05

If you (like me) use Mac OS X for your ruby development, you might need to install the RMagick gem. ImageMagick is the essential tool when it comes to automated image processing and RMagick is a nice ruby wrapper for it. The only problem is that ImageMagick has a lot of dependencies which involve numerous libraries needing to be built (or installed) alongside with it.

Of course you might use MacPorts or Fink for the installation, but if you don’t really need these massive-impressive tools, here is a simple solution to get Rmagick installed fast. Download this tar archive, unpack it with tar xvf, cd to the getRMagick folder and launch the getRMagick.sh script. Please note that you should have Developer Tools installed on your Mac (usually available on the OS X installation DVD) as well as ruby + rubygems in order for the script to compile everything for you. After a while, if everything goes well, you’ll get the Magick stuff installed. I used the script on Intel and PowerPC Macs with OS X 10.5.6.
And yeah, the script is very simple.

Read More >>

2008
08.08

We wanted our Google Analytics charts to be displayed in one of the sections of Inshaker. GA is an excellent service for complex auditorium analysis. Unfortunately, it has no public API (though, I think it will be available in future). Fortunately, it is able to export reports to several formats, including XML.
There are several existing tools for drawing charts on-the fly. Among them are the excellent flash-based amCharts and url-based Google Charts. I chose amCharts because they are more nice-looking and interactive. AmCharts rely on their own XML data files, which have rather straightforward formats.

Read More >>

2008
08.06

Why use server-side data storage, if you don’t do any data processing on server? There are many cases when you’d rather keep your data structures on the client side. In Inshaker, we had to manipulate and persist large amounts of user-specific data on the client side. Cookies were not an option because of the 4kb limit. So we used the persistency library by Ilya Kantor with slight modifications. It makes use of window.globalStorage object in Mozilla, userData behavior in MSIE and Flash storage in other cases (we will be implementing Safari sqlite storage too). All three mechanisms are different: flash storage is loaded asynchronously and userData values can’t be accessed in other paths (i.e. /page.html and /dir/otherpage.html won’t be sharing the same data). That’s why we use a “proxy” page, which is loaded in an iframe. The data we persist is “attached” to an element in this page.

Usage is rather simple:


	// needs callback because it's asynchronous in case of flash
	Storage.init(function(){
		Storage.put("js", "cool language");
		var desc = Storage.get("js");
		Storage.remove("js");
		Storage.put("objc", "pretty too");
		alert(Storage.get("objc"));
		Storage.clear();
	});

Read More >>

2008
08.05

Так сложилось, что в России небольшой процент пользоваталей компьютеров Apple. А программистов, создающих desktop-приложения для Mac OS X, и того меньше. Однако с распространением iPhone, а особенно с появлением iPhone SDK интерес к программированию под iPhoneOS, несущей в себе компоненты Mac OS X и Darwin, в нашей стране возрос.

В настоящее время единственным языком, поддерживаемым iPhone SDK, является Objective-C. Не лишенный обаяния, он впитал в себя черты C и Smalltalk. Всем, кому он любопытен, советую обратить внимание на замечательный ресурс “Программирование на Python и Objective-C в Mac OS” Evgeniy’a Krysanov’a и статью “Язык программирования Objective-C” Алексея Борескова.

2008
08.05

For Inshaker, we needed a templating mechanism for pages sharing the same design. We also wanted the pages to be static (for performance reasons). We did not need them to be generated on-the-fly.
ERB was an ideal option for such a purpose. It allows us to generate all (75+) static pages when we need to make an update.
It is also very simple in terms of use:

1. You create a template for your page (template.rhtml)


<html>
<head>
	<title><%= @title %></title>
</head>
<body>
	This page was generated by <%= @name %> on <%= Time.now.to_s %>.
	<ul>
	<% @tags.each do |tag| %>
	<li><%= tag %></li>
	<% end %>
	</ul>
</body>
</html>

2. You create a ruby class which is bound to the template and run erb (erb_test.rb)


require 'rubygems'
require 'erb'

class MyPage
  def initialize(hash)
    @title = hash[:title] + " - that's what I mean"
    @name = hash[:name]
    @tags = hash[:tags]
  end

  def get_binding
    binding
  end
end

# Instantiate ERB with the instance of that class and flush the output
template = File.open("template.rhtml").read
renderer = ERB.new(template)
page     = MyPage.new({:title => "ERB rules",
                       :name => "Ninja",
                       :tags => ["ruby", "erb", "html", "example"]})

File.open("mypage.html", "w+") { |html|
    html.write renderer.result(page.get_binding)
}

Of course, this is just a basic usage example. ERB shows its power when there are A LOT of pages to be generated, not a single one ;-)
I should have a closer look at SproutCore since they seem to be using the same principle for views compilation.