.code { background:#f5f8fa; background-repeat:no-repeat; border: solid #5C7B90; border-width: 1px 1px 1px 20px; color: #000000; font: 13px 'Courier New', Courier, monospace; line-height: 16px; margin: 10px 0 10px 10px; max-height: 200px; min-height: 16px; overflow: auto; padding: 28px 10px 10px; width: 90%; } .code:hover { background-repeat:no-repeat; } .code { background:#f5f8fa; background-repeat:no-repeat; border: solid #5C7B90; border-width: 1px 1px 1px 20px; color: #000000; font: 13px 'Courier New', Courier, monospace; line-height: 16px; margin: 10px 0 10px 10px; min-height: 16px; overflow: auto; padding: 28px 10px 10px; width: 90%; } .code:hover { background-repeat:no-repeat; }

Saturday, September 28, 2019

Lesson O1 - Angular 7



Structure Directives (ngIf  , ngFor , ngSwitch)


ඔයාලා මිට පෙර if else, switch case , for loop මෙන්න මේ වගෙ දෙවල් ටිකක් ගැන  C language  හො java වැනි language වලින් ඉගෙන ගෙන තියනව නම් ඔයාලට මතක ඇති  කියලා මන් හිතනවා. අන්න ඒ  වැඩ ටික කරගන්න තමයි angular වලදි මෙන්න මේ Structural Directives use වෙන්නෙ.


1)   අපි  බලමු ngIf Directive කියන්නෙ මොකද්ද කියලා.


මේකෙදි වෙන්නෙ සරල වැඩක් මොකක්  හරි variable එකක් true උනොත් මේ ngif එක යටතේ තියෙන දෙවල්  වැඩ කරනවා . එහෙම උනේ නැත්නම් ඒ කියන්නෙ false නම් වැඩ කරන්නෙ නෑ . පහත  නිදසුන බැලුවොත් ඔයාලට ඒක පැහැදිලි වේවි.


component.ts
component.html

ඔයාලට පහත ආකරයෙ output එකක් බලාගන්න පුලුවන් වෙවි.



මේක පහත ආකාරයට else part  එකක් add කර  ගන්න පුලුවන්.එකට ng-templete කියලා elements එක්ක හදා ගන්න වෙනවා.එහෙම  එක්ක හදා ගෙන ඒකට පහත ආකරයට reference variable assign කරගන්න ඕන.

component.ts

component.html


දැන් අපිට බල ගන්න පුලුවන්  true block එක වැඩ කරලා "Condition is true" කියල output එකක්. මොකද අපි ts file ඒකෙ "condition=true;" කරලා තියන නිසා.




දැන් අපි බලමු ngIf Directive වල special අවස්ථා ටිකක්.


1.1)  කොහොමද string value එකක් compare කරන්නෙ  කියලා.

component.ts

component.html

ඒකෙදි ඔයාලට බල ගන්න පුලුවන් වෙයි පහත ආකාරයෙ  output එකක්.



1.2) කොහොමද integer value එකක් compare කරන්නෙ  කියලා.

component.html

component.ts

ඒකෙදි ඔයාලට  පහත output එකක් බලා ගන්න පුලුවන් වෙවි.



ඉහත ආකාරයටම AND ,OR  Operations වලටත් ඔයාලා කරල බලන්න.

වැඩි විස්තර බලා ගන්න ඕනනමි පහත Link එක Click කරන්න.

https://angular.io/api/common/NgIf



2 )   දැන් බලමු ngFor Directive කියන්නෙ මොක්කද? කොහොමද                  එකෙන් වැඩ කරන්නෙ  කියලා.


for කියද්දි අපට මතක් වෙන්නෙ looping . මේ ngFor Directive එක use වෙන්නෙත් loop වලට . ඒ කියන්නෙ template  එකේ එකම component එකක් හරි form එකක් හරි කිහිපවතාවක් පෙන්නගන්න ඕන නම් . ඒ කියන්නෙ array එකක තියෙන elements ටික පෙන්නගන්න ඕන කියලා හිතන්න. මේ වගේ වැඩ වලට තමයි ngFor use කරන්නෙ .

දැන් මම පහත ආකාරයට array  එකක් හදා ගන්න ඕන.

  name=['Madhusanka','Edirimanna','Pramodi','Samaratunga'];

දැන් අපි මේක template එකේ එකින් එක පෙන්න ගන්නේ කොහොමද කියල බලමු .ඒකට මෙන්න මේ වගෙ syntax එකක් use වෙනවා.*ngFor='let myName of name';

මෙකෙන් කියවෙන්නෙ name කියන array එකෙන් එක බැගින් අරගෙන myName කියන variable එකට assign කරන්න කියන එක.මෙතන myName වෙනුවට අපට කැමති නමක් දෙන්න පුලුවන් . නමුත් name කියන එක වෙනස් කරන්න බෑ . ඒක තමයි array එකේ name(නම) එක.

දැන් ඉතින් Myname කියන variable එක view කරගන්න තියෙන්නෙ...ඒකට interpolation use කරන්න පුලුවන්.මතක ඇති component එකේ තියෙන දෙයක් template එකේ පෙන්නගන්න interpolation යොදා ගන්න ඕන. double curly brases දාගෙන.ඒකම තමයි මෙතනත් කරන්න තියෙන්නෙ .

component.html

component.ts
 මේක පහත විදියට view කරලා බලාගන්න පුලුවන් .


පහත ආකරයට  තමන්ට කැමති element විතරක් array එකෙන් view කර ගන්න පුලුවන්.ඒ සදහා පහත syntax භාවිතා කරන්න පුලුවන්.

component.html

component.ts

වැඩි විස්තර බලා ගන්න ඕනනමි පහත Link එක Click කරන්න.

https://coryrylan.com/blog/angular-ng-for-syntax


03 )   දැන් බලමු ngSwitch Directive කියන්නෙ මොක්කද? කොහොමද             එකෙන් වැඩ කරන්නෙ  කියලා.

java වල switchcase තේරුනා නම් මේකත් ඒ වගේමයි.හරිම ලේසියි.සමාන output කිහිපයක් තියෙද්දි  නිවැරදි එක තෝරගන්න තමා මේක use කරන්නෙ.java වල වගේම ngSwitch කියල මුලින්ම අදාල variable එක assign කරනවා . ඊට පස්සෙ *ngSwitchCase කියල selective ටික assign කරනව .  code එක බැලුවාම හොදටම පැහැදිලි වේවි ඔයාලට.



component.html

component.ts




වැඩි විස්තර බලා ගන්න ඕනනමි පහත Link එක Click කරන්න.

https://angular.io/api/common/NgSwitch


අපි එහෙනම්  next lesson එකෙන් හමුවෙමු.

By :- Madhusanka Edirimanna


Saturday, July 13, 2019

Introduction to Japanese for Beginners......

As a beginner to japanese language you may know that there are three type of letter in japanese language.


  1. Hiragana
  2. Katakana
  3. Kanji

To learn the language easily and quickly you should follow the above order of three type of letters.


Hiragana


Hiragana  letters usually have  phonetic sounds.These are basically used for particles, words and part of words. This express 46 different sounds used in the japanese language.when practising hiragana letters you will be able to pronouns japanese letters properly,read and write.If you learn hiragana first it will be easier to learn katakana next.


Katakana

These letters are basically used for foreign words.Katakana is a phonetic alphabet.Katakana was developed in the 8th century by simplifying the form of kanji symbols. Katakana and Hiragana represent exactly the same set of sounds.




Kanji


These are chinese characters and used for the stem of words and convey the japanese language.



********
As a beginner you should learn how to write and pronounce vowel letters in hiragana alphabet.




 Above letters are in the order of English Vowels A, I , U , E, O.

After practising vowel sounds in hiragana alphabet you should try following letters.




  • Try the following exercise after practising above letters.
  1. aka (red)
  2. ao (blue)
  3. aki (autumn)
  4. ie (house)
  5. koe (voice)
  6. kao (face)
  7. ue (on top)
  8. kaki (permission)
  9. eki (station)
  10. okii (big)



By : Pramodi Samaratunga  - University Of Moratuwa 

        Madhusanka Edirimanna - University Of Moratuwa 


       

 





Friday, July 12, 2019

B+ Tree...

Examples for Insertion of data in to a B+ Tree


B+ tree is a rooted tree that consist of a root,internal nodes and leaves.In a B+ tree of order ( or branching factor) n should satisfy the following properties.

  • From root to leaf all the path's length should be same.
  • Each node that is not a root or a leaf has between (n/2) and n children. 
  • A leaf node has between ((n-1)/2) and n-1 values. 
  • If the root is not a leaf it has at least 2 children .
  • If the root is a leaf (there are no other nodes in the tree) it can have and 0 and (n-1) values.


Example 01-Enter numbers in to a B+ Tree

Branching factor-5
Number Sequence-5,10,15,20,25,30,35,40,50,55,65,70,75,80,90,95


Not a root or leaf has children between = (n/2) , n
                                                                  
                                                                   =(5/2), 5
             
                                                                   = 3,5

Leaf node has values between                =((n-1)/2) , (n-1)

                                                                  =(4/2), 4

                                                                  =2,4 










Example 02-Enter Strings to a B+ Tree

When you entering strings to a B+ tree you should consider the alphabetical order.

Branching factor=3

Colombo,Kandy,Galle,Badulla,Gampaha,Kottawa,Kalutara


Not a root or leaf has children between = (n/2) , n

                                                                   = 2, 3

Leaf node has values between                =((n-1)/2) , (n-1)

                                                                   = 1 , 2







Advantages of B+ Tree


  • Insertion, Deletion, Update does not affect to the performance since it is a balance tree structure.
  • Searching data is becomes more easy since all records are stored only in the leaf node.
  • Minimizing disk accesses by lowering the tree height due to large node fanout.
  • Keys are used for Indexing.

Disadvantages of B+ Tree


  • This method is less efficient for static tables.




By : Pramodi Samaratunga      -  University Of Moratuwa 

       Madhusanka Edirimanna  -  University Of Moratuwa 

SPRING MVC SIMPLE CRUD APPLICATION