<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[tinywave - Medium]]></title>
        <description><![CDATA[few tiny collections - Medium]]></description>
        <link>https://medium.com/tinywave?source=rss----b73956242a6b---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>tinywave - Medium</title>
            <link>https://medium.com/tinywave?source=rss----b73956242a6b---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 12 Nov 2026 21:05:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/tinywave" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Javascript | Array GroupBy]]></title>
            <link>https://medium.com/tinywave/javascript-array-groupby-b5d47fbc46?source=rss----b73956242a6b---4</link>
            <guid isPermaLink="false">https://medium.com/p/b5d47fbc46</guid>
            <category><![CDATA[array-methods]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[arrays]]></category>
            <category><![CDATA[group-by]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Vipin Cheriyanveetil]]></dc:creator>
            <pubDate>Tue, 28 Dec 2021 05:37:03 GMT</pubDate>
            <atom:updated>2022-01-17T05:26:36.716Z</atom:updated>
            <content:encoded><![CDATA[<p>Wow ! Array has GroupBy too. I am so excited to use this ……</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fxt0n2p2IC1T8q-1ms7UZA.png" /><figcaption>Grouping in javascript</figcaption></figure><p>Hello All wonderful developers, hope you had a great Xmas.</p><p>Javascript is evolving day by day and it’s becoming my favourite programming language. I am sure many will have the same feeling and many will disagree too.</p><p><a href="https://github.com/tc39/proposal-array-grouping"><strong>Array Proposal</strong></a></p><p>I came across the <a href="https://github.com/tc39/proposal-array-grouping">array proposals</a> and i thought I should write this out in my medium blog and here it is . It introduces new array methods like <strong>array.groupBy</strong> and <strong>array.groupByToMap . </strong>I like the SQL groupBy and I use them and I really love to use it. I am hopping this will help me do the same.</p><blockquote><strong>Note</strong> : This proposal is currently at stage 3.</blockquote><blockquote>This article only covers an example for <strong>array.groupBy</strong></blockquote><p>Let’s see how to use <strong>array.groupBy</strong> with an example.</p><h4>Lets’s start by defining an array</h4><pre>let people = [</pre><pre>{ name: &quot;vipin&quot;, type: &quot;adult&quot; },</pre><pre>{ name: &quot;urmika&quot;, type: &quot;kid&quot; },</pre><pre>{ name: &quot;david&quot;, type: &quot;youth&quot; },</pre><pre>{ name: &quot;janvika&quot;, type: &quot;kid&quot; },</pre><pre>{ name: &quot;mika&quot;, type: &quot;adult&quot; },</pre><pre>]</pre><p>Ok. Now the array is ready . So let’s use the array methods on this array and observe the output.</p><h4><strong>Usage</strong>:</h4><pre>const result = people.groupBy(person =&gt; {</pre><pre>return person.type;</pre><pre>});</pre><h4><strong>Output</strong></h4><pre><strong>console.log(result);</strong></pre><pre> {</pre><pre>   &#39;adult&#39;: [</pre><pre>     { name: &#39;vipin&#39;, type: &#39;adult&#39; },<br>     { name: &#39;mika&#39;, type: &#39;adult&#39; },</pre><pre>   ],</pre><pre>   &#39;kid&#39;: [</pre><pre>     { name: &#39;urmika&#39;, type: &#39;kid&#39; },<br>     { name: &#39;janvika&#39;, type: &#39;kid&#39; }</pre><pre>   ],</pre><pre>   &#39;youth&#39;: [</pre><pre>    { name: &#39;david&#39;, type: &#39;youth&#39; }</pre><pre>   ]</pre><pre> }</pre><p>Wow, The output is great to look at. I am really impressed with this and I hope you all liked it .</p><p><strong>Happy new year in advance and Happy javascripting …….. do enjoy programming and your life……</strong></p><p><strong>You can buy me a coffee , if you like at </strong><a href="https://www.buymeacoffee.com/vipinc007"><strong>https://www.buymeacoffee.com/vipinc007</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b5d47fbc46" width="1" height="1" alt=""><hr><p><a href="https://medium.com/tinywave/javascript-array-groupby-b5d47fbc46">Javascript | Array GroupBy</a> was originally published in <a href="https://medium.com/tinywave">tinywave</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Javascript : Callbacks, Promises, and Async/Await]]></title>
            <link>https://medium.com/tinywave/javascript-callbacks-promises-and-async-await-820a12e4b689?source=rss----b73956242a6b---4</link>
            <guid isPermaLink="false">https://medium.com/p/820a12e4b689</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[callback]]></category>
            <category><![CDATA[await]]></category>
            <category><![CDATA[async]]></category>
            <category><![CDATA[promises]]></category>
            <dc:creator><![CDATA[Vipin Cheriyanveetil]]></dc:creator>
            <pubDate>Fri, 08 Oct 2021 14:41:03 GMT</pubDate>
            <atom:updated>2023-08-24T02:56:35.154Z</atom:updated>
            <content:encoded><![CDATA[<h3>Javascript : Callbacks, Promises, and Async/Await</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IEiZgpbTwuCBm5ifh-fUCw.png" /><figcaption>Javascript : Callbacks, Promises, and Async/Await</figcaption></figure><p><strong>The Real version of this blog post is at my personal space </strong><a href="https://buddyclaps.com/javascript-callbacks-promises-async-await/">https://buddyclaps.com/javascript-callbacks-promises-async-await/</a></p><p>Hello programmers,</p><p>This article is for all those who wants to understand the below topics. I love Javascripting and I am into Javascripts from more than 3 years now.</p><ul><li>Callbacks</li><li>Promises</li><li>Async and Await</li></ul><p>This article should help us in understanding few javascript concepts like</p><ul><li>What is Synchronous Operation ?</li><li>What is Asynchronous Operation ?</li><li>What is Callback and an example ?</li><li>What is Promises and an example ?</li><li>How Async and Await works in javascript with example?</li></ul><h4>What is Synchronous Operation ?</h4><p>This is the most efficient way of getting a task done. Synchronous focuses on getting tasks done <strong>one by one</strong> or <strong>one after another</strong> or getting tasks done <strong>sequentially</strong>. I like this approach as it makes code more easy to understand and debug. This also means that the other tasks waits until their turn arrives.</p><p>By default Javascript is synchronous or <strong>single threaded</strong>. it is designed to do one task at a time.</p><p>Let’s look at a simple example. Look at the below code</p><pre>console.log(&quot;I am First&quot;)<br>console.log(&quot;I am Second&quot;)<br>console.log(&quot;I am Third&quot;)</pre><p>The output on console would be</p><pre>&quot;I am First&quot;<br>&quot;I am Second&quot;<br>&quot;I am Third&quot;</pre><h4>What is Asynchronous Operation ?</h4><p>Asynchronous is exactly the opposite of synchronous operation. Which means the tasks can run independent to each other and no task has to wait for others. This approach is great when you want to make your code more efficient and fast. Imagine if you can do multiple tasks at a time and finish it all. Wow ! how great that would be. Not sure if humans can do this effectively but machines and javascript can.</p><p>Let’s look at a simple example. Look at the below code</p><pre>console.log(&quot;David Reached School&quot;)<br>setTimeout(() =&gt; {<br>  console.log(&#39;Liz reached school&#39;)<br>}, 3000)<br>setTimeout(() =&gt; {<br>  console.log(&#39;Bill Reached school&#39;)<br>}, 2000)<br>console.log(&quot;Mike Reached School&quot;)</pre><p>The output on console would be</p><pre>&quot;David Reached School&quot;<br>&quot;Mike Reached School&quot;<br>&quot;Bill Reached school&quot;<br>&quot;Liz reached school&quot;</pre><p>If you look at the above output, the output is not in the order in which they are programmed but instead its in the order in which it got completed.</p><h4>Callbacks : what’s that ?</h4><p>In JavaScript, a callback is <strong>a function passed into another function as an argument to be executed later</strong>. When you pass a callback function into another function, you just pass the reference of the function i.e., the function name without the parentheses () .</p><p><strong>OR</strong></p><p>A callback function is a function passed into another function as an argument, which is then <strong>invoked inside the outer function to complete some kind of routine or action</strong>.</p><p><strong>An Example</strong></p><pre>function announce() {<br>    console.log(&#39;Yea!, the hot water is ready !&#39;)<br>}</pre><pre>function boil_water(shoutIt) {<br>    console.log(&#39;Water is boiling&#39;)<br>    setTimeout(() =&gt; {<br>        shoutIt()<br>    }, 3000)<br>}</pre><pre>boil_water(announce)</pre><p>If you look at the code “<strong>boil_water(announce)</strong>“, you see that method “<strong>announce</strong>” is passed as a reference to “<strong>boil_water</strong>” method and “<strong>boil_water</strong>” is invoking the reference method when needed. So this becomes a simple example for how to use a callback. Hope its easier to understand.</p><h4>Callback Hell: OMG, now what is that ?</h4><p>I thought callbacks were great and interesting. But, wait ! what’s this now.</p><p>let’s look at an example straight away.</p><pre>setTimeout(() =&gt; {<br>    console.log(&#39;Sunday&#39;)<br>    setTimeout(() =&gt; {<br>        console.log(&#39;Monday&#39;)<br>        setTimeout(() =&gt; {<br>            console.log(&#39;Tuesday&#39;)<br>            setTimeout(() =&gt; {<br>                console.log(&#39;Wednesday&#39;)<br>                setTimeout(() =&gt; {<br>                    console.log(&#39;Thursday&#39;)<br>                    setTimeout(() =&gt; {<br>                        console.log(&#39;Friday&#39;)<br>                        setTimeout(() =&gt; {<br>                            console.log(&#39;Saturday&#39;)<br>                            setTimeout(() =&gt; {<br>                                console.log(&#39;Wow! week is over&#39;)<br>                            }, 2000)<br>                        }, 2000)<br>                    }, 2000)<br>                }, 2000)<br>            }, 2000)<br>        }, 2000)<br>    }, 2000)<br>}, 2000)</pre><p>Output:</p><pre>&quot;Sunday&quot; (After 2 seconds)<br>&quot;Monday&quot; (After 2 seconds)<br>&quot;Tuesday&quot; (After 2 seconds)<br>&quot;Wednesday&quot; (After 2 seconds)<br>&quot;Thursday&quot; (After 2 seconds)<br>&quot;Friday&quot; (After 2 seconds)<br>&quot;Saturday&quot; (After 2 seconds)<br>&quot;Wow! week is over&quot; (After 2 seconds)</pre><p>The code above is a perfect example of “<strong>Callback Hell</strong>“. Below are some problem of “<strong>Callback Hell</strong>“.</p><ul><li>It’s hard to read or poor readability.</li><li>Hard to understand the code.</li><li>It’s even harder to debug</li><li>Difficult to add error handling.</li></ul><p>“<strong>Callback Hell</strong>” is also known as “<strong>Pyramid of doom</strong>” or “<strong>Christmas tree of hell</strong>“. No matter whatever different names you give , the problems remains the same.</p><p>Don’t worry. “<strong>Promises</strong>” can help us. I promise you that. But don’t take my words.</p><h4>Wow ! Promises</h4><p>“<strong>Promises</strong>” as designed to help us from “<strong>callback hell</strong>” and more importantly it helps us to better handle our code and tasks. That’s so relieving to hear.</p><p>Now, let’s understand “<strong>Promises</strong>” better. Promises has few states to go through. Below are more info about them</p><ul><li><strong>Pending</strong> : This is just an initial state. Example : Just consider a customer is visiting your shop and going through your menu before making an order.</li><li><strong>Resolved</strong> : It’s like customer made an order and they got the order delivered to their hand and they are very happy.</li><li><strong>Rejected</strong> : It’s like customer ordered something which is not available and he left the shop without getting anything.</li></ul><p>Wow, how easy is this to understand. See i promised you that it will be easy to understand. I keep my promises !!!! . Have a look at the same thing like a flowchart or an image below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/918/0*DBfz1BMwVQBe6NRI.png" /></figure><p>Everything is good so far. Lets write a simple promise example.</p><pre>var is_printer_on = true<br>let take_print = (printText) =&gt; {<br>    return new Promise((resolve, reject) =&gt; {<br>        if (is_printer_on) {<br>            setTimeout(() =&gt; {<br>                resolve(&#39;Printed :&#39; + printText)<br>            }, 2000)<br>        } else {<br>            reject(&#39;Printer is off&#39;)<br>        }<br>    })<br>}</pre><p>So, this is a very simple method that uses <strong>promises</strong> to take a print of the given <strong>printText</strong>. Let’s see how to use this method. This method gives different output based on if the printer is on or off.</p><p>ie if “<strong>var is_printer_on = true</strong>” then printer is ON</p><p>else if “<strong>var is_printer_on = false</strong>“) then printer is OFF</p><p><strong>Invoke with Printer = ON</strong></p><pre><strong>var is_printer_on = true</strong><br>let take_print = (printText) =&gt; {<br>    return new Promise((resolve, reject) =&gt; {<br>        if (is_printer_on) {<br>            setTimeout(() =&gt; {<br>                resolve(&#39;Printed :&#39; + printText)<br>            }, 2000)<br>        } else {<br>            reject(&#39;Printer is off&#39;)<br>        }<br>    })<br>}</pre><pre>take_print(&#39;hello world&#39;)<br>    .then((res) =&gt; {<br>        console.log(&#39;Success : &#39;, res)<br>    })<br>    .catch((err) =&gt; {<br>        console.log(&#39;oops!,&#39;, err)<br>    })<br>    .finally(() =&gt; {<br>        console.log(&#39;Have a good day&#39;)<br>    })</pre><p>Output</p><pre><strong>After 2 seconds</strong><br>&quot;Success :  Printed :hello world&quot;<br>&quot;Have a good day&quot;</pre><p>Now lets turn OFF the printer</p><p><strong>Invoke with Printer = OFF</strong></p><pre><strong>var is_printer_on = false</strong><br>let take_print = (printText) =&gt; {<br>    return new Promise((resolve, reject) =&gt; {<br>        if (is_printer_on) {<br>            setTimeout(() =&gt; {<br>                resolve(&#39;Printed :&#39; + printText)<br>            }, 2000)<br>        } else {<br>            reject(&#39;Printer is off&#39;)<br>        }<br>    })<br>}</pre><pre>take_print(&#39;hello world&#39;)<br>    .then((res) =&gt; {<br>        console.log(&#39;Success : &#39;, res)<br>    })<br>    .catch((err) =&gt; {<br>        console.log(&#39;oops!,&#39;, err)<br>    })<br>    .finally(() =&gt; {<br>        console.log(&#39;Have a good day&#39;)<br>    })</pre><p>Output</p><pre>&quot;oops!, Printer is off&quot;<br>&quot;Have a good day&quot;</pre><p>Great, so you just saw a promise that can take the “<strong>Resolved</strong>” state when Printer was ON and it took a “<strong>Rejected</strong>” state when Printer was OFF. And irrespective of the state we got the <strong>finally</strong> block also executed. So I hope “<strong>promises</strong>” are now making sense.</p><h4>Async / await</h4><p>“<strong>Promises</strong>” were introduced in javascript to handle asynchronous activity or operation easily. The <strong>Async/Await</strong> is a syntactical sugar added to easily work with promises. The intention is that <strong>async/await</strong> will help in making the code look synchronous while performing asynchronous activity.</p><p>So let’s write the same “<strong>take_print</strong>” promise using the <strong>async / await</strong> keywords. We might need to make slight changes to the “<strong>take_print</strong>” method and the way it needs to be invoked.</p><p><strong>Invoke with Printer = ON</strong></p><pre><strong>var is_printer_on = true</strong><br>let take_print = async (printText) =&gt; {<br>    return new Promise((resolve, reject) =&gt; {<br>        if (is_printer_on) {<br>            setTimeout(() =&gt; {<br>                resolve(&#39;Printed :&#39; + printText)<br>            }, 2000)<br>        } else {<br>            reject(&#39;Printer is off&#39;)<br>        }<br>    })<br>}</pre><pre>async function testcode() {<br>    try {<br>        let res = await take_print(&#39;hello world&#39;)<br>        console.log(&#39;Success : &#39;, res)<br>    } catch (err) {<br>        console.log(&#39;oops!,&#39;, err)<br>    } finally {<br>        console.log(&#39;Have a good day&#39;)<br>    }<br>}</pre><pre>testcode()</pre><p>Output</p><pre><strong>After 2 seconds</strong><br>&quot;Success :  Printed :hello world&quot;<br>&quot;Have a good day&quot;</pre><p><strong>Invoke with Printer = OFF</strong></p><pre><strong>var is_printer_on = false</strong><br>let take_print = async (printText) =&gt; {<br>    return new Promise((resolve, reject) =&gt; {<br>        if (is_printer_on) {<br>            setTimeout(() =&gt; {<br>                resolve(&#39;Printed :&#39; + printText)<br>            }, 2000)<br>        } else {<br>            reject(&#39;Printer is off&#39;)<br>        }<br>    })<br>}</pre><pre>async function testcode() {<br>    try {<br>        let res = await take_print(&#39;hello world&#39;)<br>        console.log(&#39;Success : &#39;, res)<br>    } catch (err) {<br>        console.log(&#39;oops!,&#39;, err)<br>    } finally {<br>        console.log(&#39;Have a good day&#39;)<br>    }<br>}</pre><pre>testcode()</pre><p>Output</p><pre>&quot;oops!, Printer is off&quot;<br>&quot;Have a good day&quot;</pre><h4>Conclusion</h4><p>Thanks for reading this article with patience. I hope my article was useful and made sense. Let me know your comments and thoughts through the comment box below.</p><h4>Credits</h4><p><a href="https://www.freecodecamp.org/news/javascript-async-await-tutorial-learn-callbacks-promises-async-await-by-making-icecream/">Here</a> I found much elaborated and in detail discussion of the same topic . I got inspired by that article and I felt I should also write something similar in my own words and examples and that’s what led to this post.</p><p>Thanks for reading !! Have a great day !</p><p><strong>You can buy me a coffee , if you like at </strong><a href="https://www.buymeacoffee.com/vipinc007"><strong>https://www.buymeacoffee.com/vipinc007</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=820a12e4b689" width="1" height="1" alt=""><hr><p><a href="https://medium.com/tinywave/javascript-callbacks-promises-and-async-await-820a12e4b689">Javascript : Callbacks, Promises, and Async/Await</a> was originally published in <a href="https://medium.com/tinywave">tinywave</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular 6 : 404 error during refresh after deployment]]></title>
            <link>https://medium.com/tinywave/angular-6-404-error-during-refresh-after-deployed-8cec7140b584?source=rss----b73956242a6b---4</link>
            <guid isPermaLink="false">https://medium.com/p/8cec7140b584</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[angular-6]]></category>
            <category><![CDATA[angular-5]]></category>
            <category><![CDATA[routing]]></category>
            <category><![CDATA[error-404]]></category>
            <dc:creator><![CDATA[Vipin Cheriyanveetil]]></dc:creator>
            <pubDate>Wed, 30 Oct 2019 06:31:29 GMT</pubDate>
            <atom:updated>2019-10-30T06:35:33.421Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*EkANwcIYzNHI5E8Cwe7qQQ.png" /></figure><p>Hello All,</p><p>I am sure this is an issue which most of us are facing with Angular 2/4/5/6 applications when we deploy them to any wamp server or IIS or to any domains. I too faced the same and I have a solution too.</p><p>The main problem is because when you route from one page to another the url will be something like let&#39;s say you are going from “<strong>http://localhost/login</strong>” to “<strong>http://localhost/contact</strong>”.</p><p>If you refresh from the above urls , the system assumes it to be a physical location and it throws an error when it doesn&#39;t find it. Which is absolutely valid.</p><p>So we need to use the “<strong>#</strong>” mechanism which Angularjs 1 was using. for example, we need to make our urls look like “<strong>http://localhost/#/contact</strong>”</p><p>So to get that working I have the below steps</p><p>1). The first thing we need is to import the below two modules from “<strong>@angular/common</strong>” like below in the “<strong>app.module.ts</strong>” file</p><pre>import { HashLocationStrategy, LocationStrategy  } from &#39;@angular/common&#39;;</pre><p>2). In the same file add the below line under “<strong>Providers</strong>”</p><pre>providers: [</pre><pre>{provide : LocationStrategy , useClass: HashLocationStrategy}</pre><pre>],</pre><p>3). Compile/build and deploy and see it should work :) .</p><p>It worked for me. it should work for you too :)</p><p>Have a great day, enjoy angularing</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8cec7140b584" width="1" height="1" alt=""><hr><p><a href="https://medium.com/tinywave/angular-6-404-error-during-refresh-after-deployed-8cec7140b584">Angular 6 : 404 error during refresh after deployment</a> was originally published in <a href="https://medium.com/tinywave">tinywave</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Implement / Create Classes and Objects in vuejs]]></title>
            <link>https://medium.com/tinywave/how-to-implement-create-classes-and-objects-in-vuejs-b3f53e8330ba?source=rss----b73956242a6b---4</link>
            <guid isPermaLink="false">https://medium.com/p/b3f53e8330ba</guid>
            <category><![CDATA[object-oriented-in-vuejs]]></category>
            <category><![CDATA[vue]]></category>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[class-and-object-in-vuejs]]></category>
            <category><![CDATA[vuejs-oops]]></category>
            <dc:creator><![CDATA[Vipin Cheriyanveetil]]></dc:creator>
            <pubDate>Mon, 22 Apr 2019 08:40:01 GMT</pubDate>
            <atom:updated>2022-01-17T05:21:56.321Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*2rWcDJCpDraAeW8sV29GhA.png" /></figure><p>Hello,</p><p>Am new to vuejs as am currently learning this new guy. Vuejs is really impressive and I like it over angular. I come from a dot net background and I thought I would see classes and objects concepts in vuejs too. Am sure it will be there in the typescript.</p><p>I wanted to desperately separate out my logic to different classes and to small small reusable functions and use it in my components.</p><p>I searched many blogs and sites and many had examples of classes in some or other way. It was hard for me to follow them because I was looking for an exact replica of the same being implemented in C#.</p><p>From all the tips and examples on the internet, I thought of writing one and see if it compiles and works. So I wrote the below class in a .js file. Let&#39;s say “<strong>MyNameClass.js</strong>”</p><pre>export default class MyNameClass {<br>    FirstName = null;<br>    LastName = &quot;&quot;;<br> <br>    constructor(fname, lname) <br>    {<br>      this.FirstName = fname;<br>      this.LastName = lname;<br>    }</pre><pre>    getFullName()<br>    {<br>      return this.FirstName+&#39; &#39;+ this.LastName;<br>    }</pre><pre>    getFirstName()<br>    {<br>      return this.FirstName;<br>    }</pre><pre>    getLastName()<br>    {<br>      return this.LastName;<br>    }        <br>}</pre><p>So, the above class got created and it&#39;s just a simple one as you see. Let us below how to use it.</p><p>In the min.js file,</p><ol><li>I imported it globally like below</li></ol><pre>import MyNameClass from &quot;/classes/MyNameClass.js&quot;;</pre><p>2. And created an object of the same, like below by passing the parameters to the constructor. I stored the object to a global property.</p><pre><strong>Vue</strong>.prototype.$MyNameClass= new MyNameClass(&#39;Vipin&#39;, &#39;C&#39;);</pre><p>3. Call the methods by using the object. I called this method from one of my components and it goes like this</p><pre>this.$MyNameClass.getFullName();</pre><p>and <strong>WOW</strong>, <strong>voila</strong>. It got compiled successfully and it ran too and it gave me the string “Vipin C”. Am happy :)</p><p>I didn&#39;t try creating multiple objects of the same class. I would try that next. anyway, it as a good thing, to begin with.</p><p>Let this be useful to those who are also looking for similar implementation.</p><p><strong>You can buy me a coffee , if you like at </strong><a href="https://www.buymeacoffee.com/vipinc007"><strong>https://www.buymeacoffee.com/vipinc007</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b3f53e8330ba" width="1" height="1" alt=""><hr><p><a href="https://medium.com/tinywave/how-to-implement-create-classes-and-objects-in-vuejs-b3f53e8330ba">How to Implement / Create Classes and Objects in vuejs</a> was originally published in <a href="https://medium.com/tinywave">tinywave</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[angular : Access Properties / functions of a child component when added dynamically]]></title>
            <link>https://medium.com/tinywave/angular-access-properties-functions-of-a-child-component-when-added-dynamically-707f61c86957?source=rss----b73956242a6b---4</link>
            <guid isPermaLink="false">https://medium.com/p/707f61c86957</guid>
            <category><![CDATA[dynamic-components]]></category>
            <category><![CDATA[angular-6]]></category>
            <category><![CDATA[child-component]]></category>
            <category><![CDATA[parent-child-access]]></category>
            <dc:creator><![CDATA[Vipin Cheriyanveetil]]></dc:creator>
            <pubDate>Wed, 10 Apr 2019 04:54:13 GMT</pubDate>
            <atom:updated>2019-07-09T08:55:20.911Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*vAIvgwLY4AfmrPMM62AmBA.png" /></figure><p>Hello All,</p><p>Recently I was working on angular 6 and I really started liking it. I could create few applications using it and it seemed to be lot different than angular1. I had past experience with angular 1 and it was a completely different framework from recent angular 5 / 6. I really liked the dynamic loading of html files in angular 1 using “<strong>ng-include</strong>” which am missing in the newer versions. An alternative approach to that is, It is possible to add dynamic component and component internally can load html.</p><p>After finding a solution to add component dynamically I needed a solution to access the properties of child component . I googled and investigated many other blogs and sites and found a working solution.</p><p>Below is parent component which is trying to add a childcomponent dynamically</p><pre><strong>import {Component,ViewChild,ViewContainerRef,ComponentFactoryResolver,ComponentRef,ComponentFactory} from &#39;</strong><a href="http://twitter.com/angular/core"><strong>@angular/core</strong></a><strong>&#39;;<br>import { ChildComponent } from &#39;./child.component&#39;;<br>  <br></strong><a href="http://twitter.com/Component"><strong>@Component</strong></a><strong>({<br>    selector: &#39;app-root&#39;,<br>    templateUrl: &#39;./app.component.html&#39;<br>})<br>export class AppComponent {<br>    componentRef= null;<br>    title = &#39;parent child communication app&#39;;</strong></pre><pre><a href="http://twitter.com/ViewChild"><strong>@ViewChild</strong></a><strong>(&#39;messagecontainer&#39;, { read: ViewContainerRef }) entry: ViewContainerRef;<br>    constructor(private resolver: ComponentFactoryResolver) { }<br>  <br>    loadChildComponent() {<br>        this.entry.clear();<br>        const factory = this.resolver.resolveComponentFactory(ChildComponent);<br>        this.componentRef = this.entry.createComponent(factory);<br>        this.componentRef.instance.message = &quot;Loaded&quot;;<br>  this.componentRef.instance.showMessage();<br>    }<br>    destroyComponent() {<br>        this.componentRef.destroy();<br>    }<br>}</strong></pre><p>If you look at the above code you can see that the reference of child component is assigned to a property “<strong>componentRef”</strong></p><pre><strong>this.componentRef = this.entry.createComponent(factory);</strong></pre><p>the same reference property is used to invoke the child component property and functions . In the example, the code is accessing the <strong>message </strong>property and calling the <strong>ShowMessage() </strong>function too which belongs to a child component</p><pre><strong>this.componentRef.instance.message = &quot;Loaded&quot;;<br>this.componentRef.instance.showMessage();</strong></pre><p>So that’s it, this is one way to access child component properties and functions from a parent component.</p><p>Hope you all liked it. Happy angularing :)</p><p>You can buy me a coffee if you like to at <a href="https://ko-fi.com/tinywave">https://ko-fi.com/tinywave</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=707f61c86957" width="1" height="1" alt=""><hr><p><a href="https://medium.com/tinywave/angular-access-properties-functions-of-a-child-component-when-added-dynamically-707f61c86957">angular : Access Properties / functions of a child component when added dynamically</a> was originally published in <a href="https://medium.com/tinywave">tinywave</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ASP.net : Webforms VS MVC]]></title>
            <link>https://medium.com/tinywave/asp-net-webforms-vs-mvc-1c391c7c3a4c?source=rss----b73956242a6b---4</link>
            <guid isPermaLink="false">https://medium.com/p/1c391c7c3a4c</guid>
            <category><![CDATA[web-forms]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[aspnet]]></category>
            <category><![CDATA[aspnet-mvc]]></category>
            <dc:creator><![CDATA[Vipin Cheriyanveetil]]></dc:creator>
            <pubDate>Wed, 10 Apr 2019 04:53:12 GMT</pubDate>
            <atom:updated>2022-01-17T05:27:59.435Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*88F79h6CB05EYipOcF7V9w.png" /></figure><p>Hello to all the dot net developers out there, Hope you all are having a wonderful day !!!!</p><p>I thought I should write this post out because the question webforms or asp.net MVC will really keep every developer thinking on what would be the best fit when you are set to start a new web application. Remember one thing that MVC is not a new technology but it’s a new concept or approach that can help you to create web application. Even i had this dilemma when I wanted to start with a new project. Just because I had experience in webforms i decided to choose it over MVC. I went with MVC when i got the next project to start with. I believe every developer will come across this confusions when there are multiple options but mostly i have seen my colleagues also choosing webforms over MVC just because they had earlier worked with it and they feel much better and comfortable when working with webforms. For a moment all developers will definitely have a hesitation towards the MVC side. When I started with MVC i found it little bit difficult initially and gradually i started feeling that it’s much better and a new framework which needs few days to really understand how MVC works.</p><p>During my course of learning MVC I found so many factors that differentiates between a webform approach and a MVC approach. Later I realized that these differentiating factors itself will lead you to decide which one can best fit your project requirement.</p><p>What was wrong with asp.net?<br>Asp.net webforms when released was the best idea Microsoft could give you. Later when the web application became more familiar, the usage increased and user interactivity, speed and other factors made the people realizing that there are some weakness in asp.net.</p><p><strong>1). Maintaining State (viewState)</strong><br>The actual mechanism of maintaining state across requests (ViewState) often results in giant blocks of data being transferred between client and server. It can reach hundreds of kilobytes in many real-world applications, and it goes back and forth with every request, frustrating site visitors with a long wait each time they click a button or try to move to the next page on a grid. ASP.NET AJAX suffers this just as badly,1 even though bandwidth-heavy page updating is one of the main problems that Ajax is supposed to solve.</p><p><strong>2). Page Load (page Life Cycle)</strong><br>The mechanism of connecting client-side events with serverside event handler code, part of the page life cycle, can be extraordinarily complicated and delicate. Few developers have success manipulating the control hierarchy at runtime without getting ViewState errors or finding that some event handlers mysteriously fail to execute.</p><p><strong>3). Limited control over HTML</strong><br>Server controls render themselves as HTML, but not necessarily the HTML you want. Not only does their HTML often fail to comply with web standards or make good use of CSS, but the system of server controls generates unpredictable and complex ID values, which are hard to access using JavaScript.</p><p><strong>4). False sense of separation of concerns</strong><br>ASP.NET’s code-behind model provides a means to take application code out of its HTML markup and into a separate code-behind class. This has been widely applauded for separating logic and presentation, but in reality, developers are encouraged to mix presentation code (e.g., manipulating the server-side control tree) with application logic (e.g., manipulating database data) in these same monstrous code-behind classes. Without better separation of concerns, the end result is often fragile and unintelligible.</p><p><strong>5). Untestable</strong><br>When ASP.NET’s designers first set out their platform, they could not have anticipated that automated testing would become such a mainstream part of software development as it is today. Not surprisingly, the architecture they designed is totally unsuitable for automated testing.</p><p>Now that’s about webforms . That doesn’t mean that webform approach is totally weak. These drawbacks are found when compared with the MVC framework. Let’s see how MVC answers these issues or what’s in MVC that makes it better than webforms.</p><p><strong>1). Separation of concerns and single responsibility principle.</strong><br>This is one of the best feature a developer would love to have in his coding. He would definitely love to keep his code neat, tidy, clean, modular, readable and maintainable. Its extremely important that a class in the system has a well-defined job for itself. No class should try to more than one job or too many things. If it does that it would be difficult to maintain the class.</p><p><strong>2). Full control over the rendered HTML.</strong><br>MVC gives full control over the rendered HTML. In webforms many times the HTML that is rendered is more complex than what is really required and thus makes it difficult for the designers to style the controls.</p><p><strong>3). Test driven approach (unit testing).</strong><br>This helps us to do the unit testing very easily. Webforms are tightly coupled to session, viewstate, request and response objects because of which it becomes a bad candidate for unit testing.</p><p><strong>4). Search engine optimizations and RESTful URL’s</strong><br>Webforms url has .aspx extensions whereas MVC urls does not have any extensions and thus becomes very search engine friendly. for example it have urls like “http://localhost:8080/appname/customer/list&quot; or like the ones you notice when browsing facebook. So effort needed for search engines to recognize you application becomes much easier.</p><p><strong>5). No ViewState.</strong><br>This one becomes a big relief in terms of performance during the request and response cycle. You might have noticed above how webforms handles viewstate and the consequences of that.</p><p><strong>6). Better control over JavaScript and styles</strong><br>Webforms may dynamically add so many JavaScript files to the application when some controls or third party controls are integrated with the application. For example when you integrate AJAX into you webforms you can see few ajax related script files getting included dynamically to your application. In MVC you can very well control and include the script files that are really needed.</p><p><strong>7). No IsPostBack branches of code.</strong><br>You can completely eliminate this additional branches on IsPostBack flag from MVC because MVC doesn’t support this flag. Instead it handles it in a different manner in the controller.</p><p>Here we come to an end of this article. I am sure this will really help many to have an idea about both webforms and MVC. I will still edit this article as and when i find some more informations.</p><p>Happy coding to all developers and Enjoy</p><p>You can read the same article from my blog <a href="http://kandynote.blogspot.in/2014/05/aspnet-webforms-or-aspnet-mvc.html">here</a></p><p><strong>You can buy me a coffee , if you like at </strong><a href="https://www.buymeacoffee.com/vipinc007"><strong>https://www.buymeacoffee.com/vipinc007</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1c391c7c3a4c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/tinywave/asp-net-webforms-vs-mvc-1c391c7c3a4c">ASP.net : Webforms VS MVC</a> was originally published in <a href="https://medium.com/tinywave">tinywave</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to pass a component to a template stored in different/separate  file in vuejs]]></title>
            <link>https://medium.com/tinywave/how-to-pass-a-component-to-a-template-stored-in-different-separate-file-in-vuejs-6fad1b6c93c4?source=rss----b73956242a6b---4</link>
            <guid isPermaLink="false">https://medium.com/p/6fad1b6c93c4</guid>
            <category><![CDATA[vuejs-template-splitting]]></category>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[vuejs-include-a-component]]></category>
            <category><![CDATA[vuejs-dynamic-component]]></category>
            <category><![CDATA[vuejs-component]]></category>
            <dc:creator><![CDATA[Vipin Cheriyanveetil]]></dc:creator>
            <pubDate>Mon, 01 Apr 2019 05:21:10 GMT</pubDate>
            <atom:updated>2019-04-01T05:22:02.275Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to pass a component to a template stored in different/separate file in vuejs</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*3kYR4er6jm5p-1XxRaWb5g.png" /></figure><p>Hello, If we take <strong>vuejs </strong>Single File Component , I would say that’s a very good feature <strong>vuejs </strong>has and I like to use it often in my projects. It all looks good when we can see all 3 of them (<strong>template</strong>, <strong>script </strong>and <strong>style</strong>) in a single file. Its easy to read and manage when the template html is small and simple.</p><p>But when you have a html of larger size , it is always advisable to break the portions of HTML to smaller components and include them as components. Like the below example</p><h3>Use component when the template is in the same file</h3><pre>&lt;template&gt;<br>      &lt;div&gt;Login&lt;/div&gt;    <br>      &lt;LoginPage msg=&quot;Welcome to Your Vue.js App&quot; /&gt;<br>&lt;/template&gt;</pre><pre>&lt;script&gt;<br>import LoginPage from &quot;@/components/LoginPage.vue&quot;;</pre><pre>export default {<br>  name: &quot;login&quot;,<br>  components: {<br>    LoginPage<br>  },<br>  methods :<br>  {<br>    <br>  }<br>};<br>&lt;/script&gt;<br>&lt;style&gt;<br>&lt;/style&gt;</pre><p>In the above example you can see how easily the <strong>LoginPage </strong>componenet is used or injected to the main template. Its so easy , isn’t it ?</p><h3>Use component when the template is in a separate file</h3><p>Now what if we move the main template to a different file and refer it using the <strong>src </strong>attribute. Like below</p><pre>&lt;template src=&quot;partials/main.html&quot;&gt;<br>&lt;/template&gt;</pre><pre>&lt;script&gt;<br>import LoginPage from &quot;@/components/LoginPage.vue&quot;;</pre><pre>export default {<br>  name: &quot;login&quot;,<br>  components: {<br>    LoginPage<br>  },<br>  methods :<br>  {<br>    <br>  }<br>};<br>&lt;/script&gt;<br>&lt;style&gt;<br>&lt;/style&gt;</pre><p>Then, its not easy to include the component like the above straight manner. Here we need to use the dynamic component technique . See the below example.</p><p>The template file “partials/main.html” would look like below</p><pre>&lt;div&gt;Login&lt;/div&gt;    <br>&lt;component :is=&quot;LoginPage_component&quot;&gt;&lt;/component&gt;</pre><p>And the parent component would look like this</p><pre>&lt;template src=&quot;partials/main.html&quot;&gt;<br>&lt;/template&gt;</pre><pre>&lt;script&gt;<br>import LoginPage from &quot;@/components/LoginPage.vue&quot;;</pre><pre>export default {<br>  name: &quot;login&quot;,<br>  components: {<br>    LoginPage<br>  },<br>  data() {<br>    return { <br>      LoginPage_component: &#39;LoginPage&#39;<br>      };<br>  }<br>};<br>&lt;/script&gt;<br>&lt;style&gt;<br>&lt;/style&gt;</pre><p>That’s it :) , and that will work.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6fad1b6c93c4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/tinywave/how-to-pass-a-component-to-a-template-stored-in-different-separate-file-in-vuejs-6fad1b6c93c4">How to pass a component to a template stored in different/separate  file in vuejs</a> was originally published in <a href="https://medium.com/tinywave">tinywave</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to solve the Vue.js UI error during new installation]]></title>
            <link>https://medium.com/tinywave/how-to-solve-the-vue-js-ui-error-during-new-installation-aba068b2522c?source=rss----b73956242a6b---4</link>
            <guid isPermaLink="false">https://medium.com/p/aba068b2522c</guid>
            <category><![CDATA[vue-ui-issue]]></category>
            <category><![CDATA[vue-ui-not-loading]]></category>
            <category><![CDATA[vue-ui-error]]></category>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[vue-ui]]></category>
            <dc:creator><![CDATA[Vipin Cheriyanveetil]]></dc:creator>
            <pubDate>Sun, 31 Mar 2019 06:56:12 GMT</pubDate>
            <atom:updated>2019-03-31T06:56:12.164Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*91J3P-jXD2bRklvC2s92uw.jpeg" /></figure><p>Hello,</p><p><strong>Vue.js</strong> is one of the best framework available out there which can help us to build interactive applications . I recently started working on vue.js and I quite liked it when compared with other frameworks like angular ect.</p><p>But certain things with this framework are really a painful and its fades away the beauty of this framework. especially the installation process and getting all boxes working is not that easy sometimes. I had difficulties in installing this framework on my windows 10 laptop. One thing missing is a good documentation for this framework. I have seen people in the internet talking about various problems they are facing with the initial setup of this framework and the numbers are large.</p><p>Below is the issue I faced and how I rectified them</p><h3>Vue UI not working as expected: Hanged &amp; unable to create new project</h3><p>So I did the following steps during my installation</p><ol><li>Installed <strong>Node.js </strong>(version : v11) : <em>Installation was good</em></li><li>Installed <strong>vue/cli</strong> (version 3.5.3) : Installation was confusing because it showed me few warnings on the screen and displayed certain packages to be installed by self. I searched all over google and couldn&#39;t find anything as a problem.</li><li>I then started <strong>vue UI</strong> . The UI got started and it opened itself on a browser and I then went to “create Projects screen and then found that that screen was not working and I was not able to create a new project. The screen was still in loading state . The was loaded after 15–20 minutes and I then got the “create project “ wizard. I filled all the required field and pressed the “finish” button and it hanged again. SO nothing got created even after 20–30 minutes.</li><li>Did a google search again : I saw most of them had some or other problems with installation and nobody had a proper solution. Somewhere in one of the blog I noticed on post that the problem could be the node.js version. The post said about downgrading the node.js to 8.9 or above.</li><li>Downgraded <strong>Node.js</strong> : I uninstalled everything (node, vue.js ) . Then I reinstalled Node v8.15 and installed vue/cli v3.5.3 .</li><li>Started <strong>vue UI</strong> again : The UI came up on a browser and voila , the create project was loaded quickly this time and I created my first vue.js project withing few seconds. The vue UI looks so beautiful.</li></ol><p>So, If somebody is also facing the same issue try downgrading the Node.js version. Hope this helps</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aba068b2522c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/tinywave/how-to-solve-the-vue-js-ui-error-during-new-installation-aba068b2522c">How to solve the Vue.js UI error during new installation</a> was originally published in <a href="https://medium.com/tinywave">tinywave</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to use Mysqli with PHP]]></title>
            <link>https://medium.com/tinywave/how-to-use-mysqli-with-php-2166d8e59b8d?source=rss----b73956242a6b---4</link>
            <guid isPermaLink="false">https://medium.com/p/2166d8e59b8d</guid>
            <category><![CDATA[learn-php-and-mysqli]]></category>
            <category><![CDATA[mysql]]></category>
            <category><![CDATA[database-development]]></category>
            <category><![CDATA[mysqli]]></category>
            <category><![CDATA[php]]></category>
            <dc:creator><![CDATA[Vipin Cheriyanveetil]]></dc:creator>
            <pubDate>Thu, 28 Mar 2019 13:43:32 GMT</pubDate>
            <atom:updated>2019-03-28T13:43:32.230Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*vopRGII6LMo1JZfg2MP-gA.png" /></figure><p>Hello,</p><p>We are not new to Mysqli especially those who work with PHP+ mysql development. If by any chance you are new to it , then The MySQLi Extension (MySQL Improved) is a relational database driver used in the PHP scripting language to provide an interface with MySQL databases.</p><p>Mysqli can be used to achieve almost all actions on Mysql with the help of PHP. So its very simple and I love and use them in my projects. Below I have some code samples to implement few database activities using Mysqli + PHP.</p><p>Note: All the examples below use the <strong>Object Oriented Approach</strong> of using Mysqli and I assume that you know how to execute a php application.</p><h3>Connect to database using Mysqli</h3><p>This is the most important and the first thing every developer would do to check if the given credentials really work or not. Example would go like this.</p><pre>&lt;?php<br> $host = &quot;localhost&quot;;<br> $user = &quot;root&quot;;<br> $password = &quot;&quot;;<br> $database = &quot;School&quot;;<br> <br> $mysqli = new mysqli($host, $user, $password, $database);<br> if ($mysqli-&gt;connect_errno)<br> {<br>  echo &quot;Failed to connect to MySQL: &quot; . $mysqli-&gt;connect_error;<br> }<br>?&gt;</pre><p>Ahh, Great. If you got the connection right then let’s do more now.</p><h3>Execute a query</h3><p>Once connected the next thing we all try is to execute a query and see if that works.</p><pre>// Note: There should be connection code here</pre><pre>if ($mysqli-&gt;query(&quot;CREATE TABLE Student(id int, name varchar(20))&quot;)) {<br>    printf(&quot;Table Studentsuccessfully created.\n&quot;);<br>}</pre><p>After executing , have a look in to the database using phpmyadmin or any other database client and if you find a new table created with name “Student” , then it is really working and wow wow……</p><p>Well Done :) , Lets something interesting now. Let me insert some Student details. For that I would execute the below statement</p><h3>Execute Some Insert Statements</h3><pre>// Note: There should be connection code here</pre><pre>if ($mysqli-&gt;query(&quot;insert into Student values (1,&#39;Vipin&#39;)&quot;)) {<br>    printf(&quot;Student Record Inserted.\n&quot;);<br>}<br>if ($mysqli-&gt;query(&quot;insert into Student values (2,&#39;Rahul&#39;)&quot;)) {<br>    printf(&quot;Student Record Inserted.\n&quot;);<br>}<br>if ($mysqli-&gt;query(&quot;insert into Student values (3,&#39;Steve&#39;)&quot;)) {<br>    printf(&quot;Student Record Inserted.\n&quot;);<br>}</pre><p>The above should print the “<strong>Student Record Inserted</strong>” text thrice on the screen indicating that it did what we asked for. Now go look into the table and see if we have three records. If yes wow, we did it…..</p><h3>Let’s fetch the records now from mysql</h3><p>Now that we added some records , its now a good deal to fetch it and display it on screen. For that I would do the following..</p><p><strong>1). First let me look at the number of records in the table using PHP+mysqli</strong></p><pre>// Note: There should be connection code here<br>if ($result = $mysqli-&gt;query(&quot;SELECT * from Student&quot;)) <br> {</pre><pre>     /* determine number of rows result set */<br>     $row_cnt = $result-&gt;num_rows;</pre><pre>     printf(&quot;Result set has %d rows.\n&quot;, $row_cnt);</pre><pre>     /* close result set */<br>     $result-&gt;close();<br> }</pre><p>This is going to print me “<strong>Result set has 3 rows</strong>”. And that’s good to see the number of records retrieved by the query.</p><p><strong>1). Second let me print the records using PHP+mysqli</strong></p><pre>// Note: There should be connection code here<br>$query = &quot;SELECT * from Student&quot;;<br>if ($result = $mysqli-&gt;query($query)) <br>{</pre><pre>     /* fetch associative array */<br>     while ($row = $result-&gt;fetch_assoc()) <br>     {</pre><pre>      echo $row[&quot;id&quot;].&quot; , &quot;.$row[&quot;name&quot;].&quot;&lt;br /&gt;&quot;;<br> <br>     }</pre><pre>     /* free result set */<br>     $result-&gt;free();<br>}</pre><p>After execution the print would be</p><p>1 , Vipin</p><p>2 , Rahul</p><p>3 , Steve</p><p>There are other ways of fetching the records too. let’s see them too in action.</p><h3>Fetch records using mysqli_result::fetch_array</h3><ol><li>Using <strong>MYSQLI_NUM</strong></li></ol><p>This method fetches all records but the columns can be referred by their index number. see the example below</p><pre>$query = &quot;SELECT * from Student&quot;;<br> if ($result = $mysqli-&gt;query($query)) <br> {</pre><pre>     while ($row = $result-&gt;fetch_array(MYSQLI_NUM)<br>     {<br>       echo $row[0].&quot; , &quot;.$row[1].&quot;&lt;br /&gt;&quot;;<br>     }<br> }</pre><p>2. Using <strong>MYSQLI_ASSOC</strong></p><p>This method fetches all records and the columns can be referred by their column name. see the example below</p><pre>$query = &quot;SELECT * from Student&quot;;<br> if ($result = $mysqli-&gt;query($query)) <br> {</pre><pre>while ($row = $result-&gt;fetch_array(MYSQLI_NUM)<br>     {<br>       echo $row[&quot;id&quot;].&quot; , &quot;.$row[&quot;name&quot;].&quot;&lt;br /&gt;&quot;;<br>     }<br> }</pre><p>3. Using <strong>MYSQLI_BOTH</strong></p><p>This method fetches all records and the columns can be referred by their column name as well as with the column index number. see the example below</p><pre>$query = &quot;SELECT * from Student&quot;;<br> if ($result = $mysqli-&gt;query($query)) <br> {</pre><pre>while ($row = $result-&gt;fetch_array(MYSQLI_NUM)<br>     {<br>       echo $row[&quot;id&quot;].&quot; , &quot;.$row[&quot;name&quot;].&quot;&lt;br /&gt;&quot;;<br>       echo $row[0].&quot; , &quot;.$row[1].&quot;&lt;br /&gt;&quot;;</pre><pre>     }<br> }</pre><h3>Setting connection timeout</h3><p>This is sometimes very useful when you get a timeout issue with the connection mainly because the query is taking too long to run and come back with results. There could be various other reasons too . One thing we can do here is increase the timeout duration like the below example</p><pre>$mysqli = new mysqli(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_NAME);<br>if (mysqli_connect_errno()) <br>{<br>            echo &quot;Failed to connect to MySQL: &quot; .               <br>            mysqli_connect_error();<br>}<br>$mysqli -&gt;options(MYSQLI_OPT_CONNECT_TIMEOUT, 500);</pre><h3>Get the Last Inserted Auto Increment ID</h3><p>This is very useful when you want to know what was the primary key id inserted by the insert query. Have a look at the below example</p><pre>if ($result = $mysqli-&gt;query(&quot;Insert into emp (name) values(‘vipin’)&quot;))</pre><pre>{<br> $new_row_id = $mysqli -&gt;insert_id;</pre><pre>}</pre><p>The variable “$new_row_id” will have the new primary key values on the records inserted.</p><p>Hope this tutorial is useful. I will be updating the same with more stuff when I come across more examples.</p><p>Enjoy :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2166d8e59b8d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/tinywave/how-to-use-mysqli-with-php-2166d8e59b8d">How to use Mysqli with PHP</a> was originally published in <a href="https://medium.com/tinywave">tinywave</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angularjs | Search an array for exact match]]></title>
            <link>https://medium.com/tinywave/angularjs-search-an-array-for-exact-match-96ba3a4ce002?source=rss----b73956242a6b---4</link>
            <guid isPermaLink="false">https://medium.com/p/96ba3a4ce002</guid>
            <category><![CDATA[angularjs-search-an-array]]></category>
            <category><![CDATA[angularjs]]></category>
            <category><![CDATA[angularjs-fillters]]></category>
            <category><![CDATA[angularjs-search]]></category>
            <category><![CDATA[make-an-exact-search]]></category>
            <dc:creator><![CDATA[Vipin Cheriyanveetil]]></dc:creator>
            <pubDate>Thu, 07 Feb 2019 12:08:50 GMT</pubDate>
            <atom:updated>2019-02-22T05:14:22.792Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*Mp7MmRwhogAIE8QJUQ0eNw.png" /></figure><p>Angularjs has “$Filter” filter which can be used to search an array. One other thing what I found is that It even has options to decide if you want to make an exact search or partial match search (just like the LIKE search in sql querys).</p><p><strong>Here is an example</strong></p><pre>$scope.Students = [<br>{ID:&#39;100&#39;, Name:&#39;vipin&#39;, Mark:&#39;100&#39;},<br>{ID:&#39;10&#39;, Name:&#39;Sharon&#39;, Mark:&#39;10&#39;},<br>{ID:&#39;20&#39;, Name:&#39;Bill&#39;, Mark:&#39;75&#39;},<br>];</pre><p>Now am gonna do a search for ID=10.</p><pre>var flist = $filter(&#39;filter&#39;)($scope.Students, { ID: 10 });</pre><p>I expect it to return me the second item in the list.</p><p>expected</p><pre>{ID:&#39;10&#39;, Name:&#39;Sharon&#39;, Mark:&#39;10&#39;}</pre><p>output</p><pre>{ID:&#39;100&#39;, Name:&#39;vipin&#39;, Mark:&#39;100&#39;},<br>{ID:&#39;10&#39;, Name:&#39;Sharon&#39;, Mark:&#39;10&#39;},</pre><p>Oh Its more than what I need. So, what happened here is , it did a non exact match search and it has found two rows which is correct too. It filtered ID:100 because it has ‘10’ at the beginning. So it did a <strong>like ‘10%’ </strong>search. Hmm, now we have some work here</p><p><strong>How to do an exact match search ?</strong></p><p>Do it this way .</p><pre>var flist = $filter(&#39;filter&#39;)($scope.Students, { ID: 10 }, <strong>true</strong>);</pre><p>Just add that second boolean parameter as <strong>true </strong>after the search criteria. By default this parameter is set to <strong>false</strong>.</p><p>then see the output</p><pre>{ID:&#39;10&#39;, Name:&#39;Sharon&#39;, Mark:&#39;10&#39;},</pre><p>Voila, am happy now , its wonderful and I liked it.</p><p>Hope this will be useful to somebody.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=96ba3a4ce002" width="1" height="1" alt=""><hr><p><a href="https://medium.com/tinywave/angularjs-search-an-array-for-exact-match-96ba3a4ce002">Angularjs | Search an array for exact match</a> was originally published in <a href="https://medium.com/tinywave">tinywave</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>