code
Separate out your exception handling
Say you have a method similar to the following
void DoSomethingAmazing()
{
try
{
// do lots of stuff
}
catch
{
// handle exception in an amazing way
}
}
Then you go off happily coding away and you want to...
Read more...
language
C#
Format strings
To specify a format string for use with String.Format the following structure is required.
{index[,alignment][:format]}
For example :
String.Format( "One number : {0:#.00####} Another number *{1,10:#}*", 100, 200 );
-
{ } : the format...
Read more...
Ruby
Create a hash from a list of keys and their mapped values
I always miss creating a Hash using an array of keys and an array of their associated values, like :
Hash[key1, key2], [value1, value2]
Ruby doesn’t like this. Its Hashes are created with an array like :
Hash[key1, value1, key2, value2]
This...
Read more...
ObjectiveC
Closures
Blocks are what is known as a closure. What this means is that the code inside the block can access the variables that have been defined outside the the block definition.
As can be seen here :
int x = 3;
void(^block)() = ^() {
...
Read more...
ide
VisualStudio
Uppercase
Ctrl + Shift + U -> Converts selected text to UPPERCASE
There is no default key combination for converting to lowercase. For this, go through the menus: Edit -> Advanced -> Make Lowercase
Read more...
Vim
Getting into edit mode
When in Command mode, there are a number of keys to get into Insert mode to start entering text.
i -> Insert text before the cursor
I -> Insert text at the beginning of the line
a -> Append text after the cursor
A -> Append text at the...
Read more...
XCode
Page up and Page down
To go up or down a page without the PC Page up and Page down keys use:
fn alt up -> Page up
fn alt down -> Page down
Read more...