Skip to content

Instantly share code, notes, and snippets.

View praveenpuglia's full-sized avatar
👨‍💻
...human in progress

Praveen Puglia praveenpuglia

👨‍💻
...human in progress
View GitHub Profile
<!-- <div class="date-range">
<div class="date-range__presets">
<button #presetsTrigger
mat-raised-button
[matMenuTriggerFor]="presetMenu"
(click)="$event.stopPropagation()">{{selectedPreset.name}}
<mat-icon>arrow_drop_down</mat-icon>
</button>
<mat-menu #presetMenu="matMenu"
[overlapTrigger]="false">
@praveenpuglia
praveenpuglia / javascript-qiucksort.js
Created July 26, 2018 18:19
Quick Sort implemented in JS
function quickSort(array, left = 0, right = array.length - 1) {
console.log("CALLED");
let partitionIndex;
let pivotIndex;
if(left < right) {
pivotIndex = right;
partitionIndex = partition(array, left, right, pivotIndex);
quickSort(array, left, partitionIndex - 1);
quickSort(array, partitionIndex + 1, right);
}
@praveenpuglia
praveenpuglia / vue-apollo.ts
Created May 31, 2019 09:22
vue-apollo.ts configuration
import Vue from 'vue';
import VueApollo from 'vue-apollo';
import {
createApolloClient,
restartWebsockets
} from 'vue-cli-plugin-apollo/graphql-client';
import ApolloClient from 'apollo-client';
import { InMemoryCache } from 'apollo-cache-inmemory';
import { SubscriptionClient } from 'subscriptions-transport-ws';
import router from '@/router';
@praveenpuglia
praveenpuglia / test_data.json
Created September 13, 2019 06:59
D3 Cluster Test Data
{
"name": "Issues",
"children": [
{
"name": "Word 1",
"children": [
{
"value": 8052,
"name": "Word 1"
},
@praveenpuglia
praveenpuglia / multiple-actions.ts
Created April 25, 2018 18:24
Dispatch multiple actions from ngrx effect
@Effect()
search$: Observable<Action> = this.actions$.pipe(
ofType(SearchActions.SEARCH),
switchMap(action => {
const query = action.payload;
return [new FetchPanel1Data(query), new FetchPanel2Data(query)];
})
);
@praveenpuglia
praveenpuglia / javascript-deep-flatten.js
Created July 27, 2018 14:37
Deep flatten a JavaScript array using Array.prototype.reduce
function flatten(array) {
return array.reduce( (acc, e) => {
if(Array.isArray(e)) {
// if the element is an array, fall flatten on it again and then take the returned value and concat it.
return acc.concat(flatten(e));
} else {
// otherwise just concat the value.
return acc.concat(e);
}
}, [] ) // initial value for the accumulator is []
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Filtering vs Splicing</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
<!doctype html>
<html>
<head>
<title>Rich Text Editor - FROM MDN!</title>
<script type="text/javascript">
var oDoc, sDefTxt;
function initDoc() {
oDoc = document.getElementById("textBox");
sDefTxt = oDoc.innerHTML;
@praveenpuglia
praveenpuglia / same-effect-multiple-actions.ts
Created April 25, 2018 19:04
Same effect for multiple actions - ngrx effects
@Effect({dispatch: false})
entityCreationSuccess$: Observable<Action> = this.actions$.pipe(
ofType(UserActions.CREATE_USER_SUCCESS, PostActions.CREATE_POST_SUCCESS),
tap(action => {
this.router.navigate(['../'], {relativeTo: this.route})
})
);
@praveenpuglia
praveenpuglia / data.json
Created September 14, 2022 10:33
Mock Smallcases Data
[
{
"name": "Assistix",
"manager": "Fuelton",
"cagr": 3.720808713691426,
"createdDate": 1586810446274,
"avatar": "https://picsum.photos/id/133/200",
"volatility": "high",
"minInvestmentAmount": 49162.31361884028,
"description": "Lorem tempor consectetur minim laboris incididunt adipisicing voluptate Lorem ut eiusmod.",