Skip to content

Instantly share code, notes, and snippets.

View hollygood's full-sized avatar

Kathy H. hollygood

View GitHub Profile
@hollygood
hollygood / github-to-bitbucket.md
Last active June 11, 2021 17:55 — forked from sangeeths/github-to-bitbucket
Forking a Github repo to Bitbucket
  • Go to Bitbucket and create a new repository (its better to have an empty repo)
git clone git@bitbucket.org:abc/myforkedrepo.git
cd myforkedrepo
  • Now add Github repo as a new remote in Bitbucket called "sync"
git remote add sync git@github.com:def/originalrepo.git
@hollygood
hollygood / react-best-practices.md
Last active May 17, 2021 01:45
Some React Best Practices

React Best Practices

Map Function for Dynamic Rendering of Arrays

render () {
  let cartoons = [ "Pika", "Squi", "Bulb", "Char" ];
  return (
  <ul>
    {cartoons.map(name => <li key={name}>{name}</li>)}
  </ul>
  );
@hollygood
hollygood / some-tricks.md
Last active May 17, 2021 01:54
JS Arrays || Objects Tricks

Some Common JS Tricks

Toggle Sorting function

// Normal way
if ( this.orderBy ) {
  results = this.order === 'asc' ? 
  results[0].sort( (a, b) => ( 
    a[ this.orderBy ] > b[ this.orderBy ] ) ? 1 : -1 ):
  results[0].sort( (a, b) => ( 
@hollygood
hollygood / angular-upgrade-notes.txt
Created July 31, 2020 15:02
Angular Upgrade Notes
1. Follow the instructions here: https://update.angular.io/
Select the current Angular version and expected verson to upgrade
2. Write Document
* Make suggestions from https://update.angular.io/ as a task list, mark complete when done
3. Dependencies Table
Make a table for each dependency from package.json, which includes package name, npm script (npm i -D xxx),
version changes, code affected, package changelog link, and progress. eg.
@hollygood
hollygood / kotlin-gradle-build.ts
Created October 4, 2019 15:06
Kotlin For Gradle Build
Define variable in root project and access it in subprojects by using extra
1) val foo: String by extra["hello"]
2) extra["foo"] = "hello"
3)
buildScript {
extra.apply {
set("foo", "hello")
}
}
@hollygood
hollygood / angular-parent-child-component.md
Created April 25, 2019 14:34
Creating a Reactive Form in Parent Component or Child Component

Example 1

// parent.component.ts
form: FormGroup;

ngOnInit() {
   this.form = new FormGroup({}); // create empty FormGroup in order to addControls in nested components
}

// parent.component.html
@hollygood
hollygood / change-library-style.md
Last active April 17, 2019 19:30
Angular 6 change library style in project

Change Style from Angular Library

If we create a library for reusable components with Angular 6, and you'll find that it's not possible to update the styles from the library. One way to do that is put ':host ::ng-deep':

// from library
.example-class {
   font-weight: bold;
}
@hollygood
hollygood / expressionChangedError.md
Last active April 17, 2019 19:34
ExpressionChangedAfterItHasBeenCheckedError

mat-form-field causes Error: ExpressionChangedAfterItHasBeenCheckedError

link: angular/components#12714

I also got the same error by using mat-form-field in ng-bootstrap modal:

"ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'mat-form-field-should-float: false'. Current value: 'mat-form-field-should-float: true'."

ChangeDetectionStrategy.OnPush doesn't work for me.

@hollygood
hollygood / ngrx-effects-multiple-requests-example.ts
Created February 15, 2019 16:36
A more complicated version of multiple http requests by using ngrx store
// Logic order: New User -> (A, B, C) -> D
// Each logic is a single API call to backend
// A, B, C, D services are all depends on the creation of the New User
// A, B, C can be called in any orders, and they don't depends on each other
// After A, B, C all completes, emit D. D shouldn't be called if either A, B or C is not complete
@Effect()
addUser$: Observable<Action> = this.actions$.pipe(
ofType<AddUserAction>(UsersActionType.ADD_USER),
map((action: AddUserAction) => action.payload),
@hollygood
hollygood / more-about-higher-order-mapping.ts
Created February 14, 2019 14:42
More about higher order mapping
// Higher order mapping: instead of mapping a plain value like 1 to another value like 10,
// we are going to map a value into an Observable. It's just an Observable like any other,
// but its values are themselves Observables as well, that we can subscribe to separately
// Why Higher-Order Observables?
// Avoiding nested subscriptions
/**
* Observable Concatenation: implement sequential requests
* In order to ensure sequentiality, we need to concatenate the multiple httpPost$ Observables together