This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\documentclass[11pt]{article} | |
\usepackage[margin=0.5in]{geometry} | |
\usepackage{amsmath} | |
\usepackage{amssymb} | |
\usepackage{setspace} | |
\usepackage{listings} | |
\usepackage{alltt} | |
\makeatletter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, Inject, OnInit, PLATFORM_ID } from '@angular/core'; | |
import { Router, Event, Scroll } from '@angular/router'; | |
import { isPlatformBrowser } from '@angular/common'; | |
// https://gomakethings.com/how-to-test-if-an-element-is-in-the-viewport-with-vanilla-javascript/ | |
const isInViewport = (elem) => { | |
const bounding = elem.getBoundingClientRect(); | |
return ( | |
bounding.top >= 0 && | |
bounding.left >= 0 && |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"configurations": { | |
"production": { | |
// ... | |
"fileReplacements": [ | |
{ | |
"replace": "src/environments/environment.ts", | |
"with": "src/environments/environment.prod.ts" | |
} | |
] | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"configurations": { | |
"production": { | |
"fileReplacements": [ | |
{ | |
"replace": "src/environments/environment.ts", | |
"with": "src/environments/environment.prod.ts" | |
} | |
] | |
}, | |
"development": { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** A configuration object with environment-specific properties. */ | |
export interface AppEnvironment { | |
/** True if the @angular/core enableProdMode should be called. */ | |
production: boolean; | |
/** The api server address. */ | |
apiAddress: string; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { environment } from "../../environments/environment"; | |
@Injectable({ providedIn: "root" }) | |
export class MyApiService { | |
constructor(private http: HttpClient) {} | |
getFoo(): Observable<any> { | |
return this.http.get(`${environment.apiAddress}/foo`); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { NgModule } from '@angular/core'; | |
import { BrowserModule } from '@angular/platform-browser'; | |
import { AppComponent } from './app.component'; | |
import { MY_API_BASE } from './my-api.service'; | |
import { environment } from '../environments/environment'; | |
@NgModule({ | |
declarations: [ AppComponent ], | |
imports: [ BrowserModule ], | |
providers: [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
buffered_iterator - Decorates an iterator with "has_next" by buffering values. | |
Example use case for this is if you have a base interface/ABC that has methods | |
`has_next` and `get_next`, and several classes realizing this interface already | |
would have iterators internally, you wouldn't want them to each have to | |
implement the logic for `has_next` - so it would be better to decorate an | |
iterator with some sort of `has_next`. | |
Inspiration from |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@dataclasses.dataclass | |
class MyConfig: | |
x: str | |
y: str | |
def read_from_file() -> MyConfig: | |
with open("my-config.json", "r") as f: | |
d = json.load(f) | |
return MyConfig(d["x"], d["y"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def read_from_file(src_path="my-config.json") -> MyConfig: | |
with open(src_path, "r") as f: | |
d = json.load(f) | |
return MyConfig(d["x"], d["y"]) | |
def write_to_file(c: MyConfig, dest_path="my-config.json") -> None: | |
with open(dest_path, "w") as f: | |
f.write({"x": c.x, "y": c.y}) |
OlderNewer