Skip to content

Instantly share code, notes, and snippets.

View nivrith's full-sized avatar
🎸
Recreational Mathemusician

Nivrith nivrith

🎸
Recreational Mathemusician
View GitHub Profile
@nivrith
nivrith / webpack.config.ts
Created October 2, 2020 23:44
Webpack Config for Commandline Variables for Angular
import { CustomWebpackBrowserSchema, TargetOptions } from '@angular-builders/custom-webpack';
import * as webpack from 'webpack';
export default (
config: webpack.Configuration,
options: CustomWebpackBrowserSchema,
targetOptions: TargetOptions
) => {
config.plugins.push(
new webpack.DefinePlugin({
@nivrith
nivrith / app-env.ts
Last active October 6, 2020 02:54
Global App Environment file to define the schema of our environment variables
declare global {
/**
* @description
* Global commandline environment variables available to
* devserver build at runtime
*
*/
export const APP_ENV: {
/**
* @description
@nivrith
nivrith / main.ts
Created October 3, 2020 02:07
Import app environment schema for custom feature toggle
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
import '../tools/build/app-env'; // <- Import the app environment schema into our application bundle
if (environment.production) {
enableProdMode();
@nivrith
nivrith / angular.json
Created October 3, 2020 02:47
angular config for custom webpack builder
{
"architect": {
"build": {
"builder": "@angular-builders/custom-webpack:browser", // <- Change builder to Custom Webpack
"options": {
"customWebpackConfig": {
"path": "webpack.config.ts"
},
//...
},
@nivrith
nivrith / nvm-autouse.sh
Created October 10, 2020 03:35
NVM Auto use Bash
#
# Run 'nvm use' automatically every time there's
# a .nvmrc file in the directory. Also, revert to default
# version when entering a directory without .nvmrc
#
enter_directory() {
if [[ $PWD == $PREV_PWD ]]; then
return
fi
PREV_PWD=$PWD
@nivrith
nivrith / nvm-autouse.zsh
Created October 10, 2020 03:39
NVM Autouse Zsh
#
# Run 'nvm use' automatically every time there's
# a .nvmrc file in the directory. Also, revert to default
# version when entering a directory without .nvmrc
#
nvm_autouse() {
# if [[ $PWD == $PREV_PWD ]]; then
# return
# fi
@nivrith
nivrith / tsconfig.app.json
Last active October 13, 2020 07:44
Turn on strict mode in your editor's tsconfig.json file
{
"extends": "./tsconfig.build.json",
...
}
@nivrith
nivrith / concat-reducer-factories.ts
Last active October 20, 2020 07:05
Concatenate Reducer Factories
import { Action, ActionReducer } from '@ngrx/store';
export const concatReducers = <T, V extends Action = Action>(...reducers: Array<ActionReducer<T>>) => (
state: T | undefined,
action: Action,
): T => reducers.reduce((accumulatedState, reducer) => reducer(accumulatedState, action), state);
export const concatReducerFactories = <T, V extends Action = Action>(
...reducerFactories: Array<(state: T | undefined, action: Action) => T>
) => (state: T | undefined, action: Action): T =>
@nivrith
nivrith / concatenate-reducers-example.ts
Last active October 20, 2020 07:28
Concatenate Reducer Factories
export const MODULE_STATE_KEY = 'router';
export const initialState: RouterReducerState<RouterStoreState> = {
state: { url: '' },
navigationId: 0,
};
export const customRouterStoreReducer = createReducer(
initialState,
@nivrith
nivrith / prepare-commit-msg.sh
Last active October 11, 2024 18:49 — forked from johncmunson/prepare-commit-msg.sh
prepare-commit-message.sh
#!/bin/sh
#
# Inspects branch name and checks if it contains a Jira ticket number (i.e. ABC-123).
# If yes, commit message will be automatically prepended with [ABC-123].
#
# Useful for looking through git history and relating a commit or group of commits
# back to a user story.
#