Skip to content

Instantly share code, notes, and snippets.

@jhahspu
jhahspu / material.module.ts
Last active March 15, 2021 10:27
material-module
import { NgModule } from '@angular/core';
// import { MatAutocompleteModule } from '@angular/material/autocomplete';
// import { MatBadgeModule } from '@angular/material/badge';
import { MatButtonModule } from '@angular/material/button';
// import { MatButtonToggleModule } from '@angular/material/button-toggle';
// import { MatCardModule } from '@angular/material/card';
// import { MatCheckboxModule } from '@angular/material/checkbox';

Generate guard

ng g guard guards/auth
  -> select "canActivate"

auth.guard.ts

import { Injectable } from '@angular/core';
import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, Router } from '@angular/router';
<?php

function json_response($code = 200, $message = null)
{
    // clear the old headers
    header_remove();
    // set the actual code
    http_response_code($code);
    // set the header to make sure cache is forced
@jhahspu
jhahspu / sass_theming.scss
Created January 3, 2021 12:36
sass theming
$theme-1: (
container: (
bg: #e4ada7,
color: #000,
border-color: #000
),
left: (
bg: #d88880,
color: #fff,
height: 100%,
@jhahspu
jhahspu / jwt_basics.md
Last active February 2, 2021 11:09
JWT

Refresh Tokens

  • JWTs are meant to be short lived (minutes)
@jhahspu
jhahspu / web_comp_modal.md
Last active February 2, 2021 12:43
Web Components
class Modal extends HTMLElement {
    constructor() {
        super();
        this._modalVisible = false;
        this._modal;
        this.attachShadow({ mode: 'open' });
        this.shadowRoot.innerHTML = `
 
@jhahspu
jhahspu / aws_rek.md
Last active December 6, 2024 18:14
Python
// Assume we have the following data in the Database:
{
  "name": {
    "first": "Ada",
    "last": "Lovelace"
  }
}
@jhahspu
jhahspu / lodash_basics.md
Last active March 18, 2025 05:02
Lodash
$ npm install --save lodash

# This is the new bit here: 
$ npm install --save-dev @types/lodash
@jhahspu
jhahspu / rxjs_map.md
Last active February 2, 2021 12:42
RxJS

RxJS MAP

Number operations

const numbers = [1, 2, 3, 4, 5];
const numbersTimesTen = numbers.map(number => number * 10);
// [10,20,30,40,50]
console.log(numbersTimesTen);
// [1,2,3,4,5]