Thursday, January 1, 2015

CQRS

CQRS stands for Command Query Responsibility Segregation

Basic concept of this pattern is to keep separate models to read(Query) and write/update(Command) information. Which lead to Command Query Separation.The main aim of CQRS is to assist in building high performance, scalable systems with large amounts of data.

Usage:

Complex CRUD(Create, Read, Update, Delete) model

chris : http://pietschsoft.com/post/2014/06/15/CQRS-Command-Query-Responsibility-Segregation-Design-Pattern

Wednesday, August 6, 2014

Basic Html page with Angular js in 2mins

We only need one html file for this. We can also use three files for this purpose.

1. Angular.js file – this is the main javascript file we need to make page support for Angular js. We can include it in our folder or we can directly take it from CDN.

2. Basic Html file – this file should contain ng-app in any HTML tag. ng-controller,ng-repeat and {{variable}} are code syntaxes.

3. CardController.js file -  this file contains controller class and with $scope variable it defines its parameters.

<html ng-app xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<!--<script src="scripts/angular.min.js"></script>-->
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.21/angular.min.js"></script>
<script language="javascript">
//we can also use CardController.js for this
var CardController = function ($scope) {
$scope.cards
= [{ Id: 1 }, { Id: 4 }];
};
</script>
</head>
<body ng-controller="CardController">
<div ng-repeat="card in cards" class="CardItem">
Id: {{card.Id}}
</div>
</body>
</html>

Output will be
Id: 1
Id: 4


Hope you wanted to learn more simple beginners lessons on AngularJS covering most parts with examples. W3Cschools.com - http://www.w3schools.com/angular/default.asp

Tuesday, August 5, 2014

Remove Carriage Return, Line Feed, Tab in TSQL

Following code shows way to remove all spaces from selected column values. We generally use RTRIM and LTRIM build in string functions but sometimes it doesn’t remove some spaces due to string contains carriage return life feed and tab like control characters. We can’t see these characters with grid result view but we can see in text result view in MSS Management Studio.

REPLACE(REPLACE(REPLACE(RTRIM(LTRIM(ColumnName)), CHAR(10), ''),CHAR(13), ''),CHAR(9), '')
CHAR(9) - 'Tab'
CHAR(10) - 'Line Feed'
CHAR(13) - 'Carriage Return'

Wednesday, June 4, 2014

Started to deep learn Software Design

image

Clean Code: A Handbook of Agile Software Craftsmanship [Robert C. Martin]

Tuesday, April 1, 2014

Create a user for SQL Server authentication

First log into sql server using sql management studio or other relevant tool as an administrator.
Then use following command to create testuser in testdb database. You can ignore DEFAULT_DATABASE part as well if it is not working.

-- Create user for SQL Authentication
USE master
CREATE LOGIN testuser
    WITH PASSWORD = 'test#123',DEFAULT_DATABASE = testdb
GO

-- Creates a database user for the login created above.
USE testdb
CREATE USER testuser FOR LOGIN testuser
GO

Saturday, December 15, 2012

System.BadImageFormatException

I got following error when running Test project with visual studio 2010.

SetUp : System.BadImageFormatException : Could not load file or assembly 'TP, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Solution:

When I checked there were difference in Solution platforms of two project.One set to x86 while other project set to AnyCPU.So I changed it from AnyCPU to x86.It works.

Wednesday, July 18, 2012

C# Password encrypting and decrypting

public static string HashPassword(string password)
{
    var provider = new SHA1CryptoServiceProvider();
    var encoding = new UnicodeEncoding();
    var hash= provider.ComputeHash(encoding.GetBytes(password));
    return Convert.ToBase64String(hash);
}

var pwdstr=HashPassword(password);
var user=(from u in context.Users
          where u.UserName.Equals(username) && u.pwd.Equals(pwdstr)  
          select u);

This is simple way to set and check password stored in database.Hope it will helpful.To store in a database use first method and to compare use second method.Until next post cheers!!!

Tuesday, April 10, 2012

MSSQL useful tips

MSSQL set null when value is not numeric in select query

SELECT CASE ISNUMERIC(column1) WHEN 1 THEN column1 ELSE NULL END FROM table1

SQL Server Error Messages - Msg 8152 - String or binary data would be truncated.  The statement has been terminated.

This error message is occurred when I tried to insert data to values from another table.It’s due to one column in the table that im inserting data have lesser length than other table column.(varchar(25) – varchar(max)).It couldn’t found previously because second table column I have used max length but when inserting data it filled with strings that contains more than 25 characters.

I found another command to skip that error and continue but its like a try catch statement without catch part(thanks yasindu bro for nice example).

SET ANSI_WARNINGS OFF

Need to use above command before inserting records.but sometimes it’s not working

Inserting multiple records to a table

This isn’t simple thing but I previously work with MySQL and that is different and we can’t use

INSERT INTO tblName (column1,column2)
VALUES
('Value1','value11'),
('Value2','value22'),
('Value3','value33')
INSERT INTO tblName (column1,column2)
select ‘Value1′,’Value11’
UNION ALL
select ‘Value2′,’Value22’
UNION ALL
select ‘Value3′,’Value33’

Monday, March 5, 2012

Starting Open Xml for Microsoft Office

Previously I have work with Aspose slides and now I’m trying to work with this one.First need to download OpenXml SDK for that used following link.This link also contains Open Xml tools setup that includes help documents etc..  image

Download Open Xml SDK 2.0 

Starting Steps

  1. Install OpenXml SDK (and tools )
  2. Open Visual Studio (currently I’m using visual studio 2010 with c#)  create new windows form project
  3. Reference DocumentFormat.OpenXml dll which is in installed path (Projects->Add Reference->browse to dll)
  4. Use following name spaces image
  5. to create new presentation image
  6. to open exist presentation image

Errors Occurred :

The type 'System.IO.Packaging.Package' is defined in an assembly that is not referenced. You must add a reference to assembly 'WindowsBase, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

this error can be solved adding reference to windowsBase in .Net Tab.

Thursday, January 5, 2012

How to get Twitter ID

Before I start I wish you all a very happy new year 2012.It took long time after my last since I got new job and many changes happened in recent months.

I was learning WPF(Windows Presentation Foundation) and I tried to create RSS Feed reader.I tried to get twitter feeds from my twitter account and I searched in google and I found a code but it needed twitter id for that.I found it can be also replace by username.But this code is also useful.

I open http://api.twitter.com/users/show/rasikalb.json {this is for me common url http://api.twitter.com/users/show/[replace username].json}url and it shows some useful json code that we can get many twitter account details.last line contains  twitter id.

image

We can access our twitter feed from http://twitter.com/statuses/user_timeline/[userId or username].rss it shows as follows.Using this rss file we can read tweets.

image

Hope to post about SQL, C# useful tips in future.Until next post cheers ..!!!

Monday, August 15, 2011

Beginner techies guide to Internet World – part I

I thought what to write this Freshly created eMagazine and I decided it’s better to write something from the beginning.Now I have more than 5 year experience in internet world.Still I’m unable to learn all.But little.But I think these days our young generation are carelessly use this world because lack of knowledge of its true value.I think following steps will help at some level if you are a beginner

Internet Browsers
This is the software need to browse in the WWW (world wide web) or internet.there are plenty of internet browsing softwares.Windows default one is Internet explorer and in imagemost of linux OS’s, Firefox is default SW.But I like Google Chrome since it has quick search functionality(we can search from address bar), large web page area,collection of themes & plugins, there are many tools to support web developers and it’s softer than others.But it has some disadvatages too.It crashes than others.need more processing power when we open many tabs.Some microsoft products don’t work with other browsers so we need internet explorer in that stage.Firefox is best browser according to http://internet-browser-review.toptenreviews.com/

Search Engines
The very beginning thing.Most of newbies to internet are doing this mistake.they type web address in search engines.Because most of the browsers home page is set to a search engine.Search engine are sites that help to find web pages in internet.You have to do is just type what you need to find in search engines search text box.

Google.com is most famous one.And it has many functionalities such as image,video  real time searching etc.. Googling is a term to search something from google.com. this.Other famous search engines like Yahoo.com and  msn.com provide directory services, news and many other things.Since we need specific information rather than some other news so I prefer google.com than others.
source:http://en.wikipedia.org/wiki/Web_search_engine

Email accounts
There are many email providers but to me gmail.com is best one .Because to use most of google products such as google doc, google plus,google map need gmail accounts.
imageAnd also it has chatting facilities,filtering and many features.If you are a beginner it’s better to start your email with gmail.com .But there are many email providers. ex:yahoo.com,live.com, and newest one phoenix mail that provides facility to connect many email accounts to one.I strictly believe using too many email account isn’t good.It will waste your time.


Social Networking sites
I don’t think you need to guide to social networking sites.But if you are not aware about them.Just try facebook and google plus.These are the sites where most of people networking.These are facilitate Chatting,photo and video sharing,status updates,personal information sharing things. Although there are many benefits most people ruin that plus points by addict to those sites in most of times.

image
Social networks mean Facebook and google plus.Is that all.No.As you can see in the image there are many social networking sites that help us to build better social network.I have done my seminar presentation on Social Network Analysis you can get more information about Social Networks from that presentation here is the link. http://bit.ly/ne8kHS I think that’s enough for this post.I hope to post about twitter,blogs and some other useful techy stuffs in next post.Please comment and give your opinion about this post.It will be a really encouragement to raise new writer.
Thank you for reading this.Until next post cheers….!!!

By Rasika Bandara

Monday, July 4, 2011

Hope C# examples will help me

As I post previously Now I’m reading a book called C# 4 and .NET 4.But the thing is Without examples it’s boring so I decided to do it with this one.I heard this is a very useful book.

 image

Hope I can get some big support for my future developments.

C# Modifiers

image

image

Source: Professional C# 4 and .NET4 Wrox Programmer to Programme

Sunday, July 3, 2011

.Net Architecture

image

  • IL-Intermediate Language
  • CTS-Common Type System
  • CLS-Common Language Specification
  • JIT-Just In Time Compiler
  • GC-Garbage Collector

Started C# from the beginning

Although I have some knowledge and experience with C# I’m trying to organize my knowledge so I’m starting to read Professional C# 4 and .Net 4

image

This book was recommended by one of the software Architect.I must thank him for his help in many cases.

Friday, July 1, 2011

Bus journey time map from kandy to colombo

Morning Trip Afternoon Trip

5.50 Start-kandy
6.08 kadugannawa
6.16 hingula
6.20 mawanella
6.33 karadupana
6.38 kegalle
6.45 ambanpitiya
6.50 galigamuwa
6.56 nelumdeniya
7.02 tholangamuwa
7.05 warakapola
7.15 danovita
15min break
7.39 pasyala
7.44 nittambuwa
8.08 miriswatta
8.15 belummahara
8.21 imbulgoda
8.35 kadawatha
8.42 kiribathgoda
8.46 kelaniya
8.54 peliyagoda
9.15 colombo-Destination

11.15 start-Colombo
11.25 dematagoda 09
11.40 kelaniya
11.50 kelaniya dalugama
11.54 kiribathgoda
12.00 kadawatha
12.17 imbulgoda
12.22 belummahara
12.25 miriswatta
12.28 yakkala
12.38 kalagedihena
12.42 thihariya
1.17 warakapola
1.30 nelumdeniya
1.50 kegalla
2.08 molagoda
2.15 mawanella
2.27 hingula
2.35 kadugannawa
2.45 pilimatalawa
2.55 peradeniya
3.10 Kandy-Destination

with CTB bus
there was tea break
with private bus
it was late mostly because of traffic at the moment

Monday, June 27, 2011

Just Finished Learning PHP,MySQL & JavaScript eBooks

Although I have good experience of PHP, MySQL & JavaScript I learn many things from this book such as JavaScript Frameworks.I just read this book and I recommend this book for beginner web developers to read.  image

Some popular JavaScript frameworks


ASP.NET Ajax Framework http://asp.net/ajax
Clean Ajax Framework http://sourceforge.net/projects/clean-ajax
Dojo Toolkit http://dojotoolkit.org
jQuery http://jquery.com
MochiKit http://mochikit.com
MooTools http://mootools.net
OpenJS http://openjs.com
Prototype http://prototypejs.org
Rialto http://rialto.improve-technologies.com/wiki
script.aculo.us http://script.aculo.us
393Framework Web address
Spry Framework http://labs.adobe.com/technologies/spry
YUI http://developer.yahoo.com/yui

Sunday, June 26, 2011

Close one form from another

I wanted to open Form2 from Form1 and close Form1.I try this many times but it fails my code is this.

var F2=new Form2();
F2.show();
this.close();



I searched lot.but I could find any error of the code but Form1 doesn’t closed.Finally I found the answer.It’s my main program.

Application.Run(new Form1());

So I couldn’t close Form1.


But I found anther way to close previous one

 var f=new Form2();
 f.Show();
 this.Dispose(false);


It works for me.

Saturday, June 25, 2011

Visual Studio Short Cut

For comment source code at visual studio or MSSQL sever management studio can use Ctrl+k,Ctrl+c when press Ctrl+k it waiting for another key stroke then press Ctrl+c

For Uncomment use Ctrl+k,Ctrl+u

Ctrl+k,Ctrl+D for format code but this isn’t work in MSSQL Server Management Studio