Performance testing of Dictionary, List and HashSet

0
Categories: .NET, C#
Posted on: 30th May 2009 by: Andrei

This is an interesting article. I won’t spoil the results.

Read all about it here: http://softscenario.blogspot.com/2009/05/performance-testing-of-dictionary-list.html

How to protect your Linux home server from automated scripts

1
Categories: Linux
Posted on: 25th May 2009 by: Andrei

Recently, while I was browsing through some of the ftp logs on my Ubuntu server, I’ve noticed some unsuccessfull login attempts with random usernames, spamming every few seconds.

Here’s a few of the solutions I have found to avoid such scripts from wasting too many of your resources:

  • Change the default ports of your services (ftp, ssh etc)
  • Blockhosts.py - scans system logs, and looks for failed login attempts. It keeps a record of the number of times a particular IP address had a failed login. When the count exceeds a configured value, that IP address is added to /etc/hosts.allow with a deny flag, so the next time that IP address attempts to connect to that box, they will get a refused connection message.
  • Fail2ban – scans log files like /var/log/pwdfail or /var/log/apache/error_log and bans IP that makes too many password failures. It updates firewall rules to reject the IP address.
  • SSH Dictionary Attack Prevention with iptables – can also be adapted for use with other ports

How to delete rows in Excel using macros

0
Categories: Visual Basic
Posted on: 24th May 2009 by: Andrei

This code will run on the first column until it finds an empty cell. To change the column, modify the ’1′ with the desired column number in this line

While Cells(Cursor + StartRow, 1) <> ""

Here is the macro.

Sub Macro1()

Dim start As Integer ' row to start on
Dim i As Integer
Dim c As Integer

start = 2
c = 0
i = 1

While Cells(c + start, 1) <> ""
    If (i Mod 33 <> 0) Then
        Rows(CStr(c + start) & ":" & CStr(c + start)).Delete Shift:=xlUp
    Else ' skip row
        c = c + 1
    End If
    i = i + 1
Wend
End Sub

Microsoft products to be launched this year

0
Categories: News
Posted on: 18th May 2009 by: Andrei

Products that will be launched by the end of this year:

  • Windows 7
  • Windows Server 2008 R2
  • Windows Hyper-V Server 2008 R2
  • Windows Azure
  • Exchange 2010
  • .NET 4.0
  • Visual Studio 2010
  • ”Geneva”, identity metasystem implementation
  • ”Dublin”, workflow hosting
  • ”Stirling”, security management
  • ”Velocity”, distributed cache

Products to be launched in the first half of 2010:

  • Office 2010, Office Web Applications and SharePoint 2010
  • SQL Server 2008 R2

Product names in quotes have no marketing name yet.

Advanced SQL Join Techniques

0
Categories: MySQL
Posted on: 18th May 2009 by: Andrei

1. Nested Loop Join

The nested loops join, also called nested iteration, uses one join input as the outer input table (shown as the top input in the graphical execution plan) and one as the inner (bottom) input table. The outer loop consumes the outer input table row by row. The inner loop, executed for each outer row, searches for matching rows in the inner input table.

Information sources:

Examples:

In Microsoft SQL Server the Nested Loop Join will be chosen if one of the tables is small and the other table has an index on the column that joins the tables. The join type can be enforced by using the OPTION clause.

SELECT a.field1 FROM table1 a JOIN table2 b
ON a.table1_id = b.table2_id

There are three types of Nested-Loop join:

  • Naive Nested-loop join – scans an entire table or index.
  • Index Nested-loop join – performs lookups in an index to fetch rows
  • Temporary index nested-loop join – uses temporary index

2. Hash Join

Hash joins are used for many types of set-matching operations: inner join; left, right, and full outer join; left and right semi-join; intersection; union; and difference. Moreover, a variant of the hash join can do duplicate removal and grouping (such as SUM(salary) GROUP BY department). These modifications use only one input for both the build and probe roles.

Information sources:

Currently, MySQL doesn’t support this.

3. Merge Join

The merge join requires that both inputs be sorted on the merge columns, which are defined by the equality (WHERE) clauses of the join predicate. The query optimizer typically scans an index, if one exists on the proper set of columns, or places a sort operator below the merge join. In rare cases, there may be multiple equality clauses, but the merge columns are taken from only some of the available equality clauses.

Information sources:

Further reading:

Microsoft will banish Memcpy()

0
Categories: C++, News
Posted on: 15th May 2009 by: Andrei

Microsoft plans to formally banish the popular programming function that’s been responsible for an untold number of security vulnerabilities over the years, not just in Windows but in countless other applications based on the C language. Effective later this year, Microsoft will add memcpy(), CopyMemory(), and RtlCopyMemory() to its list of function calls banned under its secure development lifecycle.

Source: http://www.theregister.co.uk/2009/05/15/microsoft_banishes_memcpy/

How to return 0 instead of NULL with MySQL

0
Categories: MySQL
Posted on: 15th May 2009 by: Andrei

Just banged my head on this one today while working on a new project in C#.

Here’s how you can return 0 in case SUM() or any other math function returns NULL.


SELECT COALESCE((SUM(myfield)),0) FROM mytable;

COALESCE() returns the first non-null value, therefore if SUM() is null, then it will return the following 0.

How to add rows to a DataGridView programmatically in C#

0
Categories: .NET, C#
Posted on: 15th May 2009 by: Andrei

// Populate the row
string[] row = new string[] {"Item 1","Item 2","Item 3"};

//Add the row to the DataGridView
dataGridView.Rows.Add(row[0]);

You can, of course, create an object array with multiple row arrays and use a foreach to add them all to the DataGridView.

“Introduction to Wolfram Alpha” incredible screencast

0
Categories: News
Posted on: 15th May 2009 by: Andrei

Worth every minute. Amazing.

http://www.wolframalpha.com/screencast/introducingwolframalpha.html

PHP software development kit for Windows Azure

0
Categories: News, PHP
Posted on: 14th May 2009 by: Andrei

You can download an alpha version on codeplex by following this link http://phpazure.codeplex.com/. Only for PHP >= 5.2.4.

  • Overview
    • Enables PHP developers to take advantage of the Microsoft Cloud Services Platform  – Windows Azure.
    • Provides consistent programming model for Windows Azure Storage (Blobs, Tables & Queues)
  • Features
    • PHP classes for Windows Azure Blobs, Tables & Queues (for CRUD operations)
    • Helper Classes for HTTP transport, AuthN/AuthZ, REST & Error Management
    • Manageability, Instrumentation & Logging support