Skip to content

Instantly share code, notes, and snippets.

View RayLuxembourg's full-sized avatar

Ray Luxembourg RayLuxembourg

View GitHub Profile
@RayLuxembourg
RayLuxembourg / forms.ts
Created October 20, 2016 09:42
angular 2 form skeleton
import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms';
export class NewDriverComponent implements OnInit {
driver: FormGroup;
constructor(private fb: FormBuilder) {
}
createForm(): void {
this.driver = this.fb.group({
firstName: ['', [Validators.required]],
lastName: ['', [Validators.required]],
@RayLuxembourg
RayLuxembourg / redux.crud.action.js
Last active January 8, 2017 09:58
React.js Modular Crud with Redux
// Actions
import axios from 'axios';
import * as types from '../constants/actionTypes';
import { browserHistory } from 'react-router';
import setAuth from '../radiomize/auth/setAuth';
import jwt from 'jsonwebtoken';
const AUTH_URL = 'http://dev.admin.api.radiomize.com/v1/login';
const BASE_URL = 'http://dev.admin.api.radiomize.com/v1/';
// TYPES OF ACTIONS
@RayLuxembourg
RayLuxembourg / Api.js
Created January 8, 2017 10:17 — forked from bermanboris/Api.js
Api Static Class
export default class Api {
static headers() {
return {
'Accept': 'application/json',
'Content-Type': 'application/json',
'dataType': 'json',
}
}
static get(route) {
@RayLuxembourg
RayLuxembourg / Const.js
Created January 19, 2017 11:39
CRUD CONST CREATOR
const Actions = (type) => ({
FETCH: {
IN_PROGRESS: `FETCH_${type}_IN_PROGRESS`,
SUCCESS: `FETCH_${type}_SUCCESS`,
ERROR: `FETCH_${type}_ERROR`
},
POST: {
IN_PROGRESS: `POST${type}_IN_PROGRESS`,
SUCCESS: `POST${type}_SUCCESS`,
ERROR: `POST${type}_ERROR`
@RayLuxembourg
RayLuxembourg / golden.js
Created June 1, 2017 12:34
golden ratio
const spacingFactor = 8;
export const spacing = {
space0: `${computeGoldenRatio(spacingFactor, 0)}px`, // 8
space1: `${computeGoldenRatio(spacingFactor, 1)}px`, // 13
space2: `${computeGoldenRatio(spacingFactor, 2)}px`, // 21
space3: `${computeGoldenRatio(spacingFactor, 3)}px`, // 34
space4: `${computeGoldenRatio(spacingFactor, 4)}px`, // 55
space5: `${computeGoldenRatio(spacingFactor, 5)}px`, // 89
};
package fitnesse.html;
import fitnesse.responders.run.SuiteResponder;
import fitnesse.wiki.*;
public class SetupTeardownIncluder {
private PageData pageData;
private boolean isSuite;
private WikiPage testPage;
private StringBuffer newPageContent;
private PageCrawler pageCrawler;
//src/common/services/interceptor.service.ts
import { environment } from '../../../environments/environment';
import { Injectable } from '@angular/core';
import { HttpRequest, HttpHandler, HttpEvent, HttpInterceptor, HTTP_INTERCEPTORS } from '@angular/common/http';
import { Observable } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class Interceptor implements HttpInterceptor {
@RayLuxembourg
RayLuxembourg / api.service.ts
Last active August 19, 2018 14:46
Api Service
//src/common/services/api.service.ts
@Injectable({ providedIn: 'root' })
export class ApiService {
monitor = "/monitor";
analytics = "/analytics";
api = "/api"
constructor(private httpClient: HttpClient) { }
@RayLuxembourg
RayLuxembourg / product.component.ts
Created August 19, 2018 14:47
product component
export class ProductComponent implements OnInit {
product$: Observable<Product>;
constructor(private api: ApiService,private route:ActivatedRoute) {}
ngOnInit() {
const id = this.route.snapshop.params['id'];
this.product$ = this.api.product(id);
// ...
}
@RayLuxembourg
RayLuxembourg / ProductResolver.guard.ts
Last active August 19, 2018 14:49
ProductResolver
@Injectable()
export class ProductResolver implements Resolve<Product> {
constructor(private api: ApiService) {}
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Product> {
return this.api.product(route.params['id']);
}
}