Saturday 21 November 2009

Diving into RIA architectures with Flex as an example

Now I have a need to dive into Flex architecture common structure and widely used patterns. Below goes the list of links I've found useful and interesting:

Introduction to RIA architectures

Flex Architecture Fundamentals in 4 parts

Martin Fowler UI patterns

Great benchmark for different ways of Flex to communicate with external services:
(Yes, and SOAP/XML is 4 times slower than Flash-native AMF format)

All of these are really interesting articles that are definitely worth reading even if you don't have same need as I do.

Friday 20 November 2009

Fixing IronRuby error when installing Rake

I was trying to install Rake with IronRuby but was always getting the following error:

>igem install rake
ERROR: While executing gem ... (ArgumentError)

After some Googling I've found the following article:


It's not in English or in Russian so I had to ask Google Translate for help. The article stated that length of name is greater than 255 and that's the problem. I've checked mine:

C:/Program Files/IronRuby 0.9.2/

Obviously it's not longer than 255 characters, so the reason is possibly in spaces. I've reinstalled IronRuby to:

E:/bin/ironruby

And...

PS C:\Users\Ivan Suhinin> igem install rake
Successfully installed rake-0.8.7
1 gem installed
Installing ri documentation for rake-0.8.7...
Installing RDoc documentation for rake-0.8.7...

Yahoo! :) Hope this post will help someone with same problem.

Thursday 19 November 2009

Running IronRuby 0.9.2 with RubyMine 2.0

Latest releases of IronRuby 0.9.2 and RubyMine 2.0 inspired me to make them play together. That's my first experience of running IronRuby in fully featured IDE so I was rather doubtful whether it will work or not.

Here goes step-by-step manual:

1. Download IronRuby 0.9.2 from here and install it.
2. Download RubyMine 2.0 from here and install it. You may need a licence - grab it here.
3. Run RubyMine
4. Click Project Settings or press Ctrl + Alt + S:


5. Navigate to 'Ruby SDK and Gems' left menu option:


6. Click 'Add SDK...' button:


7. Choose ir.exe in your IronRuby 0.9.2 installation folder:


8. That's it! We have IronRuby listed as Ruby SDK in RubyMine:


9. Let's try it in action! Close this window and create a new project:


10. Choose project location and 'Empty project' option - we don't need Rails at the moment:


11. Create a folder named 'src' and add a 'main.rb' file to it:


12. Write this code to editor (and feel the power of RubyMine's IntelliSense):


13. Click the arrow button and choose 'Edit Configurations' option:


14. Add new Ruby configuration:


15. Name configuration and select our 'main.rb' file as executable script:


16. It's damn important to clear 'Ruby Arguments' field. Change this:


to this:


otherwise you'll get the 'can't convert NilClass into String (TypeError)' error:


17. Press OK and run our first program:


18. Here we go, our first IronRuby program running in RubyMine:


Isn't it wonderful? :)

Wednesday 18 November 2009

Use remote desktop connection faster with PowerShell

We have more than ten servers in our production network and all of them are accessible via RDC. The problem is that to connect via RDC you have to specify public IP and not local network nice name like "prod-01" or "prod-db-01". I had not bothered about it till I had a need of connecting some of them several times a day. To solve this problem I wrote a PowerShell script that takes nice name of server and launches RDC with its IP:

$prodServers =
@{
'prod-01' = '1.2.3.2';
'prod-02' = '1.2.3.3';
'prod-03' = '1.2.3.4';

'prod-db-01' = '1.2.3.6';
'prod-db-02' = '1.2.3.8';
}

Set-Alias rdcx 'c:/WINDOWS/system32/mstsc.exe'
function rdc([string]$serverName)
{
$param = ''

if ((![System.String]::IsNullOrEmpty($serverName)) -and ($prodServers.Contains($serverName)))
{
$param += '/v:' + $prodServers[$serverName]
}

rdcx $param
}

It's extremely useful if you have many servers, just believe me :)

Monday 16 November 2009

Use PowerShell to determine MS SQL table used data space

Yet another issue to be solved: we have SQL Expression installed at our branch server and it allows only 4Gb per table. So - what's the solution? Of course, PowerShell!

Right click on database - "Start PowerShell". (Note: I do NOT know how to enter MS SQL mode from normal PowerShell). And now we can have some magic with our database! The following script shows databases that are too heavy and can be cleaned up after some consideration:

ls tables | sort -Property DataSpaceUsed -Descending | ? {$_.DataSpaceUsed -gt 1024} | % {$_.Name + " takes " + [math]::Round($_.DataSpaceUsed / 1024 ) + " Mb"}

Wasn't that just sexy? :) Here goes the step-by-step explanation:

ls tables

Listing all db tables.

sort -Property DataSpaceUsed -Descending

Sorting descending by DataSpaceUsed field - we need to see only the heaviest.


? {$_.DataSpaceUsed -gt 1024}

Taking only tables that take more than 1Mb in data space.

% {$_.Name + " takes " + [math]::Round($_.DataSpaceUsed / 1024 ) + " Mb"}

Making output look nice and actually showing table name.

Friday 13 November 2009

Enlarge your Build System!

http://www.jameskovacs.com/blog/ReleasingPsakeV100PsakeV200.aspx

Rake? NAnt? NO!!!!!!!!!!!

PSake? YES!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

What is it? Ha! Powershell-based build system. DSL for tasks, easily integrated with PS script blocks.

That's only 9th message!

Yeap. This message is only 9th message I have in this year. Compared to 158 messages from last year it seems a bit... small? :)

I should definitely write more.

Delete all MSMQ queues at some PC with PowerShell

We have a small issue at one of our production servers. Once something generated ~10K queues with Guid-like names. Since then they were not deleted as there was a problem: standard MSMQ manager doesn't allow deleting several queues at once.

What to do? Powershell, of course! :) Here goes the script:


[Reflection.Assembly]::LoadWithPartialName("System.Messaging")

[System.Messaging.MessageQueue]::GetPrivateQueuesByMachine("someserver") | % {".\" + $_.QueueName} | % {[System.Messaging.MessageQueue]::Delete($_); }


You may also filter them by name if you do not need to remove them all as I need:


[System.Messaging.MessageQueue]::GetPrivateQueuesByMachine("someserver") | % {".\" + $_.QueueName} | ? {$_ -match "SOME_REGEX_FILTER"} | % {[System.Messaging.MessageQueue]::Delete($_); }

And SOME_REGEX_FILTER is... Yeap, some regex filter :) The -match operator allow us using regular expressions in the Where-Object (alias "?") clause.

Have fun with PowerShell!