Skip to content

Instantly share code, notes, and snippets.

View adamgen's full-sized avatar
🚀
Developing software, and software developers 🤖

Adam adamgen

🚀
Developing software, and software developers 🤖
View GitHub Profile
@adamgen
adamgen / bash completeion
Last active August 29, 2019 07:09
initial bash profile scripts that run on startup
# install: brew install bash-completion
# then in .bash_profile
if [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Node: Nodemon",
"processId": "${command:PickProcess}",
"restart": true,
"protocol": "inspector",
@adamgen
adamgen / bad.component.ts
Created May 6, 2020 16:32
NGRX | Use effects and router-store to isolate route related side 🧙🏼‍♂️ effects
@Component({
export class MyComponent {
id: string;
id$ = this.activatedRoute.params.pipe(
map(params => params.id),
tap(id => this.id = id),
);
constructor(
private activatedRoute: ActivatedRoute,
) {}
@adamgen
adamgen / good.component.ts
Created May 6, 2020 16:37
NGRX | Use effects and router-store to isolate route related side 🧙🏼‍♂️ effects - good component
import { Store, select } from ‘@ngrx/store’;
import { Component } from ‘@angular/core’;
@Component({
selector: ‘app-root’,
template: `{{selectedId$ | async | json}}`,
})
export class HomeComponent {
selectedId$ = this.store.pipe(select((state: any) => state.featureName.selectedId));
constructor(
private store: Store,
@adamgen
adamgen / effects.ts
Created May 6, 2020 16:37
NGRX | Use effects and router-store to isolate route related side 🧙🏼‍♂️ effects - effects injectable
setCurrentCourse$ = createEffect(() => this.actions$.pipe(
ofType(ROUTER_NAVIGATED), // get router navigated ngrx actions
mergeMap(() => this.store.pipe(
select(selectRouteParam(‘id’))) // get the id from the router store
),
map((id: string) => setIds({ id })), // dispatch a new action to set the selected id
));
@adamgen
adamgen / cloned-wp-update.sh
Created February 23, 2021 19:35
Setting up a freshly cloned WP instance with CLI commands
wp search-replace http://origin.com http://destination.com --all-tables
wp option update home http://destination.com
wp option update siteurl http://destination.com
# Make sure that you have write permissions first
wp rewrite flush