Skip to content

Instantly share code, notes, and snippets.

View pertrai1's full-sized avatar
🏠
Working from home

Rob Simpson pertrai1

🏠
Working from home
  • Warrenton, VA
View GitHub Profile
@pertrai1
pertrai1 / ohmyposhv3-v2.json
Last active October 24, 2021 02:15 — forked from shanselman/ohmyposhv3-v2.json
ohmyposhv3-v2
{
"final_space": true,
"console_title": true,
"console_title_style": "folder",
"blocks": [
{
"type": "prompt",
"alignment": "left",
"horizontal_offset": 0,
"vertical_offset": 0,
@pertrai1
pertrai1 / wallaby.js
Created December 14, 2020 14:40
Wallaby
// before starting: npm i -D ngx-wallaby-jest
const ngxWallabyJest = require('ngx-wallaby-jest');
module.exports = function(wallaby) {
return {
files: [
'src/**/*.+(ts|html|json|snap|css|less|sass|scss|jpg|jpeg|gif|png|svg)',
'tsconfig.json',
'jest.config.js',
'tsconfig.spec.json',
@pertrai1
pertrai1 / collectionSum.js
Last active December 8, 2020 10:00
collectionSum
const collectionSum = (collection) => {
const iterator = collection.iterator();
let eachIteration;
let sum = 0;
while ((eachIteration = iterator(), !eachIteration.done)) {
sum += eachIteration.value;
}
@pertrai1
pertrai1 / component.html
Last active May 9, 2020 17:59
RxJS Data Composition
<div *ngIf="product$ | async as products">
<ul>
<li *ngFor="let product of products">
{{ product.name }}
</li>
</ul>
</div>
@pertrai1
pertrai1 / deep-freeze.ts
Created January 2, 2020 21:03
Deep Freeze
function deepFreeze(value) {
if (Array.isArray(value)) {
for (const element of value) {
deepFreeze(element);
}
Object.freeze(value);
} else if (typeof value === 'object' && value !== null) {
for (const v of Object.values(value)) {
deepFreeze(v);
}
@pertrai1
pertrai1 / pipe.ts
Created October 23, 2019 02:04
Angular HTML Pipe
import { Pipe, PipeTransform } from '@angular/core';
/*
* Strips HTML
* Takes an input parameter HTML.
* Usage:
* content | striphtml
* Example:
* <p [innerHTML]="content | striphtml"></p>
*/
@Pipe({
@pertrai1
pertrai1 / intersection.js
Last active March 12, 2019 05:49
Set, Map, WeakSet, WeakMap
let union = ( set1, set2 ) => {
return new Set([...set1, ...set2]);
}
let first = [1, 3, 1, 5, 7, 3, 9, 12, 15];
let second = [1, 20, 18, 5, 10, 3, 16];
union(first, second); /*? */
let intersection = (set1, set2) => {
@pertrai1
pertrai1 / map1.js
Created March 11, 2019 04:30
Map Reduce Example
const map = (fn, arr) => arr.reduce((acc, item) => {
return acc.concat(fn(item));
}, []);
const myArray = [2, 4, 6, 8];
const reduceFn = item => item * 2;
const myReducer = map(reduceFn, myArray);
@pertrai1
pertrai1 / csx-fn-challenge-4.js
Created June 22, 2018 11:14
CSX Function Challenge 4
let calls = "";
function jerry(str) {
kramer('Jerry');
}
function george(str) {
calls = str + 'George';
elaine(calls);
}
function add(a, b) {
return a + b;
}
function sub(a, b) {
return a - b;
}
function mul(a, b) {
return a * b;