Angular JS Learning

Angular Basic

 
  MVC pattern in AngulaJS
 
 
 //defining module
 var app=angular.module(“app”,[]);
   
 //defining controller
 app.controller(‘Ctrl’, function ($scope)
    {
 
  //defining book’s authors model
  var bookAuthors=[“Leardershiop”,”Human”]

  //defining book viewmodel
  $scope.books = { id: ‘ABXY01’, name: ‘Welcome to this blog’,
  authors: bookAuthors}
 });

 

  

     

  

  

     

  

  

     

  

 </table

Value of ‘null’ is not valid for ‘stream’

Visual Studio

Route Cause :

You might have add new image file in resource.resx file of your visual studio projects, and the file property Build Action is “Content”

Image File –>Right Click –> Properties –> Build Action = Content

Solution :

Right click on the image file you added, and change the file property to Embedded Resource

Image File –>Right Click –> Properties –> Build Action = Embedded Resource

Things make LIFE worth

1. Be fearless
Being fearless does not mean being without fear, being fearless means admitting your fears and going beyond them. A real man is not in denial of his fears, holding up a mask of invulnerability but is willing to face his fears and work on them. He has the courage to do things that frighten him when the situation calls for it. A real man knows that the path towards fearlessness is endless.
2. Be resilient
A man should be flexible and reliable at the same time. If necessary he can start all over again at any given moment. Whatever happens; his house was burnt down, his crop failed, he lost his job, his wife had a miscarriage: even if he has mourning to do he starts all over again. A real man accepts his fate but doesn’t become a victim of it.
3. Live, speak and listen from the heart
A real man doesn’t hide his feelings and intentions. He is not afraid to be gentle nor afraid to be sad. He is in touch with his emotions and is able to express them. He has the courage to live his dream and the space to listen compassionately.
4. Own your anger
A real man owns his anger. His anger has transformed into masculine compassion. He can be angry, strong, decisive and courageous. His anger serves his presence and the presence of others. It is not a humiliating or destructive type of anger. The latter happens when a man is a slave of his anger, that’s the anger of the coward trying to overcompensate his feelings of inferiority. This is just as sad as a man completely disconnected from his anger. He becomes emasculated and has no power at all. Other men don’t take him seriously. Women can smell immature anger and emasculatedness from a mile away and don’t find it sexy. Mature anger, on the other hand, is a big turn on.
5. Make meaning
Try not to become a man of success, try to become a man of value. Einstein said that. I think that’s true and important. If you fill your days with doing something that pays the bills but is essentially meaningless you are wasting your precious life. Yes, even if it pays the bills so handsomely that you can spend 2 months per year on adventurous holidays and eat in fancy restaurants, you are still wasting your life.  A real man has the balls to travel outside his comfort zone to make a sincere attempt to contribute to mankind. He works for the greater good instead of for the sake of protection of his self image and clinging to the illusion of safety.
6. Own your edge
This life is a journey and we all are somewhere on our path. A real man is honest about where he is at in his development. He doesn’t pretend to be wiser or more evolved than he actually is nor does he shrink so that others won’t feel insecure around him. He knows his strengths and his weaknesses and not ashamed of either. That there is always work to do is a given to him. He knows where he has his work to do and is willing to listen and learn from those who have done that work.
7. Be vulnerable
A coward is always trying to hide his weak spots, a real man works on them. He is willing and able to reveal himself even in the midst of pain. He is vulnerable because he wants to be vulnerable. By opening up in every moment he is continuously practicing his courage. It’s his way of defeating his own cowardice.
8. Make love passionately
A real man does not hold back. When he makes love he opens up to all his rawness and all his tenderness and he gives his woman everything he has got. He does not shy away from intimacy. He can penetrate his woman so hard and deeply that she can feel that he is entering her soul. He aims for her heart. He makes her feel like a princess and a porn star simultaneously.
9. Practice a martial art
When push comes to shove every man should be able to defend his wife, children and honor. Just like we teach our children to swim to prevent them from drowning a man should know at least enough basic fighting skills so he can throw a punch in case of an emergency. A real man has spent enough time in a ring or dojo to ensure a deescalating presence. He does not panic, is not easily provoked and has some strength and skills.
10. Have a sense of humor (don’t take yourself so fucking seriously)
A real man can hold both the utter importance and the utter unimportance of life at the same time. He can see his own failures and flaws and joke about that. Since he knows his self image is just an image he feels no need to defend that image. He can uplift a tense situation with a joke but he isn’t the immature joker that abuses humor as a tool for escaping intimacy or sabotaging intensity. A real man has the capacity to light up the room. A real man embraces life.

11. Develop body, mind and spirit
A real man is devoted to the development of body, mind and spirit. Not to stay ahead of other men, not out of fear of being defeated, but because he has more to offer when he is healthy and present. Taking care of his body makes him fit and strong, taking care of his mind makes him clever and sharp, taking care of his spirit makes him wise, warm and compassionate. A real man knows that his body and mind are mortal but that the love he spreads during his life remains.
12. Be real
In the end a real man knows that he is just a guy. He does all these things because that’s what he is: a man. He likes hanging out with other men, he might drink beer during football, he loves his woman and he works wholeheartedly. Basically, he is just trying to do his best to make the most of life and is having some fun while doing that. His sweat is honest, his heart is open and his back is straight.

Book Id :
Name :
Authors :
DECLARE @String AS VARCHAR(100)
DECLARE @strSearch AS VARCHAR(100)
SET @String ='Hi SQL SERVER is from Microsoft'
SET @strSearch ='Hi'
--Find First occurrence of any character or word in the string
SELECT CHARINDEX(@strSearch ,@String) As [Result]

--OUTPUT
First occurrence
___________________
1

  • Find Last occurrence of any character or word in the string :
In the example given below, we need to search for the last occurrence of word‘the’ in the sentence.
DECLARE @String AS VARCHAR(100)
DECLARE @strSearch AS VARCHAR(100)
SET @String ='The SQL SERVER is from Microsoft hi'
SET @strSearch ='hi'
--Find Last occurrence of any character or word in the string
SELECT DATALENGTH(@String)-CHARINDEX(REVERSE(@strSearch )
,REVERSE(@String))-1 As [Result]
–OUTPUT Last occurrence
_________________________
33

How to find number of occurrence of char or word in a string ?

SQL Query

To get number of occurrence of a char in string 

DECLARE @myvar VARCHAR(20)
SET @myvar = ‘Hello World
SELECT LEN(@myvar) – LEN(REPLACE(@myvar,’l’,”)) AS [No-of-times char]

Number of times char ‘l’ is repeated 3 times

Output :  3



SQL Query  to get number of occurrence of a word in string 


DECLARE @myvar VARCHAR(MAX), @tosearch VARCHAR(20)
SET @myvar = ‘Hello Worlod, Hello World you’
SET @tosearch = ‘you’
SELECT (LEN(@myvar) – LEN(REPLACE(@myvar,@tosearch,”))) / LEN(@tosearch) AS [No-of-times word]

Number of times word ‘you’ is repeated 1 time

Output :  1





How to read System Date dynamically from windows registry file in C# ?

Get System Date and Time from windows registry

        C# sample Code  to get date format


     public static string GetSystemDateFormat()
        {
            RegistryKey rkey = Registry.CurrentUser.OpenSubKey(@”Control Panel\International”, true);
            if (rkey != null)
            {
                return rkey.GetValue(“sShortDate”).ToString();
            }
            else
            {
                return CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern;
            }

        }

        C# sample Code  to get date and time

      public static string GetSystemDateTimeFormat()
        {
            RegistryKey rkey = Registry.CurrentUser.OpenSubKey(@”Control Panel\International”, true);
            if (rkey != null)
            {
                return rkey.GetValue(“sShortDate”).ToString() + rkey.GetValue(“sTimeFormat”).ToString();
            }
            else
            {
                return CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern;
            }

        }

      

   

How to get comma separated words with single quote in C#?

LINQ  Get comma separated words with single quote in C#

  1. First parameter itemCollection is input  |   Hello+we+are+here 
  2. Second parameter separator is char      |    ‘+
        C# sample Code 


        public static string GetResults(string itemCollection,char separator)

        {

            string result = string.Empty;

            if (String.IsNullOrEmpty(itemCollection)) return result;
            else
            {
                result = string.Join(“,”, itemCollection.Split(separator).Select(x => string.Format(“‘{0}'”, x.TrimStart().TrimEnd())).ToList());                
            }
            return result;
        }

Input:  Hello+we+are+here 


Output :  ‘Hello’,’we’,’are’,’here ‘


How to backup mysql database from command line?

Easy way to back up MySQL database from command line

Steps by Step 

  1.  Open command prompt window; Windows + R ; type cmd  
  2. Copy the below line fully 
  3. mysqldump -u root -p -h localhost yourdbname >dbbackfilename.sql
  4. Right click on command window and paste it; press enter key
  5. It will ask for password; press enter key again and wait for a second
  6. Your backup file is generated under C:\Windows\System32\subs_mBackup.sq folder
          

Trouble Shooting: 

  1.  If above method returns “Access Denied” or any error please use below checks
  2. Open command prompt ; Windows key + R ; copy & paste below line and press enter
  3.  cd  C:\Program Files (x86)\MySQL\MySQL Server 5.5\bin 
  4. Now follow step 3 in Step by step section.

How to change MySQL root password?

How to change MySQL root password?

Steps by Step 

  1.  Open MySQL Command Line Client  
  2.  To remove a password  SET PASSWORD FOR root@localhost=PASSWORD(”);
  3.  To add a password    SET PASSWORD FOR root@localhost=PASSWORD(‘root’);
  4.  Demo image is below
Design a site like this with WordPress.com
Get started