Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@bamnet
bamnet / contents_1.json
Created February 24, 2021 00:24
Concerto 2 Frontend Spec
[{"id":1,"name":"Twitch 1","duration":8,"type":"Graphic","render_details":{"path":"/frontend/1/fields/1/contents/1"}},{"id":3,"name":"Standard Embed Final Proof 1","duration":31,"type":"RemoteVideo","render_details":{"path":"https://fast.wistia.net/embed/iframe/j38ihh83m5?autoPlay=true\u0026chromeless=true\u0026playerColor=black\u0026html5=1"}}]
export class DistanceMatrixService extends google.maps.DistanceMatrixService {
rateLimiter = new RateLimiter(2, 'second');
static readonly maxElements = 100;
async getDistanceMatrixAsync(req: google.maps.DistanceMatrixRequest) {
// If the matrix is too big, we have to split up the requests into smaller chunks.
if (req.origins!.length * req.destinations!.length > DistanceMatrixService.maxElements) {
return this.shardedMatrix(req);
}
async function routeBetween(
directionSvc: import("./modern_services").DirectionService,
parks: Park[]
) {
const waypoints: google.maps.DirectionsWaypoint[] = parks.map((p) => ({ location: p.place }));
const req: google.maps.DirectionsRequest = {
origin: 'New York Penn Station',
destination: 'New York Penn Station',
optimizeWaypoints: true,
export async function filterParks(placesSvc: import("./places").PlacesService): Promise<Park[]> {
return Promise.all(ListParks().map((park) => park.findPlace(placesSvc))).then((parks) => {
return parks.filter((park) => park.placeResult!.formatted_address!.includes("New York, NY"));
});
}
export class Park {
// Name of the park.
name: string;
let placesSvc: import("./places").PlacesService;
async function initMap() {
const services = await import('./places');
placesSvc = new services.PlacesService(<HTMLDivElement>document.getElementById('attr'));
}
import { RateLimiter } from 'limiter';
export class PlacesService extends google.maps.places.PlacesService {
rateLimiter = new RateLimiter(2, 'second');
async findPlaceFromQueryAsync(req: google.maps.places.FindPlaceFromQueryRequest) {
await this.waitForToken();
return new Promise(
(
resolve: (result: google.maps.places.PlaceResult[]) => void,
@bamnet
bamnet / Dockerfile
Created January 7, 2019 06:02
Multiarch Go Builds + Google Cloud Build
FROM golang:alpine as builder
RUN apk update && apk add git && apk add tzdata
COPY . $GOPATH/src/github.com/bamnet/village
WORKDIR $GOPATH/src/github.com/bamnet/village
ARG CGO_ENABLED=0
ARG GOARCH=amd64
ARG GOARM=6
@bamnet
bamnet / .gitlab-ci.yml
Last active January 11, 2023 06:16
Multiarch Go Builds
image: docker:latest
services:
- docker:dind
stages:
- build
variables:
IMAGE: registry.gitlab.com/bamnet/njtdata
DOCKER_CLI_EXPERIMENTAL: enabled
@bamnet
bamnet / README.md
Last active October 20, 2018 04:52
Helper functions for use with the Google Maps JavaScript API to find points along a polyline.

Point Along Polyline

The percentAlongPath and distanceAlongPath functions below use the Geometry library of the Google Maps API to interpolate points a percentage or distance along a polyline. This can be useful to plot points along a polyline at regular intervals.

Note: The Geometry library must be loaded by appending &libraries=geometry to the <script> tag used to load the Google Maps API. For more information, check out the Library documentation.

analytics

<style id="jsbin-css">
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
height: 100%;
}
/* Optional: Makes the sample page fill the window. */
html, body {
height: 100%;
margin: 0;