Skip to content

Instantly share code, notes, and snippets.

@ravivit9
ravivit9 / array-of-objects-filter-by-property
Created July 11, 2018 14:46
The array of objects will be filtered based on a object.property value.
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) {
@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 July 3, 2018 15:29 — forked from telekosmos/uniq.js
Remove duplicates from js array (ES5/ES6)
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;
});
#!/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
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 January 14, 2016 21:02 — forked from christierney402/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
/**
* Sort JavaScript Object
* CF Webtools : Chris Tierney
* obj = object to sort
* order = 'asc' or 'desc'
*/
function sortObj( obj, order ) {
"use strict";
var key,
angular.module('restangularDemoApp', [
'restangular',
'ngCookies'
])
.constant('apiKey', 'YOUR_Mongolab_API_KEY')
.config(function(RestangularProvider, apiKey) {
RestangularProvider.setBaseUrl('https://api.mongolab.com/api/1/databases/YOURDATABASE/collections');
RestangularProvider.setDefaultRequestParams({
apiKey: apiKey
})
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>AngularJS Sorting &amp; Filtering Example</title>
<style type="text/css">
body{ font:12px arial, sans-serif; line-height:1.6em; margin:0 auto; max-width:960px; }
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs")
port = process.argv[2] || 8888;
http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname
, filename = path.join(process.cwd(), uri);
angular.module('testApp', []).
directive('lazyLoad', ['$window', '$q', function ($window, $q) {
function load_script() {
var s = document.createElement('script'); // use global document since Angular's $document is weak
s.src = 'https://maps.googleapis.com/maps/api/js?sensor=false&callback=initialize';
document.body.appendChild(s);
}
function lazyLoadApi(key) {
var deferred = $q.defer();
$window.initialize = function () {