Monday, February 27, 2012

15 Best Practices of Variable & Method Naming (link)

1. Use short enough and long enough variable names in each scope of code. Generally length may be 1 char for loop counters, 1 word for condition/loop variables, 1-2 words for methods, 2-3 words for classes, 3-4 words for globals.

Read more...

Saturday, February 25, 2012

The Sun is Setting on Rails-style MVC Frameworks (link)

Lately I've been thinking a lot about the impact of the move to a thick client architecture for web applications, and I'm becoming more and more certain that this means that Rails-style MVC frameworks on the server-side are going to end up being phased out in favor of leaner and meaner frameworks that better address the new needs of thick-client architecture.

There are a few major reasons for this:

Read more here...

Friday, February 24, 2012

what is Func<T>, really?

Have you ever wondered what the hell is this Func thing? Wonder no more because simply is is the following thing:
public delegate TResult Func<out TResult>();
Don't believe? Here is the screenshot of reflector:

Wednesday, February 22, 2012

MonoDevelop syntax highlighting style inspired by GitHub site

Hi,

I created new syntax highlighting style for MonoDevelop inspired by Github.com site. This time it's light style. The following is screenshot of this theme.

You will find all my themes at github repo: MonoDevelop-Styles.

Tuesday, February 21, 2012

MonokaiNotBold theme for MonoDevelop

Hi,

I have finished alternative version of Monokai theme for MonoDevelop. This time I removed bold style from all keywords. You can grab copy of MonokaiStyleNotBold.xml from my Monokai github repo. By the way original (bold) style is available from the same github repo. It is called MonokaiStyle.xml. Here is post about original version of Monokai for MonoDevelop.

P.S. How to install

  • in MonoDevelop open menu -> Tools -> Options
  • navigate to -> Text Editor -> Syntax Highlighing
  • press 'Add' button
  • nvigate to file 'MonokaiStyle.xml'
  • press 'Open'
  • select 'Monokai' theme and then press 'OK'
  • close and reopen all your file tabs
Have fun ;)

Essential JavaScript Design Patterns For Beginners (link)

I hope this book helps on your journey to improving your knowledge of design patterns and the usefulness of their application to JavaScript. Read more...

Monday, February 20, 2012

What Level Programmer Are You? (link)

Everybody's talking about how programming is the skill that we all are going to need. [Except those folks who might feel that most programming could be turned into wizard-like tools. Insert long discussion about Strong AI.] But what's a programmer? Is the guy who set up his own Apache Web Server a programmer? How about the guy who created a complex Excel spreadsheet? The guy who made his own RPG level? Minecraft players? When we say "Everybody is going to have to know programming" what, exactly, does that mean? Read more...

My git ignore (.gitignore) file for C# projects

The following is my git ignore (.gitignore) file for C# project. I use both VisualStudio and MonoDevelop as IDE's, NUnit for unit testing and also vim for quick view/edit ;)
bin
obj
Obj
TestResults
test-results
*.csproj.user
*.suo
*.cache
*~
*.swp
*.userprefs
*.pidb

Sunday, February 19, 2012

20 Linux System Monitoring Tools (link)

Need to monitor Linux server performance? Try these built-in command and a few add-on tools. Most Linux distributions are equipped with tons of monitoring. These tools provide metrics which can be used to get information about system activities. You can use these tools to find the possible causes of a performance problem. The commands discussed below are some of the most basic commands when it comes to system analysis and debugging server issues such as:
  • Finding out bottlenecks.
  • Disk (storage) bottlenecks.
  • CPU and memory bottlenecks.
  • Network bottlenecks.
Read more

Wednesday, February 15, 2012

Wayland - the life beyond X Windows (link)

Although current discussion of the Linux desktop tends to focus on the disharmony around Unity and the GNOME shell, the true revolution on the desktop is taking place out of sight of users. The Wayland display server is expected to reach version 1.0 later this year, and is seen by many as the long term replacement for the X Window System, with real potential to improve and transform the performance of the desktop for Linux users. Read more...

Visual Studio 2010 Keyboard and Mouse Shortcuts (link)

It's time to learn a thing or two about VisualStudio keyboard shortcuts...

Tuesday, February 14, 2012

Create your first code template for MonoDevelop

I switched from VisualStudio to MonoDevelop as my primary IDE not long time ago. Wat satisfies me in MonoDevelop most it is the level of customization you can applay to it... I was long time user of VisulaStudio and I always used VisualStudio defaults. Monoevelop triggered something in me and in few weeks I created MonokaiStyle for MonoDevelop and MonoDevelop custom code templates. Now I'll show you how you can create yours code templates... Tools->Options
Text Editor->Code Templates->C# and then press add. We will implement IDisposable code template as an example. Start by pasting the following code into code editor:
namespace MyNamespace
{
 public class MyClass : IDisposable
 {
  private bool _disposed = false;

  public MyClass()
  {
  }

  public bool IsDisposed
  {
   get { return _disposed; }
   private set { _disposed = value; }
  }

  protected virtual void Dispose(bool disposing)
  {
   if (!IsDisposed)
   {
    if (disposing)
    {
    }

    IsDisposed = true;
   }
  }

  public void Dispose()
  {
   Dispose(true);
   GC.SuppressFinalize(this);
  }

  ~MyClass()
  {
   Dispose(false);
  }
 }
}
Now we will replace namespace and class names with placeholders (placeholders starts and ends with '$' characters). Your template should look like this:
namespace $MyNamespace$
{
 public class $MyClass$ : IDisposable
 {
  private bool _disposed = false;

  public $MyClass$()
  {
  }

  public bool IsDisposed
  {
   get { return _disposed; }
   private set { _disposed = value; }
  }

  protected virtual void Dispose(bool disposing)
  {
   if (!IsDisposed)
   {
    if (disposing)
    {
    }

    IsDisposed = true;
   }
  }

  public void Dispose()
  {
   Dispose(true);
   GC.SuppressFinalize(this);
  }

  ~$MyClass$()
  {
   Dispose(false);
  }
 }
}
press OK (now your template will be saved).
Now you can use it Edit->Insert template->dsp

Github repo you should watch 2011-02-14 - Xwt

Xwt is a new .NET framework for creating desktop applications that run on multiple platforms from the same codebase. Xwt works by exposing one unified API across all environments that is mapped to a set of native controls on each platform. This means that Xwt tends to focus on providing controls that will work across all platforms. Which means that the functionality available is usually a common denominator across all platforms. The following code taken from github repo README:
using Xwt;

class XwtDemo 
{ 
    static void Main () 
    { 
        Application.Initialize (); 

        var mainWindow = new Window ()
        { 
            Title = "Xwt Demo Application", 
            Width = 500, 
            Height = 400 
        }; 
            
        mainWindow.Show (); 
        
        Application.Run (); 
        
        mainWindow.Dispose (); 
    }
}
Link to GitHub repo

Monday, February 13, 2012

Practical Garbage Collection, part 1 – Introduction (link)

This is the first part of a series of blog posts I intend to write, whose aim will be to explain how garbage collection works in the real world (in particular, with the JVM). I will cover some theory that I believe is necessary to understand garbage collection enough for practical purposes, but will keep it to a minimum. Read more...

Sunday, February 12, 2012

Van Gogh's Starry Night comes to Life (link)

A fluid simulation gently creates a flowing fabric from Van Goghs impressionist portrait of the Milky Way and night sky over Saint-Rémy in France using the thick paint daubs as the particles within the fluid.

A touch interface allows a viewer to deform the image, altering both the flow of the particles and the synthesized sound, and then watch it slowly return to its original state. The sound itself is created using a MIDI interface to create a soft ambient tone out of the movement of the fluid that underscores the soft movement. Beauty through simplicity at its finest and most playful.

Saturday, February 11, 2012

Friday, February 10, 2012

NNXT - DRNK TXTNG (free music at www.digsin.com)

Github repo you should watch 2011-02-10 - node.native

Excerpt from README:

node.native is a C++11 (aka C++0x) port for node.js.

Sample code:

Simplest web-server example using node.native.

#include <iostream>
#include "http.h"
using namespace native::http;

int main()
{
    http server;
    if(server.listen("0.0.0.0", 8080, [](request& req, response& res){
        res.set_status(200);
        res.set_header("Content-Type", "text/plain");
        res.end("C++ FTW\n");
    })) std::cout << "Server running at http://0.0.0.0:8080/" << std::endl;

    return native::run();
}
Go to repo

Bjarne Stroustrup: C++11 Style (link)

We know how to write bad code: litter our programs with casts, macros, pointers, naked new and deletes, and complicated control structures. Alternatively (or additionally), we could obscure every design decision in a mess of deeply nested abstractions using the latest object-oriented programming and generic programming tricks. Then, for good measure, we might complicate our algorithms with interesting special cases. Such code is incomprehensible, unmaintainable, usually inefficient, and not uncommon. But how do we write good code? Watch here...

Thursday, February 9, 2012

Escaping the Cycle of Technical Debt (link)

If you are not familiar with the concept, technical debt is essentially the idea that you build and program things quickly, skipping the niceties in order to ship, and then fix it later. By putting things off you build up debt that needs to be paid down later. One of the places this most commonly shows itself is in performance. It works like this. Developers make features because the business and users want features. Performance is hard, and the benefits of good performance are not usually as obvious or concrete as the benefits of new features. Therefore, nobody really pays attention to performance or it is intentionally skipped until it gets so bad that people consciously notice it. Then the developers need to do a “feature freeze” and fix things until performance is at least “okay.” again. If you don’t mind the cliche, the feature freeze is the “Rinse.”, and then it all starts over again — “Repeat.” This is the cycle of technical debt. At Stack Exchange I saw this happen, the developers had to stop working on features and fix performance because it got the point where we were getting timeouts. However, here is where things get interesting: After that, it never happened again. Read more

Wednesday, February 8, 2012

How I learned to stop worrying and love REST (link)

Buzzwords can be a funny thing. I’ve been writing (what I thought were) ‘RESTful’ web apps and APIs for five years now, and it wasn’t until a couple of weeks ago that I really began to understand what that meant. I’d like to share my ‘AHA’ moment, and give a concrete example of why following the REST style correctly can save you headaches in the long run. Read more here...

Keep It Simple, Stupid (link)

K-I-S-S: Keep It Simple, Stupid. It’s a mantra that always pops into my head when I’m looking at new startups. A lot of them seem to want to do a million different things because other companies have been successful at one of those things in the past. But that’s a bad idea. Way too many new products and services are too complicated. And I would suggest, often fail as a direct result of that. Read more here...

Tuesday, February 7, 2012

One way to defeat boredom

In his blog post Scott Hanselman writes that one of methods for defeating lack of motivation is "skinning and themeing" of your IDE...

"More and more I find myself "skinning and themeing" my Visual Studio development environment 
in order to stay frosty. It's surprising how changing your theme (fonts, colors, etc.) can 
re-energize me when I'm having trouble with some problem or motivation."

- Scott Hanselman

But I took one step further and switched my IDE from VisualStudio to MonoDevelop.

One week later...

Performance:

  • on my 32-bits Windows MonoDevelop is very stable (Warring: colleagues had many problems with MonoDevelop on 64-bit Windows).
  • consumes less memory...
  • feels snappier
  • don't do magic tricks with your code

Customization:

I think the best MonoDevelop feature is that you can customize it the way you like.

  • customize visual style (Tools->Options->Preferences->Visual Style) however this requires some work in LINUX you jest download GTK+ 2.x theme (and it's engine) you like from gnome-look or install it from your package manager. In Windows it's a lot more work (most of gtk themes didn't worked). If you like the dark gtk theme from my screenshot download it from here. (Download uzip and place extracted files into 'c:\Program Files\GtkSharp\2.12\share\themes' directory).
  • customize your syntax highlighting (Tools->Options->Text Editor->Syntax Highlighting if you like my screenshot you can use my syntax highlighting scheme: Monokai for MonoDevelop)
  • you can change key bindings the way you like (Tools->Options->Preferences->Key Bindings) also there are 4 predefined key binding Visual Studio/MonoDevelop1.0/MonoDevelop2.0/GNU Emacs.
  • fonts (Tools->Options->Preferences->Fonts) on Windows I use Consolas 10 for everything...
  • you can customize every aspect of code formatting (Tools->Options->Source Code->Code Formatting->C# source code->C# Format->Edit)

Verdict

I am very happy I made switch. MonoDevelop consumes less memory, feels snappier and is solid. I am more then surprised by it's ability to customize according to your needs... I feel fresh again thanks to MonoDevelop I can work long hours...

Monday, February 6, 2012

Good git cheat sheet (link)

Even with a GUI application at hand there are times when you resort to the command line. We admit we can’t memorize all important Git commands... Read here...

Friday, February 3, 2012

C# example search GitHub API for user

Here follows simple example how to search Github for user with C# WebRequest and Github API V2
using System;
using System.Net;
using System.IO;

namespace SimpleGitHubAPI
{
    class MainClass
    {
        public static void Main (string[] args)
        {
            HttpWebRequest request = WebRequest.Create ("https://github.com/api/v2/json/user/search/dkucinskas") as HttpWebRequest;
            request.Method = "GET";
            request.Proxy = null;
   
            using (HttpWebResponse response = request.GetResponse() as HttpWebResponse) 
            {
                using (StreamReader reader = new StreamReader(response.GetResponseStream())) 
                {
                    Console.Write(reader.ReadToEnd());      
                }
            }
        }
    }
}
Have fun :)

Thursday, February 2, 2012

Why does it take Task Manager longer to appear when you start it from the Ctrl+Alt+Del dialog? (link)

Why does it take Task Manager longer to appear when you start it from the Ctrl+Alt+Del dialog? Well, you can see the reason right there on the screen: You're launching it the long way around. Rea this post for longer answer...

Wednesday, February 1, 2012

Three ways to tell if a .NET Assembly is Strongly Named (link)

Here are several convenient ways to tell whether a .NET assembly is strongly named. Read here