Skip to content

Instantly share code, notes, and snippets.

View rhutchison's full-sized avatar

Ryan Hutchison rhutchison

View GitHub Profile
@rhutchison
rhutchison / products-search.store.ts
Last active April 13, 2024 18:24
ngxr signalStore
@Injectable()
export class ProductsSearchState extends searchStore<Product>() {
private readonly api = inject(ProductsService);
search(criteria: SearchCriteria) {
console.log(criteria);
// this.api.query(criteria);
}
}
@rhutchison
rhutchison / custom-repository.util.ts
Last active March 23, 2023 19:26
nestjs: TypeOrm 0.3.0
import { Provider, Type } from '@nestjs/common';
import { getDataSourceToken, getRepositoryToken } from '@nestjs/typeorm';
import { DataSource, DataSourceOptions, Repository } from 'typeorm';
export function provideCustomRepository<T>(
entity: Type<T>,
repository: Type<Repository<T>>,
dataSource?: DataSource | DataSourceOptions | string
): Provider {
return {
const standaloneMocks: Type<any>[] = [];
TestBed.overrideComponent(component, {
remove: { imports: standaloneMocks },
add: { imports: MockComponents(standaloneMocks) },
});
import {
Directive,
InjectFlags,
Input,
OnInit,
ɵɵdirectiveInject as inject,
} from '@angular/core';
import { ControlContainer } from '@angular/forms';
import { FormArray, FormBuilder, FormGroup } from '@ngneat/reactive-forms';
ng new gym.com --createApplication=false --routing=false --style=scss --directory=. --newProjectRoot=apps --skipInstall=true
ng g application gym --experimentalIvy=true --skipInstall=true --style=scss --prefix=gym
ng g application gymsearch --experimentalIvy=true --skipInstall=true --style=scss --prefix=gym
ng g application gymsolutions --experimentalIvy=true --skipInstall=true --style=scss --prefix=gym
@rhutchison
rhutchison / config.model.ts
Last active March 26, 2018 03:30
FuseConfig/Navigation bootstrap/refactoring
export type NavigationPositionType = 'right' | 'left' | 'top' | 'none';
export type NavigationOpenBehaviorType = 'push' | 'slide';
export type ToolbarPositionType = 'above' | 'below' | 'none';
export type FooterPositionType = 'above' | 'below' | 'none';
export type LayoutModeType = 'boxed' | 'fullwidth';
export type RouterAnimationType =
| 'fadeIn'
| 'slideUp'
| 'slideDown'
| 'slideRight'
(function () {
'use strict';
/**
* Edits by Ryan Hutchison
* Credit: https://github.com/paulyoder/angular-bootstrap-show-errors */
angular
.module('core')
.directive('showErrors', showErrors);
@rhutchison
rhutchison / pr.md
Last active September 5, 2015 20:36 — forked from piscisaureus/pr.md
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@rhutchison
rhutchison / .README.md
Last active September 5, 2015 20:36 — forked from gnarf/..git-pr.md
Global .gitconfig aliases for GitHub Pull Request Managment

Install

Either copy the aliases from the .gitconfig or run the commands in add-pr-alias.sh

Usage

Easily checkout local copies of pull requests from GitHub remotes:

  • git pr 4 - creates local branch pr/4 from the origin remote and checks it out
  • git pr 4 upstream - creates local branch pr/4 from upstream remote and checks it out
// Post repeat directive for logging the rendering time
angular.module('myApp').directive('postRepeatDirective',
['$timeout',
function($timeout) {
return function(scope, element, attrs) {
var timerName = attrs.postRepeatDirective || 'postRepeatDirective';
if (scope.$first) {
if (window.console && window.console.time) {
console.time(timerName);