December 03, 2013

Installing Cisco Packet Tracer 6.0.1 on Ubuntu 13.10 (64-Bit)

I have posted about Installing Cisco Packet Tracer on Ubuntu 13.04 and prior versions. But this method is not working on Ubuntu 13.10 because of repository issue I think. So "Medywan" posted a link. I followed linked and found a new way. But it was not in english so I translated it. 

Thanks for the guy who posted it first : http://www.be-root.com/2013/11/19/installation-de-cisco-packettracer-6-sur-ubuntu-13-10-64bits/ Credit should goest to him!

Run those commands in terminal first.
sudo dpkg --add-architecture i386
sudo apt-get install libnss3-1d:i386 libqt4-qt3support:i386 libssl1.0.0:i386 libqtwebkit4:i386 libqt4-scripttools:i386
After that install using bin file. "Cisco Packet Tracer 6.0.1 for Linux - Ubuntu installation (no tutorials).bin" would be the filename. This name is too long for me. Then I renamed it to "ciscopt.bin". chmod +x ciscopt.bin
./ciscopt.bin
Thanks again to Medywan and the author http://www.be-root.com/ site!

November 20, 2013

Where to declare Java Variables?

Recently I went to Java Meetup. And it was all about Garbage Collector. So I learned lot more about Garbage Collectors. So Dr. Daya's suggestions was not to declare variable in higher scopes unless we really know what we do. For a example, don't declare class level variables if we are only using it inside on method. Then I was thinking about doing some tests on variable declarations. I used following code:

Then I used following code to do see the difference. Following code is declaring a variable in a higher scope(which is bad according to Dr.Daya).

First Code execution time was 1756557171 ms.(Variable01.java)
Second Code execution time was 1826556296 ms.(Variable02.java)

With those statistics, it's clear that declaring objects(Strings) in relevant scopes improves performance. But primitive data types are different. So I did same code for a primitive data type.


int is a primitive data type. It will not behave like String did. Improvement is upside down here.

Third Code execution time was 1829664932 ms.(Variable03.java)
Forth Code execution time was 1681147372 ms.(Variable04.java)

Those statistics were collected from same machine with same condition. And I ran those programs against JRE 1.6.0_45. I saw a difference in result, when I ran those programs on JRE 1.7.0_45. Now I'm digging into it!

November 02, 2013

Ubuntu 13.10 කොහොමද?

මම දැන් අවුරුද්දක විතර ඉදලා පාවිච්චි කරන්නේ එක එක ජාතියේ ලිනක්ස් ඩිස්ට්‍රෝ. ඒකට හේතුව වෙලා තියෙන්නේ මට වැඩ කරන්න වෙලා තියන සර්වර්ස් හැම එකක්ම වගේ ලිනක්ස් හන්දා, මමත් ලිනක්ස් පාවිච්චි කරන කොට ගොඩක් ලේසි. ඒත් මම පාවිච්චි කරපු හැම ලිනක්ස් ඩිස්ට්‍රෝ එකකින්ම පහසුව අතින් බලනකොට ඉස්සරහින්ම ඉන්නේ උබුන්ටු. ඇත්තටම ලින්ක්ස් සාමාන්‍ය එදිනෙදා වැඩ කරන අයට පාවිච්චි කරන්න පුලුවන් තරමට පත් කරලා තියෙන්නේ උබුන්ටු කියන එක කියන්න ඕන. උබුන්ටු වල 9 වන උපන් දිනයත් ගිය මාසේම තමා තිබුනේ.

ඉතින් ගිය මාසේ 17 වෙනිදා උබුන්ටු 13.10 ඒකියන්නේ උබුන්ටු වල අලුත්ම සංස්කරණය නිකුත් කලා. උබුන්ටු වල සංස්කරණ නම් කරන ක්‍රමයක් තියනවා. ඒ තමා පලවෙනි ඉලක්කම් දෙකෙන් කියන්නේ සංස්කරණය නිකුත් කරන අවුරුද්ද, 13 කියන්නේ 2013 කියන එක. ඒවගේම දෙවනෙි ඉලක්කම් දෙකෙන් කියන්නේ නිකුත් කරන මාසය, 10 කියන්නේ ඔක්තෝම්බර් කියන එක. උබුන්ටු රිලිස් කරන්නේ අවුරුද්දකට දෙපාරක් විතරයි. ඒක අප්‍රේල් මාසයේ සහ ඔක්තොම්බර් මාසයේ. ඒක හන්දා දෙවෙනි ඉලක්කම් දෙක වෙන්න පුලුවන් 04 හෝ 10 විතරමයි. ඒවගේම අවුරුදු දෙකකට සැරයක් LTS සංස්කරණයක් නිකුත් කරනවා. LTS කියන්නේ Long-Term Support කියන එකයි. LTS සංස්කරණ ගොඩක් ස්ථායි. ඒකියන්නේ තියන bugs ගොඩක් අඩුයි. ඒවගේම ඊල LTS රිලිස් එක එනකම් LTS වලට Updates, Patches නිකුත් කරනවා.

ගොඩක් පරිගණක පාවිච්චි කරන අයට වින්ඩෝස් වලිදි තියන වයිරස් කරදරයෙන් මිදෙන්න හොදම විසදුමක් තමා උබුන්ටු. වින්ඩෝස් වල තියන හැම සොෆ්ට්වේයා එකකටම වගේ විකල්පයක් තියනවා උබුන්ටු වල.

මේ infographic එක අරගත්තේ මම http://www.omgubuntu.co.uk/ සයිට් එකෙන්.


උබුන්ටු වල තියන Unity ඩෙස්ක්ටෝප් එකට මගේ වැඩි කැමැත්තක් නැ. ඒත් උබුන්ටු 13.10 වලදි Unity වලට features එකතු කරලා තියනවා. මම ඇතතටම කැමති අවශ්‍ය ඇප්ලිකේෂන් සර්ච් කරන්න පුලුවන් ගුණාංගයට. එවගේම පාවිච්චිය ලේසි කරන විදිෙහේ ගුණාංග එකතු කරලා තියනවා. ඒත් ලොකු වෙනසක් කරන දෙයක් එකතු කරලා නෑ.

මම උබුන්ටු 13.10 ඉන්ස්ටෝල් කරපු ගමන් කිසිම සොෆ්ට්වෙයාර් එකක් ඉන්ස්ටෝල් නොකර වයර්ලස් මවුස් එකේ battery status පෙන්නුවාම මට පුදුමත් හිතුනා.


September 24, 2013

Java EE 7 Essentials

Java is one of my favorite languages. Long time ago I learnt Java EE. And this book polished that knowledge I had. This books covers from servlets to EJBs, SOAP web services and many more things. But I should highlight one important thing. If you really don't know anything about Java EE, this is not for you. But if you are Java EE 6 Guru or you know something about Java EE, This is written for you. 

For Guru's this will explain new feature with good examples. And that example is enough to understand the new feature. Although this book has 300 pages, it is worth more than that. In a way this book deserves as a reference book. When you need to find something new you can just turn some pages and find the thing what you are looking about Java EE. There would be nice brief examples to help you to understand the topic you are looking for.

This is a good book. I like it. Here is the link to buy this book : http://shop.oreilly.com/product/0636920030614.do

September 22, 2013

Installing Cisco Packet Tracer 6.0.1 on Ubuntu 13.04/12.04 (64-Bit)

I was watching some CBT Nugget Tutorials and then I wanted to work with Cisco Routers. But I don't have any Cisco device. Then I downloaded Cisco Packet Tracer from a torrent(TPB the Pirate Bay).

If you want to install Cisco Packet Trace 6.0.1 you have to download "Cisco Packet Tracer 6.0.1 for Linux - Ubuntu installation (no tutorials).bin" file. This name is too long for me. Then I renamed it to "cp.bin".

Then take a terminal window and change directory to the place where you downloaded installation file. Type following commands:

chmod +x cp.bin

./cp.bin


Then press space bar to scroll down "EULA". And press "y". Then Press "Enter" key. Setup will prompt for root password, Please enter it. You will successfully install Cisco Packet Tracer, but if you are going to run it, you will get nothing. That is because libraries you want to run this on 64 bit Ubuntu version are not installed. You have to install them. To install those 32-bit libraries type following command on your terminal.

sudo apt-get install ia32-libs-gtk


After installing those libraries, you are good to go! You can enjoy Packet Tracer 6.0.1 on Ubuntu 13.04 64bit.

PS: I tested this on Ubuntu 12.04 64bit also. This works! This should work on 12.10 as well, but I couldn't test it.

If you are looking for "Installing Cisco Packet Tracer 6.0.1 on Ubuntu 13.10 (64-Bit)"

September 17, 2013

OneNote app එකක් Google Play එකේ

ඇත්තටම දැන් හැම සමාගමක්ම වගේ ලොකු උනන්දුවක් දක්වන්නේ මොබයිල් ඇප්ස් මොබයිල් ඩිවයිසස් ගැන. ඒ අතරේ ඇන්ඩ්‍රොයිඩ් කියන්නේ ගොඩක් හොද වෙලදපලේ ප්‍රමුඛ මෙහෙයුම් පද්ධතියක් ඒත් මේක හදන්නේ Google එකෙන්.

OneNote කියන්නේ මම කැමතිම සොෆ්ට්වෙයා එකක්. ඇත්තටම මේක Evernote වගේ. හොදිට අපිට අවශ්‍ය නෝට්, ලිස්ට් හැම දේම ලේසියෙන් හදාගන්න පුලුවන්. එත් මේක ලිනක්ස් වල දාන්න බැ. එවෙනු වට පාවිච්චි කරන්න වෙන්නේ වෙබ් බේස් සංස්කරනය. එතකොට ගොඩක් දේවල් සිමා වෙනවා. 


ඒත් මේ අලුත් නිව්ස් එකේ තියෙන්නේ OneNote ඇප් එකක් ඇන්ඩ්‍රොයිඩ් ඩිවයිසස් වලට තියනවා කියලා. මේ ඇප් එක රිලිස් කරලා තියෙන්නේ 16 වැනදා. දැන් ඇත්තටම අපි පාවිච්චි කරන ඩිවයිස් එකේ කම්පැනියට සීමා නොවි හොද මෘදුකාංග පාවිච්චි කරන්න පුලුවන් කාලයක් එන්නයි යන්නේ.

ඇත්තටම මම ගුගල් ප්ලේ එකේ බැලුවා මයික්‍රොසොෆ්ට් මෘදුකාංග හරියටම 10ක් තියනවා. ඒත් මම හිතන්නේ ඒ අතරින් වටිනම ඇප් එක් OneNote කියලා. 

මයික්‍රොසොෆ්ට් අැප්ස්

වන්නෝට් අැප්

August 29, 2013

After renaming I can't access MongoDB collection! :(

Yesterday while I was doing some test for performance team, I renamed a collection. Actually I renamed system.profile into "Profiling_28-08-2013". Then I couldn't access it. I couldn't delete that collection use db.Profiling_28-08-2013.drop(). After renaming MongoDB shell can't access that object. 
1. JavaScript execution failed: ReferenceError: <Part of collection name> is not defined
 2. JavaScript execution failed: SyntaxError: Unexpected token ILLEGAL
 3. <Part of collection name> is not a legal ECMA-262 octal constant (shell):1
 4. SyntaxError: missing ; before statement (shell):1
 5. ReferenceError: <Part of collection name> is not defined (shell):1
Those errors I got by trying combination against MongoDB several versions. First two errors I got from  MongoDB 2.4 and the rest from MongoDB 2.2.

If you have "-" inside your new collection name without any numbers you will get first error. Rest errors you will only get if you have "-08" like parts in your collection names.

MongoDB version 2.4.3 Shell version 2.4.3
MongoDB version 2.2.3 Shell version 2.2.3

Now you may want to get rid from those collections or you may want precious data in those collection. You can use runCommand to rename those collections or to drop them.
db.runCommand({drop:"test.Profiling_28-08-2013"});
db.runCommand({drop:"test.post-old"});
Rename commands you may have to run against the admin database. For rename you may have to use complete namespace. But dropping you can do with just collection name. It is recommended to use namespace when you are dropping.
db.runCommand({ renameCollection: "test.Profiling_28-08-2013", to: "test.newCol"});
db.runCommand({ renameCollection: "test.post-old", to: "test.newCol"});

Data Science for Business

Thanks Foster and Tom for this great book! Since the trend in the industry is towards Big Data and Data Science, I was reading and learning about them. When I found this book, I felt like I found something valuable. And I couldn't wait until start reading this book. This book's introduction says that this book will not be too much technical. That was not a problem because this book's title itself gives a idea that this book is not for technical people. But I'm a technical guy. 

When we are explaining something to our managers, we have to be-careful. Because there is a possibility that  Manager will misunderstand what we are explaining. Such a scenario relevant Data Science, this book will help you for sure. Because this book tells you why you want Data Science and how you use it with business. Then you can use Data Science to gain market share or to increase revenues. If you are a manager, it will be helpful to read and understand your techies. If you are a techie, you should this book to explain how you would be useful to business.

I like this book although it is not too much technical. But that doesn't mean that this book doesn't include any kind of technical stuff. I like this book! Thumbs u
p!

You can buy this book from here

August 12, 2013

Training Kit (Exam 70-463): Implementing a Data Warehouse with Microsoft SQL Server 2012

It's time to learn about Data Warehousing. I was really interested about Data Science. But I really didn't had much idea about Enterprise reporting, or analysis. But this book give much more than Microsoft SQL Server BI tool (Business Intelligence). It helped me to learn basics, some of theories about Data Warehousing. Because I learned things from the scratch, I think this is good for beginners. But you have to have a little bit of SQL Server exposure before.

This is not just a exam prep. This is something more than that. You can learn for exam as well. If you love to start learning Data warehousing with SQL Server, you can go with this book. This book gives you a good start for sure. I love Microsoft Press exam training kits because they have nice questions and explained answers which you can measure yourself.

This book is available as ePub, Mobi, PDF. So you can think about purchasing ebook also.

You can buy this book from here : http://shop.oreilly.com/product/0790145345219.do

July 09, 2013

Google Storage Status

කොච්චර ගුගල්ගේ ස්ටෝරේජ් පාවිච්චි කරලා තියනවද කියලා බලන්න පුලුවන් විදිහේ ඩැෂ්බෝර්ඩ් එකක් ගුගල් විසින් අලුතෙන් ඉදිරි පත් කරලා තියනවා. මේ ඩැෂබෝර්ඩ් එකේන් Gmail, Google Drive, Google+ Photo වලට ඔයාලගේ ගුගල් Quota එකෙන් අරන් තියන ඉඩකඩ ප්‍රමාණය බලන්න පුලුවන්. ලැබිලා තියන ඉඩ මදිනම් තවත් වැඩිපුර ඉඩ මිලදි ගන්නත් පුලුවන්. 

ලින්ක් එක ඩැෂ්බෝර්ඩ් එකට - https://www.google.com/settings/storage/summary/

July 08, 2013

Arduino + Raspberry Pi = UDOO

මම වැඩිය ඉලෙක්ට්‍රොන්ක් දේවල් ගැන දන්නේ නැති වුනත් මට මේ UDOO ගැන යාලුවෙක් තමා කිව්වේ. ඉලෙක්ටොනික්, PIC වලට කැමති අයට හොද නිෂ්පාදනයක් මේක. මේ විඩියෝ එකෙන් දැනගන්න පුලුවන් වෙයි 
 Kickstarter එකේ $27,000 එකතු කරන්න පටන් ගත්තත් මේ ව්‍යාපෘතිය කරන්න $641,614 එකතු කරලා තමා නතර කලේ. දැන් මේ UDOO එක Pre-order කරන්න පුලුවන්. $99, $109, $129 යන එක එක ගනන් වලින් එක එක ෆිචර්ස් එකක් UDOO ලබා ගන්න පුලුවන් හැබැයි දැනට ලංකාවට නම් Shipping නැ මම හිතන විදිහට.

වැඩි විස්තර - http://www.udoo.org/
මිල ගන්න බලන්න - http://shop.udoo.org/

July 05, 2013

Ubuntu Pre-installed Dell Laptops

Recently I went to Unity Plaza to buy a laptop for one of my friends who is going to university. So she doesn't wanted a computer with high specs. She just wanted to surf and do her day to day stuffs with laptop. Because of that I was looking for a Core i3 without dedicated VGA but little bit more ram. Spec was like below as I remember,

  • Core i3 2.4GHz
  • 4GB RAM
  • 500GB HDD
  • Ubuntu Pre Installed
And Laptop's price was around 60,000 LKR. But last option is the one which makes it special for me. Most of the laptops which where in Unity Plaza was pre-installed with Windows 8, Ubuntu or Windows 7. But most of them comes with Ubuntu. That is a good sign for Ubuntu. But it was Ubuntu 11.10 not at least 12.04. But the guy in shop asked that they can installed Windows 8 or Windows 7 trial version. And then he told me, "You can crack it and use!". Some how my friend is not much techie. But because of Virus problem she agreed to work with Ubuntu. So I'm happy a lot. I promoted Ubuntu to a new user. If she uses Ubuntu forever, Wow that's great! 

Below laptops appearance is 100% same to the laptop my friend purchased. But it was Core i3 not i5.

Ubuntu Logo On Laptop

June 13, 2013

Do you want unlimited history in Linux Terminal?

History in Linux terminal is very usefull if you get used to it. If you have to ssh long hostname, or long  file paths you don't need to type them again and again. You can just grep your history and rip what you want like this.

Lets say I want my ssh commands I want to get.
history | grep ssh
perhaps may be smbclient commands
history | greb smbclient
By default in Ubuntu Linux History size is 2000 commands or some thing like that. That will limit you from accessing your all commands. Then you may feel sick of using history. Solution for that is making you linux terminal history unlimited. Those days disk space is not much concern so you can save your all the history in single file without any problem. For 7000 commands it will not take half of a Mega Byte at least. Lets see how to make this history unlimited.

1. Take a terminal and type below command.
gedit ~/.bashrc
or
vi ~/.bashrc
2. Then find  below lines from gedit or vi
HISTFILESIZE=2000 
HISTSIZE=2000 
3. Change delete the number infront of equal.
HISTFILESIZE= 
HISTSIZE=
4. Save it.
5. Close and open a terminal again.

June 11, 2013

Change default keyspace of Titan DB on Cassandra

Long time ago I have posted about how to use Titan with Cassandra. But it will only use a database called "titan". Sometimes you may want to use two different databases in Cassandra backend. In that case we have to use Cassandra Specific Configurations.


To change the database(I'm sorry I have used the word database instead of keyspace.), I'll change storage.keyspace. But this is not a modifiable setting. That means once you have used one value for a graph, you can't change it next time when you login. This is how they mention about it.

It is very important to note that some configuration options should NEVER be modified after the TitanGraph is first initialized. Doing so may corrupt the graph or lead to unexpected behavior.-- https://github.com/thinkaurelius/titan/wiki/Graph-Configuration
I'll give code how to connect to a Titan DB with different keyspace(database). First go to cassandra bin and run.
Linux:
bash cassandra

Windows:
cassandra.bat

Then take gremlin from titan bin.

Linux:
bash gremlin.sh
Windows:
gremlin.bat
Then you have to configure storage backend. for that use following commands on gremlin.
cnf = new BaseConfiguration();
cnf.setProperty('storage.backend','cassandra');
cnf.setProperty('storage.hostname','127.0.0.1');
cnf.setProperty('storage.keyspace','graph1');
g = TitanFactory.open(cnf);
 In this case I have used Cassandra Local host instance. And the keyspace that I'm going to use with graph database is "graph1". You don't need to get limited to one keyspace on one instance!

Those two links will help you if you are going to try Titan for the first time!
Enjoy Graphs!

What is this NoSQL?

Day by day NoSQL databases are releasing their new versions of their databases. But my favorite MongoDB has forgotten its purpose. And day by day the I find a limitation of NoSQL databases. Somehow NoSQL is not for everything. But in this way it seems like, it is not good for anything. I mean the MongoDB. Today I was reading about Security issues of MongoDB. But I couldn't find a problem in MongoDB. Because all those problems will come if we are going to use dynamic like queries or string JSON parsers.
I'm in a kind of a disappointment about NoSQL databases.

May 19, 2013

How I feel it?

For the first time in my life, I got a chance today to fly. So I on boarded from Colombo. And now I'm at Dubai Airport. This is like a dream to me. And the experience, I'm facing is really cool. Although I didn't feel nervous about process in Airport, I was and I am very careful because this is just me travelling alone. I'm very happy to post a blog post away from SL. And I should be thankful to everyone who helped me on my journey. And long way to go to also. I just walked around everywhere I can. I don't know why I feel some kind of a relax.


Thank you Preethi, Shamil, Bhanu, Dinesh and everyone else who helped me!

May 14, 2013

පලවෙනි MongoDB User Group Meetup එක

පහුගිය මාස කිහිපයම MongoDB ගැන උනන්දුවෙන් තමා හිටියේ. ගොඩක් මොන්ගෝඩිබි සයිට්ස් පොත් එක්ක තමා කාලය ගත කලේ. ඉතින් ඔහොම එක එක දේවල් හොය හොයා යනකොට මට හම්බුනා Colombo MongoDB User Group Facebook Group එක. අපේ ඔෆිස් එකේ කෙනෙක් තමා මට මේ යුසර් group එක ගැන කිව්වේ. කොහොම කොහොම හරි Ensiz ආයතනයේ අනුග්‍රහයෙන් මැයි 3 වෙනිදා මොන්ගොඩිබි පලවෙනි මීට්අප් එක තිබුනා. 

මට අවස්ථාවක් ලැබුනා මොන්ගොඩිබි පාවිච්චි කරන අදුර ගන්න ඒවගේම අත්දැකිම් බෙදා ගන්න. මේ අවස්ථාව ලබා දුන්න Ensiz ආයතනයට ස්තුති වන්ත වෙනවා!

User Group එකට ලින්ක් එක:
http://www.facebook.com/groups/490378190986291/?fref=ts

Readme.lk පෝස්ට් එක:
http://readme.lk/the-official-mongodb-colombo-user-group-meetup/






Google IO Extended Event Colombo 2013

මට මේ ගැන ඊයේ දැනගන්න ලැබුනේ අපේ ඔෆිස් එකේ කෙනෙක්ගෙන්. ටෙක්කතා වැඩසටහනෙනුත් ගුගල් IO ගැන කතා කරලා තිබුනා. ඒන ඇත්තටම තියෙන්නේ San Francisco වල වුනත් අපිටත් මේ පාර සහාභාගි වෙන්න අවස්ථාවක් උදා වෙලා තියනවා. පහල තියන ලින්ක් එකෙන් පුලුවන් වැඩි විස්තර දැනගන්න.  


ReadMe.lk link එක

ඒවගේම මේ Event එකත් මට වැදගත් එකක්. 


ReadMe.lk link එක

May 03, 2013

Using same key twice in MongoDB

In MongoDB course one of my colleague has run a query with two occurrences of same key. Then I thought query will fail on validation. But the way that MongoDB behaves is different on this scenario.

> db.test.insert ({name:1})
> db.test.insert ({name:2})
> db.test.insert ({name:3})
> db.test.insert ({name:4})
> db.test.find({name:1,name:2})
{ "_id" : ObjectId("518342a1f193f1de8aef117e"), "name" : 2 }
> db.test.find({name:3,name:1})
{ "_id" : ObjectId("5183429ef193f1de8aef117d"), "name" : 1 }

Then I ran some insert statements.

> db.test.insert ({name:"Dedunu",name:"Dinesh"})
> db.test.find()
{ "_id" : ObjectId("51833fabeadc78fbf0f7232d"), "name" : "Dinesh" }

I think this behavior is inherited from JavaScript. 

April 06, 2013

Run query on all databases all tables at once

When I was writing previous post, I was thinking about single line statement to disable all the triggers in SQL Server instance. But after that I found a way to how to do this. Those queries may looks like confusing.

Below query will print all the names of tables in all the databases of SQL Server instance.

EXEC sp_MSforeachdb 'USE [?] EXEC sp_MSforeachtable ''PRINT ''''/'''''',N''/'' '

But the problem here is you have so many ‘ here. And if you want to disable all the triggers on all the databases you can use below query.

EXEC sp_MSforeachdb 'USE [?] EXEC sp_MSforeachtable ''ALTER TABLE / DISABLE TRIGGER ALL'',N''/'' '

This query will disable all the triggers in you SQL Server Instance. But this alter statement will run on temp database’s tables also. In master and msdb you don’t need to worry because all of their tables are System tables. But temp database’s tables are user tables. So that is also not a much worry.


Enjoy SQL Server !

How to run a query on all Tables?

In some cases people need to run some queries against all the databases in their SQL Server instance. Something very very useful for administrators. Lets say somebody want to give read permission on all tables he can use this sp_MSforeachdb
stored procedure.

But what I’m going to tell in this post is not about it. I’m going to talk about sp_MSforeachtable. Let’s say somebody want to disable all the triggers of one database. Then you can use a Script like below.

USE AdventureWorks2012
GO

EXEC
sp_MSforeachtable 'ALTER TABLE ? DISABLE TRIGGER ALL'
GO

But this command will not run on system tables. This is how I confirmed it.

USE AdventureWorks2012
GO

EXEC
sp_MSforeachtable 'PRINT ''?'''
GO
You can see when you run this query on AdventureWorks database, it will print only user tables. Not on system table of that database.

April 04, 2013

Graph Database පොතක්

graphdatabases_v31

නොම්ලේ ඉගෙන ගන්න අවස්ථාවක්! දැන් ඉතින් ඩේටාබේස් කරන අයටත් ඩිවලොපර්ස් ලටත් NoSQL ඩේටාබේස් ගැන ඇහෙන්න පටන් අරගෙන තියෙන්නේ. ඉතින් මම මේ දවස් වල වැඩියක් ඉගෙන ගන්නේ MongoDB Cassandra Titan(GraphDB) වගේ ඩේටාබේස් ගැන. ඉතින් මේ Graph Database වලින් සමහර බිස්නස් වලට ගොඩක් ලේසියෙන් සොෆ්ට්වෙයාර් හදන්න එහෙමත් පුලුවන්.

Neo4J කියෙන්නේ ඒවගේ Graph Database එකක්. ඉතින් මේ කම්පැනියෙන් නොමිලේ Graph Database ගැන පොතක් ඩවින්ලෝඩි කරගන්න දෙනවා. ඔයාලත් කැමතිනම් ඩව්න්ලෝඩ් කරගෙන කියවලා බලන්න.

http://graphdatabases.com/

April 03, 2013

Free Graph Database Book!

Hey, Do you like to get to know about Graph Database. Then this is for you. Neo4J is giving a Graph Database Book for free. This is a very good opportunity to people who wants to learn about Graph databases. Please don’t miss this!

http://www.neo4j.com/learn/

Enjoy your graph database book!!!

April 02, 2013

MongoDB IDE

I’m using MongoDB for about 6 months. And some guys asked about a IDE. (Basically a GUI tool for MongoDB) At that time there was only one usable GUI Tool. And it is MongoVUE. It is also painful one. So I gave it up. And now I’m  used to MongoDB shell. And I can do everything in MongoDB shell.

But for Developers and QAs to get to know whether their applications are running properly, they need to check MongoDB instances. For them using MongoDB Shell is some thing painful.

MonjaDB

But recently from MongoDB Java Developer course, I got to know about MonjaDB. MonjaDB is a plugin to a Eclipse IDE. And it is really cool IDE. This one is available on any platform where Eclipse is available.

http://marketplace.eclipse.org/content/monjadb#.UVrrrRxHJCY

http://www.jumperz.net/index.php?i=2&a=0&b=9

RoboMongo

This one I just saw one of my colleagues is going to try. This one is not a plugin. And this one also awesome tool. But only available on Macs and Windows. RoboMongo is more into DBAs side. And it supports MongoDB shell as well. And RoboMongo is a combination of set of products. And it supports Intellisense like thing for MongoDB commands

http://www.robomongo.org/ 

Enjoy MongoDB !!!

March 27, 2013

Indexes on Views

I tried to create a Index on View. Then SQL Server said I have to alter that index as a schema bound view. Then I created Schema Bound View.

USE AdventureWorks2012
GO

CREATE VIEW
[dbo].[vHR]
WITH SCHEMABINDING
AS
SELECT
BusinessEntityID AS A,
NationalIDNumber AS B,
LoginID AS C
FROM HumanResources.Employee
GO

Then I created Index on that View.

CREATE UNIQUE CLUSTERED INDEX UCI_vHR ON vHR(A,B)
GO

Then after that I altered index. And my index got disappeared suddenly.

ALTER VIEW [dbo].[vHR] 
WITH SCHEMABINDING
AS
SELECT
BusinessEntityID AS A,
NationalIDNumber AS B
FROM HumanResources.Employee
GO

Then I ran below query to confirm that index got disappeared forever.

SELECT * FROM sys.indexes WHERE name = 'UCI_vHR'

I got nothing as result Sad smile. As soon as I figured this out, I hope to write about this again.

March 21, 2013

Install MongoDB on Windows

Installing MongoDB on windows. OOps. What I'm going to post about is not how to install MongoDB on Windows. Because It is not a normal installation process which you have select path like that. So this is about how to run MongoDB service on Windows. That's it. 

One of my cousin's friends has asked for this post, hence I'm posting this. But long time ago I posted about how to install MongoDB as windows service. It is bit different.

So you can find the way to install MongoDB on windows from official link also.

  1. First of all you have to download MongoDB binary which is suitable for your processor architecture. I mean 32bit or 64bit.
  2. Then extract it to C: drive. You can select  any drive or any folder. I post this for beginners, because its easy to use C: drive.
  3. And then create a following folders in C: drive. You don't need to worry about capital simple letters. ;)
      • c:\data
      • c:\data\db
  4. Then open MongoDB folder and go to bin
  5. After that you can see few exe files. Please run mongod.exe
If it disappears please follow instructions carefully again. If you can see a black window on screen you have done it perfectly, Now your MongoDB is working properly!

March 18, 2013

MongoDB Sri Lanka User Group

Wow! It's a great pleasure to hear that we have a MongoDB User Group in Sri Lanka. I just sent a request  to join to MongoDB User Group page in facebook. I really worry about got so long time to join the community of MongoDB.

You can also join to Colombo MongoDB User Group from this link.

I really didn't know there are much more people in Sri Lanka, who is interested in MongoDB. I hope to join community and enjoy MongODB!!!

March 14, 2013

Do you want a colorful terminal

After moving to Ubuntu, I was looking for a way to make my terminal colorful. Because I really don't like mono color environments. Then I was searching "Enable Colors in Terminal". Then I found a very easy way to give colors to my odd terminal.
  1. Take a terminal window. Press Ctrl + Alt + T (We are going to give colors to the terminal from terminal.)
  2. Then type below command.  vi ~/.bashrc
  3. Then you will have vi editor. Then Press 'i' to start inserting.
  4. Find and remove # infront of below line or add it to that file. force_color_prompt=yes
  5. Then press Esc.
  6. Then type :wq
  7. And close your terminal and take a new terminal. 
Now you got colors!

March 13, 2013

Yes, It's our fault

Today our architect sent a mail to team with two links of blog posts. With the coming of NoSQL that developers think that they really don't need DBAs who objects each and every possible easiest way to solve the solution. And the other one is a post of Grant, which says that fault is on our hand.

When a DBA getting mature and having lot of experiences what happens is, they are trying to avoid problems which can occur in future. It's like cutting wings of developer birds. Then developers are getting into angry developers.


When we have up and running databases, DBAs know how difficult to make a change, how difficult to let developers to go home early. That's the way that developers looks at DBAs. When developers want to do a change they do all the designs and then send all queries to DBAs. And then say "Please now take care of it, it's your baby now!". 

With the time, angry devs are finding out a solution to get rid from DBAs mails. Angry developers are trying to destroy DBAs beautiful dreams with the help of NoSQL databases. But finally what will really happen is they will make angry stakeholders if they really don't know what is they are using.

Those NoSQL databases are like non-tested missiles. They may work very very well and achieve the target, or else that may fall into your side and may destroy your whole career life. NoSQL databases are babies. We should understand it. When we say that this is too much risky, people things that we don't like to change what we know or we are obsolete. 

And Big companies are looking forward for new technologies and new things. And developers most of the time they also hate new things. But they want to bypass permission stage like Grant says. Then they are going  with this awesome NoSQL databases. 

Myself and Shamil had so many discussions about the change that is comming towards us. What will happen to DevDBAs career. Some times NoSQL may be a another thing like ORDBMS. Perhaps it may be a relational like database. Some how part of this fault is on our hand because we are trying to deploy best things to production. And the other part of this fault is also on our hand because we are trying to defend the production.

For developer "Table joins", "WHERE clauses" are just another line like a declaring a variable on their programming language. But for DBAs its a table scan, its a table lock which hurts them and their bonuses.  Developers are not going to understand that their queries should work on production. That's why DBAs are coming to office.With DevOps some times this problem may solve in a good way. Because developers may have part of baby sitting with DevOps. Then they may start to realize how much we have saved their bonus. :)

March 12, 2013

Install MongoDB on Ubuntu using deb file

WoW! This is my first video that I have created. Today, right now I uploaded it to YouTube and I hope to create few more videos also. It seems funny!
So this videos describes how to install MongoDB on Ubuntu or on any debian using deb file(deb package). And you don't need to use apt-get install command to do this. In this method every configuration file creates on system without any matter and you don't need to create a user account for MongoDB also. 

Go MonGO!

March 10, 2013

Login to a Linux box

After the first day of linux training, I got IP, Username and Password for a linux box. But I really didn't know how to log in to a linux box with Credentials. Then I asked from few guys, unfortunately they also didn't know what is the way to log in to linux box.

Then I asked from the guy who was next to me. How to log in to this box, then he told you have to use putty for this. That's my first day of using putty. But I really didn't know that I'm using SSH. I'm writing this blog post because there may be people who is like me don't know how to log in to a Linux box. And Google here and there for it.

  1. So first what you need to do is you have to download putty. For that you can Google 'putty' then you can download it.Here's the link. http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
  2. Then run it!
  3. You will have a window like below. Enter the IP or host name on text box.
  1. Then Click Open.
  2. For the first time they should be a long message with Yes, No Cancel Buttons. Please press "Yes"
  3. Then Putty will ask for user name. Type user name and press enter.
  4. Then Putty prompts for password. Please type password and press enter.
  5. Here you go !!!! Now you have successfully logged in to your linux box using putty, enjoy shell!!! 

March 09, 2013

Do you like to surf with mobile devices?

I'm pretty much interested about Ubuntu Touch those days. Basically I'm interested about Ubuntu Mobile devices which is going to arrive to market in near future. To be frank I should say that, I'm interested in those devices because they can change the future of Ubuntu. But in this blog post what I'm going to discuss is not about Ubuntu Mobile devices. I'm going to talk about generic mobile devices.

With the arrival of smart phones, tablets, PDAs, EDAs people thought about buying a tablet instead of computers. Then they try to install whole lots of things into those small devices which has not much computing capability. Then after that they try to surf, try to send mails and try to do so many things with this devices. Then battery and the capacity of those devices avoids people of doing things. Then what happens is people starts to blame on poor mobile devices. :|

But my view is mobile devices are mobile devices, They are not laptops. Even the laptops can't perform like Desktops, how can you expect it from mobile devices. Although we come up with new technologies to save the power, or increase the battery life such things, you can't make mobile device a computer. You can't use it like a boss. You just have small screen to tap here and there. For me that is not going to work. 



So my recommendation is buy a computer when you need a computer. Buy a smart phone when you need a smart phone. Otherwise if you buy a smart phone when you need a computer, most probably you may have to give up smart phone and computer both! ;)

Ubuntu ටැබ්ලට්

Ubuntu Tablet එක Pre-Order කරන නිව්ස් එකක් omgubuntu එකේ දාලා තිබුනා. ඇත්තටම මමත් සයිට් එකේ එහෙට මෙහෙට ගිහින් බැලුවම මට හිතුනේ මේක බොරුවක් කියලා. $299 තමයි මේකේ දාලා තිබුනේ ඒවගේම ගාන වැඩිවෙන්නත් පුලුවන් කියලා කියනවා. කොහොම වුනත් සයිට් එකේ ෆිනිෂිං එක එහෙම බැලුවාම කාගේ හරි තනි කෙනෙක්ගේ සයිට් එකක් වගේ. ඒත් ප්‍රශ්නයකට තියෙන්නේ omgubuntu සයිට් එකෙත් මේක ගැන පෝස්ට් එකක් දාපු එක. ටැබ්ලට් සයිට් එකේ ලින්ක් එක පහල තියෙන්නේ.





මේ ටැබ්ලට් එක ගැන කතාව මෙහෙම යද්දි hp එකෙන් Pavilion 20 කියලා මොඩල් එකක් Ubuntu එක්ක මාර්කට් එකට දානවලු. ඇත්තටම මේක උබුන්ටු වල හෙට දවස ටිකක් හොද කරන වැඩක් වෙන්න පුලුවන්. මේ කම්පුටරය ගැන විස්තර මෙතනින් බලන්න.





March 05, 2013

Gmail පාව්ච්චි කරලා Scroogled වෙලාද?

මම මේ ලගකදි දැක්ක ලොකුම මඩ පාර තමා මේක. Microsoft එකෙන් Gmail වලට විරුද්ධව කරගෙන යන Campaign එකක් තමා Scroogled.com කියන්නේ. මේයාලා කියන්නේ Gmail ads ඩිස්ප්ලේ කරන්න අපේ හැම ඊමේල් එකක්ම කියවනවා කියන එක. මේක ලංකාවේ අයට ලොකු ප්‍රශ්නයක් නෑ. මොකද ලංකාවේ අයගේ (බහුතරය) Internet එකේ Privacy ගැන හිතන්නේ නැ. ඒත් US වල අයගෙන් 89% දන්නේ නෑලු මේ ඊමේල් ගුගල් එකෙන් කියවන වැඩේ. 88% කියන්නේ මේ ඊමේල් කියවන වැඩේ නරකයි කියලාලු. 
කොහොම වුනත් මේ scroogled සයිට් එකේ ජීමේල් එකේ වැරදි කියන ගමන් කරන්නේ, Outlook.com එක මාර්කට් කරන එක. අවුට්ලුක් කාගෙවත් මේල් කියවන්නේ නැලු ඇඩ්ස් ඩිස්ප්ලේ කරන්න කියලා කියනවා. කොහොමත් මේක මයික්‍රෝසෝෆ්ට් එකෙන් ගුගල් එකට කෙලින්ම ගහන මඩ පාරක්. ඒවගේම මේකේ ඇත්තකුත් තියනවා. ඒත් අපි Gmail එකවුන්ට් එකක් හදද්දි සමහර විට මේ කියවන දේවල් වලට කැමති වෙනවා ඇති (ඇති කියන්නේ කව්රුත් Privacy and Policy කියවන්නේ නැනේ). 

March 04, 2013

Evernote එකව්න්ට් තියනවා නම් Password Reset කරන්න

Evernote ගැන ගොඩක් අය දන්නවා ඇති. ගොඩක් ප්‍රසිද්ධ සේවාවක් තමා එවර්නෝට්. එවර්නොට් වල පාස්වර්ඩ් කව්රුහර් ඇක්සස් කරලා තියනවා කියලා. ඒක හන්දා හැමෝම පාස්වර්ඩ් මාරු කරන්න කියලා එවර් නෝට් එකේ නිවේදනයක් කරලා තියනවා. ඩේටා කිසිම දෙයකට හානියක් වෙලා නැලු. ඒවගේම පාස්වර්ඩ් හැෂ් කරලා salt කරලා තිබුනලු. ඒක හන්දා ලේසි වෙන එකකුත් නැලු බ්රේක් කරන්න. කෝකටත් ඔයාලගේ අකව්න්ට් තියනවා නම් පාස්වර්ඩ් මාරු කරන්න. ඒවගේම අනික් අකව්න්ට් වලත් ඒ පාස්වර්ඩ් එක තිබුනා නම් මාරු කරන්න.

http://blog.evernote.com/blog/2013/03/02/security-notice-service-wide-password-reset/

February 27, 2013

What I love in Outlook 2013

I installed Microsoft Office 2013 few weeks ago. So in Office as usual there are few enhancement and new things. But I should write a blog post about what I love in Office 2013. It is about Outlook. In Outlook they have added new feature to text area which makes us feel that we are typing faster. When we type cursor is not jumping it is wiping through the text.

That feature is awesome one. I hope that will be implemented in Word and other text boxes in Windows in future. Or at least give a option to users to Enable/Disable it. I really don't bother about those effects in software. But this one I can't ignore. I love it. I don't use G mail because of this. I use Outlook 2013.

And if I don't mention about LinkedIn integration, that's not cool. So they have given a facility to connect LinkedIn profile with Outlook. It syncs all the contacts from LinkedIn and use their faces on contacts. I really love it too.

February 25, 2013

Installing RedHat Enterprise Linux from USB Drive

Recently I downloaded Red Hat Enterprise Linux 6.0 to install on my home server. And I'm a person who haven't used Optical Drive for ages. On my laptop even DVD Drive doesn't work properly. So every time I use USB Drive (Pen Drive) to install any operating system because my server doesn't have a optical drive. Although I call it a server it is just a machine without CD Rom and blah blah.

Then as usually I wanted to make Red Hat ISO bootable. Then I used UNetBootin to make my USB drive bootable. But I got mounting error in installation when I was going to format hard drive. So it never happened with Ubuntu for me. Then I searched here and there to find a method to install RHEL. Then I found a link to iso2usb. It worked bit far away from that place. But it just installed minimal Linux server with out any GUI. There was no any option for it on Installation Wizard. Installation Wizard was GUI one although.

The I used fedora live usb create. It didn't work properly. Then I copied all the contents of DVD into my server machine and added a repo entry for yum to DVD packages. :)

February 23, 2013

NoSQL Discipline

Long time ago there were very few popular databases. Because starting a DBMS was not easy with relational database model. But now with NoSQL database management systems are getting cloned. Numbers of database management systems are growing exponentially.

Now the fashion is, if you are fed up with DBMS which is existing you can write a new one and be a master of it. No matter what ever it is. It may be just a API to reading from or writing to text file. But to be frank there are few good NoSQL databases. But most of them are clones. Clones give nothing to the industry, nothing to the growth of data science.

Data is something valuable to everyone. All of our IT professionals depend on Data. So it is not a joke to play with those useless NoSQL databases. :)

February 19, 2013

Juju

Did you know about JuJu?

Juju is a new solution for Developer's to configure their development environments very very faster than it was. Developers don't need to be a expert on each and every service and how to configure each and service. Juju has distilled knowledge on each and every product like MongoDB, Cassandra or Hadoop. Creating environment's (linux) becomes more and more easier with juju.

Juju is still in development and not good for real production. But as I feel it is going to play a big role on the industry like Hadoop. Most of the businesses are looking into DevOps model. So juju helps DevOps as well. 

Juju is another work from african language like Ubuntu. It means magic. Juju is magic. Actually magic is going to happen! Enjoy JuJu!

February 09, 2013

උබුන්ටු වල root User Account එක Activate කරන හැටි

මට උබුන්ටු ඉන්ස්ටෝල් කලාට පස්සේ ඕන වුනා root යුසර්ව ඇක්ටිවේට් කරන්න. උබුන්ටු වල root ඩිඇක්ට්වේට් වෙලා තමා තියෙන්නේ හැම තිස්සේම. ඒක හන්දා root වෙනුවට පාවිච්චි කරන්න වෙන්නේ sudo කමාන්ඩ් එක. 

su root වැඩ කරන්නේ නැ මොකද root ඩිඇක්වේට් හන්දා. root ඇක්ටිවේට් කරන්න root ගේ පාස්වර්ඩ් එක මාරු කලාම හරි. ඒකට පහල තියන කමාන්ඩ් එක ටයිප් කරන්න ටර්ම්නල් එක අරගෙන (Ctrl+T).

sudo passwd root

ඊට පස්සේ ඇඩ්ම්න් යුසර්ගෙ පාස්වර්ඩ් එක ටයිප් කරන්න. ඊට පස්සේ root දාන පාස්වර්ඩ් එක දෙපාරක් ටයිප් කරන්න. දැන් root activate වෙලා තියෙන්නේ.

su root ගහලා චෙක් කරලා බලන්න.

Are you looking to move to Ubuntu?

When you are going to move from Windows to Ubuntu you should be aware about versions to move. So If you are looking to move to Ubuntu you should select LTS (Long Term Support) version. Currently latest Ubuntu LTS version is 12.04. Most of the times LTSs are more stable than other versions.
Also now Firefox is getting other side. So you should install Google-Chrome. Otherwise with Firefox you will fed-up with Ubuntu. It's better if you can use Google Docs more than Libre office. Because Personally I don't like to use LibreOffice. 
Go Ubuntu!

January 24, 2013

උබුන්ටු වල Close Button වමෙන් දකුනට ගෙනියන හැටි

මම මේ ලගදි blog කියව කියව යද්දි දැක්කා Linux Mint ගැන පෝස්ට් එකක්. ඉතින් ඒකේ කියලා තිබුනා සමහරු Close Button එක දැක්කාම අව්ල් වෙනවා කියලා. ඉතින් සමාන්‍යෙයන් අපි පුරුදු තැනට Close Button එක ගන්න හැටි තමා මම මේ පෝස්ට් එකෙන් කියන්න හදන්නේ.

පලවෙනියට මේක ලේසියෙන් කරන්න නම් gnome-tweak-tool එක install කරගන්න ඕනේ. Ctrl+Alt+T press කරන්න. ඊට පස්සේ පල්ලෙහා තියන කමාන්ඩ් එක ටයිප් කරන්න.

sudo apt-get install gconf-editor

ඊට පස්සේ පහල තියන කමාන්ඩ් එක ටයිප් කරන්න.

gconf-editor

දැන් එන වින්ඩෝ එකේ / expand කරලා apps/ metacity/ general click කරන්න. ඊට පස්සේ button_layout එකේ Value එක menu:minimize,maximize,close කියලා වෙනස් කරලා. වින්ඩෝ එක ක්ලෝස් කරන්න. ඇප්ලයි වුනේ නැත්තම් රිස්ටාර්ට් කරලා බලන්න.

Screenshot from 2013-01-24 11_44_29

January 23, 2013

Mac OS Mountain Lion on VirtualBox

සෑහෙන කාලයක් මම Mac OS පාවිච්චි කරන්න ආසාවෙන් හිටියත් මට ඇපල් කම්පුටරයක් නැති හන්දා පාවිච්චි කරන්න බැරි වුනා. ඒත් මම දැනන් හිටියේ නෑ සාමාන්‍ය කම්පුටර් වලට Mac OS දාන්න පුලුවන් කියලා. ඉතින් මම දවසක් එහෙ මේහෙ ඉන්ටර්නෙට් එකේ යනකොට දැක්කා Mac OS Virtual Box වල ඉන්ස්ටෝල් කරන කතාවක් ඉතින් මම ඒ පෝස්ට් එකේ තියන විදිහට ට්‍රයි කරලා Mac OS දැම්මා. තාම වැඩි දවසක් නැති හන්දා කියන්න තරම් ලොකු දෙයක් නැ Mac OS ගැන.

ඒත් සරලවම කිව්වොත් යුනික්ස් බේස් හන්දා ලොකු වෙනසක් පේන්නේ නැ මට ලිනක්ස් වගේම තමා ගොඩක් දේවල්. මම ඉන්ස්ටෝල් කලේ Intel DH67CL Motherboard එකක. ඔයාලත් කැමති නම් ට්‍රයි කරලා බලන්න.

http://www.macbreaker.com/2012/07/mountain-lion-virtualbox.html

Mac OS Virtual Machine

For a long time I was suffering because I wanted to use Mac OS. But I didn’t have any apple computer to use it. Also I didn’t try to install Mac OS to Virtual Machine. But after joining Pearson I saw few Apple machines daily. And my eager to use Mac OS got exponentially increased. Then I started to thing about Mac OS Virtual Machine. I had downloaded a genuine Mac OS installation long ago. But it was not a good one to install Mac OS to Virtual. So then I found this article.

http://www.macbreaker.com/2012/07/mountain-lion-virtualbox.html

And I tried with its instruction in little bit different way. I used Ubuntu 12.10 as host operating system. My computer had Core i7 processor with DH67CL motherboard. So I was able to successfully install and run Mac OS Mountain Lion as a Virtual Machine on Ubuntu 12.10 with Oracle VirtualBox.

January 22, 2013

MongoDB – Part 2

මම ඊයේ ලියපු පෝස්ට් එකෙන් මොන්ගෝ ඩිබි ස්ටාර්ට් කරන හැටි. අපි බලමු කොහොමද මොන්ගෝ ඩිබි වල ඩේටාබේස් හදන හැටි ඩේටා සේව් කරන, ඩේටා අරගන්න විදිහ.

හැම දේටම කලින් අපි දැන ගන්න ඕන දෙයක් තමා මොන්ගෝ ඩිබි වල ස්ට්‍රක්චර් එක. මොකද අපි දැනට පුරුදු වෙලා ඉන්න ටේබල් වලට වැඩිය ටිකක් වෙනස් දෙයක් තමා මොන්ගෝ ඩිබි වල තියෙන්නේ.

මොන්ගො ඩිබි වල  Database, Collection, Document කියන තුන අපි දැනගන්න ඕනේ. ඩේටාබේස් එක නම් අපි සමාන්‍යෙයන් දන්න ඩේටාබේස් එකම තමා. කලෙක්ෂන් කියන්නේ ටේබල් වලට සමාන දෙයක්. හැබැයි කලෙක්ෂන් වල හරියටම Schema එකක් නැහැ. Document කියන්නේ රෙකෝඩ් එකක් වගේ දෙයක්.

අපි බලමු ඩේටා බේස් එකක් හදන්නේ කොහොමද කියලා. ඩේටා බේස් එකක් හැදෙන්නේ ඇත්තටම අපි ඒ ඩේටා බේස් එක ඇතුලේ ඩේටා සේව් කලොත් හරි නැත්නම් කලෙක්ෂන් එකක් හරි හැදුවොත් තමා.

use <database name>

අපිට sample කියලා ඩේටාබේස් එකක් හදන්න ඕනේනම් ඉස්සෙල්ලා සිලෙක්ට් කරන්න ඕනේ. ඒකට පහල තියන කමාන්ඩ් එක මොන්ගෝ ඩිබි ෂෙල් එකේ ටයිප් කරන්න ඕනේ. කලින් පෝස්ට් එකේ නතර කරපු තැනින් ඉස්සරහට තමා මම මේ පොස්ට් එක ලියන්නේ.

use sample

ඉහත කමාන්ඩ් එකෙන් අලුත් ඩේටාබේස් එකට මාරු වුනත්. ඒකට අදාල ෆයිල්ස් හැදෙන්නේ නැ. \data\db එක ඇතුලට ගිහින් බැලුවොත් ඔයාලට පෙනෙයි තාම sample කියලා ෆයිල් හැදිලා නෑ කියලා.

කලෙක්ෂන් එකක් හදන්න පහත තියන කමාන්ඩ් එක ටයිප් කරලා එන්ටර් කරන්න.

db.createCollection(“users”);

දැන් ඩේටාබේස් එක හැදිලා ඉවරයි. දැන් අපිට තියෙන්නේ ඩේටා සේව් කරන්න. මේකෙදි ඩේටා සේව් කරන්නේ JSON විදිහට. අපි බලමු සාම්පල් රෙකෝඩ් එකක් සේව් කරලා.

db.users.insert({ name:”Dedunu”, org:”Pearson Education” })

සේව් වුන ඩේටා ආපහු බලන්න පහත කමාන්ඩ් එක එන්ටර් කරන්න.

db.users.find()

අපි තවත් ඩේටා එන්ටර් කරලා බලමු.

db.users.insert({ name:”Angelo”, org:”Softlogic”})

ආපහු db.users.find() කියලා ටයිප් කරලා ඩේටා සේව් වුනාද කියලා චෙක් කරලා බලන්න පුලුවන්.

mongo sample shell

January 21, 2013

MongoDB

මම කලින් පෝස්ට් එකේදි කිව්වා NoSQL ගැන. ඒවගේම මොන්ගෝ ඩිබි කියන්නේ NoSQL ඩේටාබේස් එකක්. ඉතින් මොන්ගො ඩිබි කියන්නේ Document Base ඩේටා බේස් එකක්. අපි දන්න අනික් ඩේටාබේස් හැම එකක් වගේම දත්ත සේව් කරන්නෙ Record හැටියට. ඉතින් මේවායේ ඩේටා ටයිප්ස් තියනවා අලුතෙන් කොලම් ඇඩ් කරද්දි මුලු ටේබල් එකටම බලපානවා ඒවගේ නානප්‍රකාර ගැටලු තියනවා. නමුත් මොන්ගො ඩිබි වල මේවගේ සිමාවල් නැ. මොකද දත්ත සේව් වෙන්නේ Document විදිහට ඒ ඒ Document එකට අදාල කොලම් වගේ දේවල් තියෙන්න පුලුවන්. කිසිම වෙලාවක් Schema එකකට බැදිලා නෑ. මේක ඇත්තටම එක පැත්තකින් පාඩුවක් වුනත් තව පැත්තකින් වාසියක්.

අපි බලමු මොන්ගො ඩිබි එක්ක වින්ඩෝස් වලදි වැඩ කරන්නේ කොහොමද කියලා.

http://www.mongodb.org/downloads

ඉහත තියන සයිට් එකට ගිහින් පලවෙනියට මොන්ගො ඩිබි ඩව්න්ලෝඩ් කරගන්න ඕනේ. හැබැයි මේක අනික් ප්‍රසිද්ද DBMS වගේ ලොකු ඩව්න්ලෝඩ් එකක් නෙමෙයි. 60MB-70MB අතර ප්‍රමාණයක් තමයි ගොඩක් වෙලාවට වෙන්නේ. ඊට පස්සේ අපි කරන්න ඕනේ මේක extract කරන එක.

අපි හිතමු D:\ ඩ්‍රයිව් එකට extract කලා කියලා. දැන් අපි D:\ ඩ්‍රයිව් එකේ හදන්න ඕන ෆෝල්ඩර් වගයක් තියනවා. ඒ තමා පහත තියන ෆෝල්ඩර්.

  • D:\data
  • D:\data\db

මේ ඉහත තියන ෆෝල්ඩර් වල තමා දත්ත සේව් වෙන්නේ. දැන් ඊලගට තියෙන්නේ ඩේටාබේස් සර්වර් එක ස්ටාර්ට් කරන එක. ඒකට mongodb ෆෝල්ඩර් එක ඇතුලේ තියන bin එකේ mongod.exe එක ඩබ්ල් ක්ලික් කරන්න. හරියට ෆෝල්ඩර්ස් හැදුවා නම් ඒ වින්ඩෝ එක ක්ලෝස් නොවි තියනවා.

mongod

MongoDB වලට Connect වෙන විදිහ

මොන්ගො ඩිබි හරියට රන් වෙනවා නම් දැන් අපි කරන්න ඕනේ කනෙක්ට් වෙන එකනේ. ඒකට mongo.exe රන් කරන්න.

mongo

දැන් ඉතින් තියෙන්නේ මොන්ගො ඩිබි එක්ක වැඩ කරන්න. මම ඉස්සරහට තවත් පෝස්ට් එකකින් වැඩ කරන හැටි දාන්නම්.

Big Data සහ NoSQL

මම මේ දවස් වල ගොඩක්ම සර්ච් කරන්නේ ඉගෙන ගන්නේ ඩේටාබේස් ගැන. මොකද මම වැඩ කරන්නේ ඩේටාබේස් ටීම් එකක හන්දා. දැනට ලෝකේ තියන ඩේටාබේස් සිස්ටම් වල වෙනසක් වෙන්න යනවා කියන එක තමයි හැමෝගෙම අදහස. මොකද මේ Big Data නිසා.

මෙච්චර කාලයක් Relational Database තමා හැම සිස්ටම් එකක්ම වාගේ පාවිච්චි කලේ. ඒත් දැන් අලුතෙන් එන ගොඩක් සිස්ටම් වලට Relational Database පාවිච්චි කරන එක අඩු වෙන්න වගේ යන්නේ. මොකද මේ ඩේටාබේස් වලින් ගොඩක් අඩු කාර්යක්ෂමතාවයක් තමා ලැබෙන්නේ. ඒත් මේ NoSQL ඩේටාබේසස් ඔක්කෝම වීශේෂ කාර්යකටම තමා නිර්මාණය කරලා තියෙන්නේ. ඒ ඒ  NoSQL ඩේටාබේස් එකිනෙකට වෙනස් කටයුතු වලට පාවිච්චි කරන්න තමා නිර්මාණය කරලා තියෙන්නේ.

ඒවාට උදාහරණ කිහිපයක් තමා,

  • MongoDB
  • Cassandra
  • RavenDB
  • TitanDB
  • HBase

සමහර විට මේක පරිගණක පද්ධති වල ලොකු වෙනසකට යොමු කරන දෙයක් වෙන්නත් පුලුවන්

Retrieving data from MongoDB database using PHP

Previous post I wrote about how to install MongoDB driver on PHP when we are using windows. In linux (I mean Ubuntu) there were no issues on installing that. So after that I want to connect to MongoDB to take data.

<!DOCTYPE html>
<html>
    <head>
        <title>MongoDB Connection</title>
    </head>
    <body>
        <?php
        $m = new MongoClient();
       
        $db = $m->phpdb;
       
        $col = $db->pageind;
       
        $rs = $col->find();
       
        foreach ($rs as $rec)
        {
            echo "<a href='" . $rec['url'] . "'>" . $rec['name'] . "</a><br />";
        }
            ?>
    </body>
</html>

Below Code part I inserted between PHP document. This MongoDB server is not running in auth mode. If your MongoDB is running in auth mode and in different ports, you can specify them with connection string. And my database structure was like this.

Database : phpdb

Collection : pageind

Sample document in a database was like below.

{

_id : 1,

name : “Dedunu Blog”,

url : “http://www.dedunu.info/”

}

January 08, 2013

PHP MongoDB Driver not working!

In Semester 3 I have PHP unfortunately not MongoDB. So I was doing PHP practicals while I was doing my office things. So suddenly MongoDB came to my mind. Then I tried to connect to MongoDB with PHP. Although I have already tried with .NET. I never tried MongoDB with PHP. So I installed IIS 8.0 and PHP 5.3.1. 

Then I downloaded the driver from github. Extracted it to C:\Program Files (x86)\PHP\v5.3\ext\. 
I added the entry to php.ini properly. Then I restarted IIS using iisreset. But MongoDB Driver for PHP was not loaded properly. Then I was checking and doing so many things but nothing worked.

Try this way!

1. Download driver from github.

2. Extract zip file.

3. Copy php_mongo-1.3.2RC1-5.3-vc9-nts.dll to C:\Program Files (x86)\PHP\v5.3\ext\. And rename it to php_mongo.dll.

4. Then take properties of php_mongo.dll and unblock executable.
5. Then go to C:\Program Files (x86)\PHP\v5.3\ and open php.ini as Administrator and add below line to end of the file.

extension=php_mongo.dll

6. Then take a command prompt as administrator and run below command.

iisreset

Enjoy MongoDB with PHP!

January 02, 2013

How to setup a replication set in MongoDB?

I just wanted to setup a replication set in MongoDB to check the behavior of MongoDB replica set.
For this demonstration I use MongoDB 2.2.0 and PowerShell 2.0.
First I want to create directories for MongoDB replication instances. I’m going to for a replication set with three nodes. So because of the I need to create there MongoDB data directories.

New-Item -ItemType Directory -Path \data\
New-Item -ItemType Directory -Path \data\repDb1
New-Item -ItemType Directory -Path \data\repDb2
New-Item -ItemType Directory -Path \data\repDb3
New-Item -ItemType Directory -Path \log

Now copy MongoDB Binaries to the drive that you ran above PowerShell commands. Change directory to MongoDB bin. And create three separate configuration files in MongoDB bin folder with notepad or any other plain text editor.
  • config1.cnf
  • config2.cnf
  • config3.cnf
Create config1.cnf file with below content.

logpath=d:\log\log1.txt
dbpath=d:\data\repDb1
port=9991
replSet=samplecluster
rest=true

Create config2.cnf file with below content.

logpath=d:\log\log2.txt
dbpath=d:\data\repDb2
port=9992
replSet=samplecluster
rest=true

Create config3.cnf file with below content.

logpath=d:\log\log3.txt
dbpath=d:\data\repDb3
port=9993
replSet=samplecluster
rest=true

Now we are going to run MongoDB. For that you must go to MongoDB bin folder. And Press Shift and while you pressing shift right click on free area. And select ‘Open command window here’




Now you will get a Command Prompt. Type below three commands on your command prompt.
start mongod –-config config1.cnf
start mongod –-config config2.cnf
start mongod –-config config3.cnf
Now you should login to one of those MongoDB instance to initiate the MongoDB replication set. For that type below command.

mongo localhost:9991
Now you have a MongoDB shell and you can initiate replication set. Type below command to initiate MongoDB replication set.

rs.initiate()
This command will take some time. Don’t worry most of the times its not stuck. Then you have to add other instances to this MongoDB replication set.

rs.add(“localhost:9992”);
rs.add(“localhost:9993”);
This will return { “ok” : 1 }. If it is not please replace your machine name to “localhost”. Now it is done. Your MongoDB replication is up and running!!!

Start Here! Learn HTML5

Another good book for starter from Oreilly. If you don’t know how to save a HTML file with your notepad. You can learn it from this book too. And gradually author moves to advanced topics. Also this book contains CSS.

Author don’t use confusable terminology. So its really cool for novice people. I got addicted when reading first chapter. At last chapter he introduce Microsoft Expression Web. It is also again nice tool to develop web pages. And you can learn best practices of HTML from this book too. For example read below extract.

The nonbreaking space entity &nbsp; is very popular for creating spaces, and in fact,
many WYSIWYG web site creation programs like Microsoft Expression Web and Adobe
Dreamweaver insert them for you when you press the spacebar. Don’t use nonbreaking
spaces instead of good layout techniques, though. For example, if something needs to be
indented a certain amount, use the correct HTML tags and styles for indenting it, don’t just
“space over” with a half-dozen &nbsp; codes.

Those points are emphasized. So this book is a nice book to start your HTML life. There are three appendixes which helps to learn about ‘Designing for Usability’, ‘Designing for Accessibility’ and cool Quick reference. Quick reference was something remarkable to me. It has only two different sections which contains what are the new in HTML5 and what are the thing getting deprecated in HTML5. It’s a smart appendix.

I recommend this book for beginners who wish to begin learn HTML or HTML5 both. Name of this book deserves it 100%!!!

You can buy it from here.

DISTINCT and ORDER BY together

When we are using DISTINCT we can’t use ORDER BY as we want. If you are going to use DISTINCT when you have ORDER BY, all ODER BY attributes should be in SELECT phrase.

USE AdventureWorks2012;

-- Works fine
SELECT
BusinessEntityID
FROM HumanResources.
Employee
ORDER BY BirthDate
;

-- Fails
SELECT DISTINCT
BusinessEntityID
FROM HumanResources.
Employee
ORDER BY BirthDate
;

-- If you are going to sort with
distinct result should consist attribute that you are sorting
SELECT DISTINCT
BusinessEntityID
FROM HumanResources.
Employee
ORDER BY BusinessEntityID
;

Otherwise it fails with following error.

ORDER BY items must appear in the select list if SELECT DISTINCT is specified.