Skip to content

Instantly share code, notes, and snippets.

View mrmeku's full-sized avatar
💭
Chillin like a villain

mrmeku

💭
Chillin like a villain
View GitHub Profile
@mrmeku
mrmeku / tasks.json
Last active October 30, 2019 17:07
Super Narwhal Team's tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "super-narwhal-devserver",
"type": "ng",
"command": "serve",
"project": "super-awesome-app",
"flags": ["--aot=false"],
"dependsOn": ["my-npm-task-that-runs-first"]
import { BehaviorSubject, Subject } from 'rxjs';
export interface Breadcrumb {
title: string;
}
export interface MenuOption {
name: string;
image: string;
invoke: () => void;
}
export interface NonContextualAction {
<html>
<style>
html,
body {
height: 100vh;
overflow: hidden;
}
body {
align-items: center;
@mrmeku
mrmeku / match-height.directive.ts
Created December 14, 2018 20:35
Match Height Directive
import { AfterViewInit, Directive, ElementRef, Input, NgZone, OnDestroy } from '@angular/core';
import ResizeObserver from 'resize-observer-polyfill';
const HEIGHT_MATCHER_MAP: Map<string, HeightMatcher> = new Map();
class HeightMatcher {
private readonly targets = new Set<HTMLElement>();
private readonly resizeObserver = new ResizeObserver(() => {
this.matchHeightOfTargets();

Coding guidelines

This document is split into two sections

  1. On General Code Health. This section contains guidelines intended encourage patterns which produce more maintainable, less bug prone, code.
  2. On Angular Performance. This section contains guidelines intended to make an Angular app trigger change detection less often and on less entities.

General Code Health

Copy only once, extract otherwise

case MAZDA:
done.run(GetCarsResponse.newBuilder()
.addCars(newCar("Miata", MAZDA))
.addCars(newCar("Mazda3", MAZDA))
.build());
@mrmeku
mrmeku / STDERR.txt
Created May 29, 2018 20:25
All references to TOYOTA within CarService.java
backend/src/CarService.java:3: error: cannot find symbol
import static schema.Manufacturer.TOYOTA;
^
symbol: static TOYOTA
location: class
backend/src/CarService.java:22: error: an enum switch case label must be the unqualified name of an enumeration constant
case TOYOTA:
^
backend/src/CarService.java:24: error: cannot find symbol
.addCars(newCar("Corolla", TOYOTA))
@mrmeku
mrmeku / car.proto
Last active May 31, 2018 00:02
Example Protocol Buffer schema definition
syntax = "proto3";
option java_multiple_files = true;
option java_package = "schema";
option java_generic_services = true;
// An RPC service which has a method to request a list of cars.
service CarService {
rpc GetCars(GetCarsRequest) returns (GetCarsResponse);
}
@mrmeku
mrmeku / BUILD.bazel
Created May 28, 2018 20:14
Example of how to consume the same proto_library within TypeScript and Java
package(default_visibility = ["//visibility:public"])
load("@build_bazel_rules_typescript//:defs.bzl", "ts_proto_library")
proto_library(
name = "car_proto",
srcs = ["car.proto"],
)
ts_proto_library(
@mrmeku
mrmeku / CarService.java
Last active May 31, 2018 00:12
Example of how to extend the abstract class output of java_proto_library
package backend;
import static schema.Manufacturer.TOYOTA;
import static schema.Manufacturer.HONDA;
import com.google.protobuf.RpcController;
import com.google.protobuf.RpcCallback;
import schema.Car;
import schema.GetCarsRequest;