Skip to content

Instantly share code, notes, and snippets.

View mohanramphp's full-sized avatar

Mohan Ram mohanramphp

View GitHub Profile
<?php
echo "This is sample page";
?>
@mohanramphp
mohanramphp / self calling function
Created June 8, 2018 10:35
This gist is to explain the self calling function
(function(){
console.log('I called myself');
})();
@mohanramphp
mohanramphp / tsconfig.json
Created June 17, 2018 06:46
To show how the library got referred in the tsconfig.json file
{
"compileOnSave": false,
...
...
"paths": {
"ratify": [
"dist/ratify"
],
"ratify/*": [
"dist/ratify/*"
@mohanramphp
mohanramphp / angular.json
Created June 17, 2018 06:49
To show how library is configured with the angular.json file
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"angular-component-library": {
"root": "",
"sourceRoot": "src",
...
...
@mohanramphp
mohanramphp / app.module.ts
Created June 17, 2018 07:03
To show how to inlcude the library module in app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { RatifyModule } from 'ratify'; // <-- import the RatifyModule from ratify library we built
@NgModule({
declarations: [
AppComponent
],
@mohanramphp
mohanramphp / app.component.ts
Created June 17, 2018 07:08
To show the configuration need to pass for lib-ratify component in the template
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
grade = 0; // current rating - default to pass to the component
maxRating = 5; // max rating - can be 5 or 10. Based on user convinence
@mohanramphp
mohanramphp / app.component.html
Created June 17, 2018 07:10
This to show how to use the rating component by sending the configuration to that component
<div style="text-align:center">
<h1>
Lets rate it!
</h1>
<lib-ratify [grade]="grade" [maxRating]="maxRating" [showRatingCounter]="showRatingCounter" (triggerRatingSelection)="selectedRating($event)"></lib-ratify>
<h1 *ngIf="myRating">
Rated to {{myRating}}
</h1>
</div>
@mohanramphp
mohanramphp / package.json
Last active June 17, 2018 07:16
This is to show the commands to built angular component library
{
"name": "angular-component-library",
"version": "0.0.0",
"scripts": {
"prestart": "npm install",
"ng": "ng",
"start": "ng serve",
...
...
"build-lib": "ng build --prod ratify", // To built the library for production
@mohanramphp
mohanramphp / modern_js.md
Created July 14, 2018 11:14 — forked from gaearon/modern_js.md
Modern JavaScript in React Documentation

If you haven’t worked with JavaScript in the last few years, these three points should give you enough knowledge to feel comfortable reading the React documentation:

  • We define variables with let and const statements. For the purposes of the React documentation, you can consider them equivalent to var.
  • We use the class keyword to define JavaScript classes. There are two things worth remembering about them. Firstly, unlike with objects, you don't need to put commas between class method definitions. Secondly, unlike many other languages with classes, in JavaScript the value of this in a method [depends on how it is called](https://developer.mozilla.org/en-US/docs/Web/Jav
@mohanramphp
mohanramphp / screening.js
Created July 20, 2018 07:54 — forked from jgornick/screening.js
JS: Interview Questions
// 1: how could you rewrite the following to make it shorter?
if (foo) {
bar.doSomething(el);
} else {
bar.doSomethingElse(el);
}
Answer:
bar[foo ? 'doSomething' : 'doSomethingElse'](el);