Skip to content

Instantly share code, notes, and snippets.

View mikecabana's full-sized avatar
✌️
dilly dallying

Michael Cabana mikecabana

✌️
dilly dallying
View GitHub Profile
@mikecabana
mikecabana / oidc-auth.service.ts
Last active August 8, 2018 13:58 — forked from danielcrisp/auth.service.ts
Oidc Client Authorization Service - Async HTTP Interceptors | Angular 6.x | rxjs 6.x
import { Injectable } from '@angular/core';
import { UserManager, User } from 'oidc-client';
import { Observable, from } from 'rxjs';
@Injectable({
providedin: 'root'
})
export class AuthService {
private userManager: UserManager;
@mikecabana
mikecabana / authorization-token-interceptor.service.ts
Last active January 16, 2019 09:31 — forked from danielcrisp/token.interceptor.ts
Authorization Token Interceptor Service - Async HTTP Interceptors | Angular 6.x | rxjs 6.x
import { Injectable } from '@angular/core';
import { HttpErrorResponse, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';
import { Observable } from 'rxjs';
import { mergeMap } from 'rxjs/operators';
import { User } from 'oidc-client';
import { AuthService } from './oidc-auth.service.ts';
@Injectable({
providedIn: 'root'
@mikecabana
mikecabana / remove-node-modules-recursive.bat
Last active August 11, 2020 21:06
Remove recursively node_modules folders on Windows machines
REM Windows CMD
REM List all the node_modules folders
FOR /d /r . %d in (node_modules) DO @IF EXIST "%d" echo "%d"
REM Remove all the node modules folders
FOR /d /r . %d in (node_modules) DO @IF EXIST "%d" del /q /s "%d"
@mikecabana
mikecabana / remove-node-modules-recursive.sh
Created August 11, 2020 21:23
Remove recursively node_modules folders on Mac/Linux machines
# Mac/Linux Terminal
# List all node_modules folders in a directory
find . -name "node_modules" -type d -prune -print | xargs du -chs
# Delete all node_modules folders in a directory
find . -name 'node_modules' -type d -prune -print -exec rm -rf '{}' \;
@mikecabana
mikecabana / remove-node-modules-recursive.ps1
Last active August 11, 2020 21:26
Remove recursively node_modules folders on Windows machines using powershell
# Windows Powershell
# 1. cd into the root directory you want to start from
# 2. run the follwing command
Get-ChildItem -Path "." -Include "node_modules" -Recurse -Directory | Remove-Item -Recurse -Force
@mikecabana
mikecabana / pkce-generators.js
Last active March 3, 2022 12:47
Sample code_verifier and code_challenge generators for OAuth PKCE + Code Flow
/**
* Based on spec: https://tools.ietf.org/html/rfc7636#section-4
* Uses: https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/crypto-js.min.js
*/
/**
*
* Static values
*
*/
@mikecabana
mikecabana / generic-polling.js
Created November 5, 2021 14:21
Generic Polling in Javascript
// curtesy of this post https://levelup.gitconnected.com/polling-in-javascript-ab2d6378705a
const poll = async ({ fn, validate, interval, maxAttempts }) => {
let attempts = 0;
const executePoll = async (resolve, reject) => {
const result = await fn();
attempts++;
const validationResult = await validate(result);
@mikecabana
mikecabana / server.js
Created July 10, 2023 03:18
Edit contact HTMX example
const http = require('http');
const querystring = require('querystring');
const host = 'localhost';
const port = 1235;
const contact = { firstName: 'Joe', lastName: 'Blow', email: '[email protected]' };
const server = http.createServer(function (req, res) {
res.setHeader('Access-Control-Allow-Origin', '*');
@mikecabana
mikecabana / stock_cli.py
Created February 23, 2024 20:47
Terminal stock ticker - generated by Chat GPT 3.5
import os
import platform
import yfinance as yf
import time
import sys
import warnings
def clear_terminal():
# Clear terminal screen based on the operating system
if platform.system() == 'Windows':