Tuesday, September 27, 2011

Pasting tools

Edit: Right now(December 2013) Lodge It is down and I'm using https://gist.github.com/ which has awesome syntax highlighting and allows to edit files and fork snippets.

Today I needed to send 5 LOC (lines of code) to my colleague to discuss some solution. This is that type of changes you don't want to just "commit", rather to discuss to omit later refactoring. So I made that silly thing and paste it to chat window. But after that that start to looking for some internal solution for such situation. Of course, I found one, but after that I started to looking on the Internet. This is a short list what interesting I found.

Lodge It
I really liked that tool. It has some cool features:

  • paste reply's
  • history log
  • reply notification
You can find more on: http://paste.pocoo.org/about/. Support for vim and command line is also cool.
But what is the most important: clean and easy interface.
What is also interesting, project is open source, so you can download and modify, and host yourself.

And the last thing if you look for a perfect solution for yourself:

Thursday, September 22, 2011

Testing tools

I found another great testing tool:
It allows me to mock-up entire class.

The other one, previously used by me is:
Which is just a unit test framework.
The team of this two can really make the life of developer much simpler as it allows to test code functionality every time he mess a lot. Bugs cannot feel safe from now.

And if we are using unit tests and some more generic system tests at some points we probably start to care about the test coverage. We want to know which functionalities are tested and what is percentage coverage of source by tests. In C++ we can accomplish this by:
To display the results in human-friendly format we can use:

Wednesday, September 21, 2011

C++ Profiling

I am writing program for ai-contest right now and noticed that for some reasons and initial conditions my program is working slower and slower. I don't want to change algorithms or design as it is quite well written. So I decided to find bottlenecks of my bot. Here is how I started.

List of C++ profilers:
Both of them are open source. I especially liked the second one.

To be continued.

Blogger customization - syntax highlighting

Edit: As December 2013, I'm trying to migrate all posts to: http://google-code-prettify.googlecode.com/ It's easy to use and actively develop.


Code highlighting on Blogger found on http://heisencoder.net/2009/01/adding-syntax-highlighting-to-blogger.html.

int main() {
  return 0;
Html escaper: http://www.accessify.com/tools-and-wizards/developer-tools/quick-escape/default.php

It looks that added syntax highlighting library is little bit outdated. I will need to change links to new one or create own Google code project with latest version.
As there is no exact newest Blogger and SyntaxHighlighter installation tutorial on the Internet, try to follow this steps (Quick&Dirty tutorial):

  1. Just to note: SyntaxHighlighter version 3.0.83, Blogger as for a date: September 22nd, 2011.
  2. Go to Blogger administration panel, choose "Template" from menu on the left, click "Edit HTML" button. Confirm by clicking "Proceed".
  3. Find </head> closing tag. And just before paste code below:
    <link href='http://syntax-highlighter-snapshot.googlecode.com/git/dist/3.0.83/styles/shCore.css' rel='stylesheet' type='text/css'/>
    <link href='http://syntax-highlighter-snapshot.googlecode.com/git/dist/3.0.83/styles/shThemeDefault.css' rel='stylesheet' type='text/css'/>
    <script src='http://syntax-highlighter-snapshot.googlecode.com/git/dist/3.0.83/scripts/shCore.js' type='text/javascript'/>
    <script src='http://syntax-highlighter-snapshot.googlecode.com/git/dist/3.0.83/scripts/shAutoloader.js' type='text/javascript'/>
  4. Find </body> and just before paste:
    <script type='text/javascript'>
    var base_url = 'http://syntax-highlighter-snapshot.googlecode.com/git/dist/3.0.83/scripts/';
      'cpp '+base_url+'shBrushCpp.js',
      'html xml '+base_url+'shBrushXml.js',
      'css '+base_url+'shBrushCss.js',
      'js '+base_url+'shBrushJScript.js',
      'py '+base_url+'shBrushPython.js',
      'sql '+base_url+'shBrushSql.js',
      'bash '+base_url+'shBrushBash.js');
    SyntaxHighlighter.config.bloggerMode = true;
    Feel free to change base_url if you can host files yourself. I don't so I uploaded code to Google Code Hosting. You can use author hosting, but hey, he's paying for that, so use Google ;-)
  5. Click "Save template" and "Close". Now you have you syntax highlighting ready for C++, HTML, XML, JavaScript, Python, SQL and Bash.
    Try to put some C++ code on your blogger. You need to switch to "HTML" editing mode to do this.
    <pre class="prettyprint lang-cpp">
    int main() {
      std::cout << "Hello world!\n";
      return 0;

    For more information go: http://alexgorbatchev.com/SyntaxHighlighter/, and don't forget to buy a beer for creator ;-)