Thoughts and tips for a daily coding life

2013/10/05

Disabling Clang warning

October 05, 2013 Posted by Antanas Domarkas No comments
If you have a line where you are sure warning is not needed and want to disable it, use this pragma:

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmultichar"

char b = 'df'; // no warning.

#pragma clang diagnostic pop

2013/10/04

Improving cout performance

October 04, 2013 Posted by Antanas Domarkas , , No comments
If cout performs badly and there are no calls to printf, you can turn off iostream syncing with stdio
ios::sync_with_stdio(false);

Also replace ::endl calls with '\n'. So you are not flushing with every line.
// BAD
std::cout << "This is my line" << std::endl;
// GOOD
std::cout << "This is my line\n";

Adding prettify support to "Dynamic theme" in blogger

October 04, 2013 Posted by Antanas Domarkas , , No comments
Open theme customization --> Advanced tab --> Add CSS
Paste this CSS if you like it, or customize your own:
/* Curonian pretty-printing styles. Used with prettify.js.  */
 
pre .str, code .str { color: #DB312F; } /* string literal */
pre .kwd, code .kwd { color: #268AD1; } /* keyword */
pre .com, code .com { color: #B3AE9D; font-style: italic; } /* comment */
pre .typ, code .typ { color: #859900; } /* type */
pre .lit, code .lit { color: #D33682; } /* literal value.  e.g. 1, null, true */
pre .pun, code .pun { color: #647B83; } /* punctuation string */
pre .pln, code .pln { color: #647B83; } /* plain text */
 
pre .tag, code .tag { color: #FF0000; } /* sgml tag */
pre .dec, code .dec { color: #FF0000; } /* markup declaration such as a DOCTYPE */
pre .atn, code .atn { color: #FF0000; font-weight: normal;} /* sgml attribute name */
pre .atv, code .atv { color: #FF0000; } /* sgml attribute value */
pre .src, code .src { color: #FF0000;} /* embedded source */
 
pre.prettyprint, code.prettyprint {
  font-family:"Lucida Console", Monaco, monospace;
  font-weight: normal;
  font-size: 8pt;
  background-color: #FDF6E2;
  -moz-border-radius: 2px;
  -webkit-border-radius: 2px;
  -o-border-radius: 2px;
  -ms-border-radius: 2px;
  -khtml-border-radius: 2px;
  border-radius: 2px;
}
 
pre.prettyprint {
  width: 95%;
  margin: 5px 0px;
  padding: 2px; border: 1px solid #EDE8D4;;
  white-space: pre-wrap;
}

/* Specify class=linenums on a pre to get line numbering */
ol.linenums { margin-top: 0; margin-bottom: 0; color: #647B83; } /* IE indents via margin-left */
li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8 { list-style-type: none }
/* Alternate shading for lines */
li.L1,li.L3,li.L5,li.L7,li.L9 { }

@media print {
  pre.prettyprint { background-color: none }
  pre .str, code .str { color: #060 }
  pre .kwd, code .kwd { color: #006; font-weight: bold }
  pre .com, code .com { color: #600; font-style: italic }
  pre .typ, code .typ { color: #404; font-weight: bold }
  pre .lit, code .lit { color: #044 }
  pre .pun, code .pun { color: #440 }
  pre .pln, code .pln { color: #000 }
  pre .tag, code .tag { color: #006; font-weight: bold }
  pre .atn, code .atn { color: #404 }
  pre .atv, code .atv { color: #060 }
}

Now go back to blogger and switch to edit HTML. At the end of head tag add these lines
<!-- Pretty print support start -->
<link href="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.css" rel="stylesheet" type="text/css"/>
<script src="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.js" type="text/javascript" />
<script language="javascript" type="text/javascript">
    $(window.blogger.ui()).on('viewitem', function (event, post, element) {
        prettyPrint();
    });
</script>
<!-- Pretty print support end -->
Save & close your template.

Now when you want to include source code in your post - put it inside pre tags. Like this:
<pre class="prettyprint">
    /*
    * Put your code here
    */
</pre>
You can find more information on usage over at prettify project website here: http://code.google.com/p/google-code-prettify/

Also thank you to Jeffery To over at stackoverflow for JS function which makes it all work nicely inside blogger.

.gitignore file for Xcode 4/5

October 04, 2013 Posted by Antanas Domarkas , No comments
Original post on stackoverflow: http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects

My own forked gist (updated for Xcode 5): https://gist.github.com/curonian/6761653

-- Update --
Here's quick Terminal command to downloading this:
curl https://gist.github.com/curonian/6761653/raw/ -o .gitignore
git add .gitignore
git commit -m "Adding gitignore file"
git push -u origin master

Accessibility checklist

October 04, 2013 Posted by Antanas Domarkas , No comments
Quick checklist for accessibility proofing.

  • Make sure app can be resized to as small size as possible
  • Might be used on resolutions down to 800x600
  • Make one "bottle neck" method for setting font size inside application (suggested limits 8-40pt)
  • Use application in greyscale mode
  • Make sure every UI element has description for screen readers. (Make sure description strings are localized)
  • Make sure no element depends on just visual information (color/shape)

2013/03/11

Configuring Mac Mail for Google apps

March 11, 2013 Posted by Antanas Domarkas , , No comments
Warning: with setup described below we are going against google philosophy of "Never delete your email again". If I delete email, I DO want it to be deleted.

Ok, so after this scary message let's get started. First things first. Add your google account to Mail application

Server configuration

  • Incoming Mail (IMAP) Server - Requires SSL
    • imap.gmail.com
    • Port: 993
    • Requires SSL:Yes
  • Outgoing Mail (SMTP) Server - Requires TLS 
    • smtp.gmail.com 
    • Port: 465 or 587 
    • Requires SSL: Yes 
    • Requires authentication: Yes 
    • Use same settings as incoming mail server 
  • Full Name or Display Name: [your name] 
  • Account Name or User Name: your full Gmail address (username@gmail.com). Google Apps users, please enter username@your_domain.com 
  • Email address: your full Gmail address (username@gmail.com) Google Apps users, please enter username@your_domain.com 
  • Password: your Gmail password
Link to google answer

Mail configuration

After adding your account open Mail Account settings, select added account and choose Mailbox Behaviors. Make sure your configuration resembles this


P.S. for Mountain Lion users setup stays the same, the only difference you won't have Notes option.

Settings for deleting

Open Settings inside you GMail account and select Forwarding and POP/IMAP. In there, set Auto-Expunge to OFF and Move the message to the Trash.


Don't forget to press Save changes

Setting up labels for IMAP

Tip: if, during configuration process, your label setup fails to update: create dummy label in gmail label management window (you can choose any name), synchronize Mail client and delete dummy label through gmail label management once everything is working.

2013/02/20

Solarized for Qt Creator

February 20, 2013 Posted by Antanas Domarkas , 6 comments
Few weeks ago, I've posted my modification of Solarized theme for Terminal application (post here). Today I'm posting my take of Solarized theme for Qt Creator. You can find original files on github.

Here's result of my modifications:


Download files from skydrive: http://sdrv.ms/12NkfEd
Update: moved files to Github
You can find files here

Installation on Linux/Mac:
cp *solar*.xml ~/.config/QtProject/qtcreator/styles/

Installation on Windows 7:
xcopy *solar*.xml %APPDATA%\QtProject\qtcreator\styles

2013/02/11

Building Qt 4.8 with PostgreSQL support (MSVC)

February 11, 2013 Posted by Antanas Domarkas , , No comments
Today I was rebuilding my dev environment on to a new Windows 7 VM, so I decided to write up whole process for my own future reference, and maybe it will help someone.

Qt 4 has a buggy temperamental support for Postgre on windows using plugin method, so we are building Postgre support into QSql library. As development IDE, we will be using Qt Creator and MSVC 2010 compiler.

2013/02/08

Solarized theme for OSX Terminal app

February 08, 2013 Posted by Antanas Domarkas , , 2 comments
There's an excellent unified theme for various IDE's

Solarized

Unfortunately I wasn't able to find working settings for Terminal app, so I've put together my own.


If anyone will be interested, here's light version settings file: http://sdrv.ms/XrIP5B

Update: Added dark version and moved both files to GitHub

You can find repository here

2013/02/04

2013/01/30