Skip to content

Instantly share code, notes, and snippets.

Ravi ravivit9

Block or report user

Report or block ravivit9

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View angular-form-presentation.md

All about forms in Angular

✏️ by Jiyoon Koo


View muitpleFormControl.md

Angular - Form With Multiple Input Field

SOURCE, SOURCE

contact-information.component.html:

<div id="ContactInput" fxLayout="column" [formGroup]="contactForm">
    <mat-form-field appearance="standard" fxFlex color="accent">
        <mat-label>{{'ContactInformation.customer_name_heading' | translate}}</mat-label>
@ravivit9
ravivit9 / geo.js
Created Mar 19, 2019 — forked from mkhatib/geo.js
A Javascript utility function to generate number of random Geolocations around a center location and in a defined radius.
View geo.js
/**
* Generates number of random geolocation points given a center and a radius.
* @param {Object} center A JS object with lat and lng attributes.
* @param {number} radius Radius in meters.
* @param {number} count Number of points to generate.
* @return {array} Array of Objects with lat and lng attributes.
*/
function generateRandomPoints(center, radius, count) {
var points = [];
for (var i=0; i<count; i++) {
@ravivit9
ravivit9 / reduce-from-array-for-matching-criteria
Created Jul 11, 2018
Search for a string value from an array of items and return those matching array items.
View reduce-from-array-for-matching-criteria
var dataset = [2,2,4,2,6,4,7,8];
var search = 2;
var count = dataset.reduce(function(n, val) {
return n + (val === search);
}, 0);
console.log(count);
@ravivit9
ravivit9 / array-of-objects-filter-by-property
Created Jul 11, 2018
The array of objects will be filtered based on a object.property value.
View array-of-objects-filter-by-property
people = [
{name: 'Mary', gender: 'girl'},
{name: 'Paul', gender: 'boy'},
{name: 'John', gender: 'boy'},
{name: 'Lisa', gender: 'girl'},
{name: 'Bill', gender: 'boy'},
{name: 'Maklatura', gender: 'girl'}
]
var numBoys = people.reduce(function (n, person) {
View slideInOut-AngularAnimation.ts
@Component({
selector: 'app-actions',
templateUrl: './actions.component.html',
styleUrls: ['./actions.component.scss'],
animations: [
trigger('slideInOut', [
state('in', style({
'max-height': '500px', 'opacity': '1', 'visibility': 'visible'
})),
state('out', style({
@ravivit9
ravivit9 / uniq.js
Created Jul 3, 2018 — forked from telekosmos/uniq.js
Remove duplicates from js array (ES5/ES6)
View uniq.js
var uniqueArray = function(arrArg) {
return arrArg.filter(function(elem, pos,arr) {
return arr.indexOf(elem) == pos;
});
};
var uniqEs6 = (arrArg) => {
return arrArg.filter((elem, pos, arr) => {
return arr.indexOf(elem) == pos;
});
View cleanup-ssh.sh
#!/bin/bash
if [ "$GIT_SSH_KEY" != "" ]; then
echo "Cleaning up SSH config" >&1
echo "" >&1
# Now that npm has finished running,
# we shouldn't need the ssh key/config anymore.
# Remove the files that we created.
rm -f ~/.ssh/config
rm -f ~/.ssh/deploy_key
View Angular2 Geolocation service
import {Injectable, provide} from 'angular2/core';
import {Observable} from 'rxjs';
const GEOLOCATION_ERRORS = {
'errors.location.unsupportedBrowser': 'Browser does not support location services',
'errors.location.permissionDenied': 'You have rejected access to your location',
'errors.location.positionUnavailable': 'Unable to determine your location',
'errors.location.timeout': 'Service timeout has been reached'
};
@ravivit9
ravivit9 / sortObj.js
Created Jan 14, 2016 — forked from CFJSGeek/sortObj.js
JS: Sort a JavaScript object by key in alphabetical order case insensitive. Thanks to Arne Martin Aurlien and Ivan Krechetov for inspiration. #snippet
View sortObj.js
/**
* Sort JavaScript Object
* CF Webtools : Chris Tierney
* obj = object to sort
* order = 'asc' or 'desc'
*/
function sortObj( obj, order ) {
"use strict";
var key,
You can’t perform that action at this time.