Friday, December 30, 2011

Screenshot with Android powered device

As I own beautiful Samsung Galaxy Nexus, I'm sometimes willing to make some screenshot to blog, show a friend or send bug report to developers etc.
Galaxy Nexus has Android 4.0 (Ice Cream Sandwich) on board so I don't know how it is in older versions.

To make a sreenshot: hold Volume Down + Power buttons by about 2 seconds. After than the information about the screenshot should appear on your device.

Below is the screenshot of this post.

Tuesday, December 20, 2011

Page Speed

Page Speed is an open-source project started at Google to help developers optimize their web pages by applying web performance best practices. Page Speed started as an open-source browser extension, and is now deployed in third-party products such as Webpagetest.orgShow Slow and Google Webmaster Tools.
So if you want to try Page Speed go: http://code.google.com/intl/pl/speed/page-speed/

Tuesday, November 8, 2011

Next great tool from Google to you

Address Sanitizer (aka ASan)
http://code.google.com/p/address-sanitizer/

Address Sanitizer is a memory error detector for C/C++. It finds:
I hope to extend this note with some examples.

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
http://paste.pocoo.org/
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:
http://en.wikipedia.org/wiki/Comparison_of_pastebins

Thursday, September 22, 2011

Testing tools

I found another great testing tool:
http://code.google.com/p/googlemock/
It allows me to mock-up entire class.

The other one, previously used by me is:
http://code.google.com/p/googletest/
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:
http://gcc.gnu.org/onlinedocs/gcc/Gcov.html
To display the results in human-friendly format we can use:
http://ltp.sourceforge.net/coverage/lcov.php

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.

Original

Code highlighting on Blogger found on http://heisencoder.net/2009/01/adding-syntax-highlighting-to-blogger.html.
#include<iostream>

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

Edit:
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.
Edit2:
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/';
    SyntaxHighlighter.autoloader(
      '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;
    SyntaxHighlighter.all();
    </script>
    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">
    #include<iostream>
    
    int main() {
      std::cout << "Hello world!\n";
      return 0;
    }
    </pre>
    

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