Microsoft .NET to run on Linux and Mac OS X

Microsoft .NET will finally run fully on Linux and Mac OS X platform and this is a great news.

Visual Studio is maybe the best tool for developers and Microsoft decided to open sourcing the full server-side .NET Core stack, from ASP.NET 5 down to Core Runtime and Framework.

Microsoft is also giving for free Visual Studio Community 2013 full featured edition of Visual Studio, available today.

You can watch more about this here.

Open source links
ASP.NET – https://github.com/aspnet/home
.NET Compiler – http://roslyn.codeplex.com/
.NET Core – https://github.com/dotnet/corefx
.NET – https://github.com/Microsoft/dotnet

Continue Reading

How to delete duplicated records in MS SQL Server?

First, create one demo table

Let’s create one demo table first. It will be called Person and will hold some fictive person data.

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE dbo.Person
(
  Id int IDENTITY(1,1) NOT NULL,
  Firstname nvarchar(50) NULL,
  Lastname nvarchar(50) NULL,
  Email varchar(100) NULL,
  Created datetime NULL,
  CONSTRAINT PK_Person PRIMARY KEY CLUSTERED
  (
    Id ASC
  )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON PRIMARY
) ON PRIMARY
GO
SET ANSI_PADDING OFF
GO

Now, fill the data

Insert some fictive person data and do some duplicated records that have the same values for fields  firstname, lastname and email.

INSERT INTO Person (Firstname, Lastname, Email, Created) VALUES ('John', 'Belvien', 'john.belvien@example.com', GETDATE())
INSERT INTO Person (Firstname, Lastname, Email, Created) VALUES ('Peter', 'Lumberjack', 'peter.lumberjack@example.com', GETDATE())
INSERT INTO Person (Firstname, Lastname, Email, Created) VALUES ('Peter', 'Lumberjack', 'peter.lumberjack@example.com', GETDATE())
INSERT INTO Person (Firstname, Lastname, Email, Created) VALUES ('Peter', 'Lumberjack', 'peter.lumberjack@example.com', GETDATE())
INSERT INTO Person (Firstname, Lastname, Email, Created) VALUES ('Suzy', 'Leghorn', 'suzy.leghorn@example.com', GETDATE())
INSERT INTO Person (Firstname, Lastname, Email, Created) VALUES ('Suzy', 'Leghorn', 'suzy.leghorn@example.com', GETDATE())
INSERT INTO Person (Firstname, Lastname, Email, Created) VALUES ('Daisy', 'Sommerfield', 'daisy.sommerfield@example.com', GETDATE())
INSERT INTO Person (Firstname, Lastname, Email, Created) VALUES ('Daisy', 'Sommerfield', 'daisy.sommerfield@example.com', GETDATE())
INSERT INTO Person (Firstname, Lastname, Email, Created) VALUES ('Daisy', 'Sommerfield', 'daisy.sommerfield@example.com', GETDATE())
INSERT INTO Person (Firstname, Lastname, Email, Created) VALUES ('Daisy', 'Sommerfield', 'daisy.sommerfield@example.com', GETDATE())

Now the magic

Use this subquery trick to extract duplicate records and then delete them. Notice the use of PARTITTION and WITH Transact-SQL keywords. All records that have RowNumber > 1 are deleted.

WITH CTE AS
(
  SELECT  Id,
          Firstname,
          Lastname,
          Email,
          ROW_NUMBER() OVER (PARTITION BY Firstname, Lastname, Email
          ORDER BY	Created) AS RowNumber
  FROM Person
)
DELETE FROM Person WHERE Id IN (SELECT Id FROM CTE WHERE RowNumber > 1)
Continue Reading

Tips and Tricks: Export GoogleMaps as image

You don’t really need to bother with exporting GoogleMaps position into the image because Google created StaticAPI that renders the whole map as image, instead of using JavaScript to make dynamic map.

Example:

<img alt="" src="//maps.googleapis.com/maps/api/staticmap?center=46.056988,14.515536&amp;zoom=15&amp;size=455x350&amp;maptype=roadmap&amp;markers=color:red%7Clabel:S%7C46.056988,14.515536&amp;sensor=false" border="0" />

This will results with this:

Continue Reading

How to escape parenthesis/brackets ‘{‘, ‘}’ in string.Format?

Usually you have something like this:

string.Format("Output: {0}", "A");

This will result as:

Output: A

What you should do if you want to make an output like this?

Output: {A}

You need to escape parenthesis/brackets like this:

  • You use {{ to output {
  • You use }} to output }

So, you final C# command should look like this:

string.Format("Output: {{{0}}}", "A");

Continue Reading

Daily project: Automatic Twitter status updater

Courtesy of Venture Capital for Africa
Courtesy of Venture Capital for Africa

I like to read great quotes, because they express the wisdom and the creativity of human race.

So, I was thinking how I can share them automatically on my Twitter account. First task was to find out the source of great quotes and RSS/Atom feeds are perfect data source to complete this task. After some researching I found out few publicly available sources on BrainyQuote.com:

  1. Quotes of the day: http://feeds.feedburner.com/brainyquote/QUOTEBR
  2. Love quotes: http://feeds.feedburner.com/brainyquote/QUOTEFU

After having the source all we need to do now is to parse these RSS feeds and we need also a tool to publish these quotes automatically to the Twitter account.

For parsing RSS I rewrote one C# class that do this job (it reads data from RSS feed which is basically XML and put these data into one list of custom RSS objects).

TweetSharp is nice tool to do automatic updates of your Twitter status. You need to enter four keys from your Twitter application to make this process seamless:

  1. ConsumerKey
  2. ConsumerSecret
  3. AccessToken
  4. AccessTokenSecret

You get these keys after you create your first Twitter application under http://dev.twitter.com

Updating Twitter status is then an easy task:

//You have defined somewhere before: consumerKey, consumerSecret, accessToken, accessTokenSecret
var service = new TweetSharp.TwitterService(consumerKey, consumerSecret);
service.AuthenticateWith(accessToken, accessTokenSecret);
var response = service.SendTweet(new TweetSharp.SendTweetOptions() { Status = quote.Tweet });

After all is programmed and tested I just created an automated task that updates my Twitter status every 4 hours.

What was the result?

I increased the number of followers by 20% in just few days ­čÖé

Plus, I can read this every day during my lunch break and enjoy in great wisdom quotes.

What need to be improved?

Sometimes I got an empty quote in my Twitter feed – so I need to check the content better before I publish it online.

What’s next?

This mini project could be upgraded into an SaaS service product where users will register, enter the RSS sources from which they want us to parse the data and service will do everything else automatically (publish on Twitter). So it could be named somehow “Intelligent automatic Twitter updater from the given data source”.

Interested? Contact me if you think it could be interesting and you want to contribute to this idea (perfect match would be if you can create the design and user experience for this service).

Continue Reading

Scrum and Kanban development frameworks

Just returned from the very interesting lecture (by Du┼ían Omer─Źevi─ç from Zemanta and Andrej Zrim┼íek from NiceLabel) about Scrum and Kanban development frameworks here in Ljubljana, Slovenia and I am right now thinking about what I heard there and comparing with our approach, what we are doing in out development process.

What I like is this:

  1. Developers protection from new feature requests while they are in one Sprint cycle. We have this problems all the time (adding new features and breaking the release date agreement).
  2. What was agreed this exactly will be done – no rooms for changes during the one Sprint.
  3. No multitasking, doing one task in agreed time period of time. Focus is about saying no to 1000 things.
  4. Communication, Communication, Communication.
  5. Doing retrospectives  backwards and re-evaluating what was done at the end of each Sprint cycle.
  6. If we set a rule that we will do only 5 bigger tasks in certain amount of time and if top manager come with new task he must choose which one of previous 5 tasks he will remove to make the place for this new task. Really cool, and make them think.

What I don’t like:

  1. I felt during the lecture that lecturers talk really slow, like they don’t care at all about the time and I was worried about their productivity in real company environment.
  2. At the end of the lecture, we have put our questions on the board and they chose 5 questions from 15 and set 45 minutes frameset to go through these 5 questions.
  3. Even it is very useful framework it also looks to me little bit like bureaucracy if not used in a right way (in a way that real programming hours will decrease in organization and also the lines of produced code).
  4. I am not sure how this is suitable for small teams (for example, 3 people).
  5. It is in the humane nature to try to earn highest amount of money for smallest amount of work so I am afraid that people will be happy to have 3-days weekend (if Monday is dedicated for all day meeting and discussion).
  6. There is a Programming, Motherfucker movement that expose this problem more exactly.

Best practice is to take the best from both approaches!

programming-motherfucker

Continue Reading