Skip to content

Instantly share code, notes, and snippets.

@timjonesdev
timjonesdev / Dockerfile
Created February 18, 2019 23:49
A Composite Dockerfile
# -------------------------------------------------------
# Build the go source
# -------------------------------------------------------
FROM docker.io/golang:1.11 as go-builder
# copy simple go application into the container
COPY app/api/main.go $GOPATH/src/app/main.go
# change the working directory, for convenience
WORKDIR $GOPATH/src/app
# build the Go binary and create some directories to copy in later stages
@timjonesdev
timjonesdev / Dockerfile
Last active February 18, 2019 23:50
Scratch and Sniff
# -------------------------------------------------------
# Build the go source
# -------------------------------------------------------
FROM docker.io/golang:1.11 as go-builder
# copy simple go application into the container
COPY sniff.go $GOPATH/src/app/sniff.go
# change the working directory, for convenience
WORKDIR $GOPATH/src/app
# build the Go binary and create some directories to copy in later stages
apiVersion: v1
kind: Pod
metadata:
labels:
test: liveness
name: liveness-exec
spec:
containers:
- name: liveness
image: k8s.gcr.io/busybox
apiVersion: v1
kind: Pod
metadata:
labels:
test: liveness
name: liveness-exec
spec:
containers:
- name: liveness
image: k8s.gcr.io/busybox

Calculation of Projected Order Expiration

Sorting based on relative expiration time.

Algebra for calculating when value will equal zero: We project when value will equal zero, and compare number of seconds

v = (s - x) - (d * x)

Solve for the slope-intercept form:

v = -dx - x + s

v = -(d + 1)x + s

module github.com/samplerepo/sampleproject
go 1.12
require (
github.com/pkg/errors v0.8.0
github.com/spf13/cobra v0.0.4
github.com/spf13/viper v1.3.2
)
@timjonesdev
timjonesdev / ChangeStream.java
Created May 21, 2019 20:28
An example of how to configure a reactive changestream watcher with Spring Boot 2 and Reactive MongoDB
// uses Spring Boot 2, Spring Webflux, Reactive Mongo Repository
public class ChangeStream {
@Autowired
private ReactiveMongoTemplate reactiveMongoTemplate;
public Flux<SampleDao> watchChanges() {
// set changestream options to watch for any changes to the sample collection
ChangeStreamOptions options = ChangeStreamOptions.builder()
.filter(Aggregation.newAggregation(SampleDao.class,
@timjonesdev
timjonesdev / teams_initial.bson
Last active May 28, 2019 23:32
Some initial sample data for the reactive mongo streams example.
[
{
"_id": ObjectId("5cb96b9132ac9751f3ff1912"),
"nickname": "HingleMcCringleberry",
"owner": "John S."
},
{
"_id": ObjectId("5cb96b9132ac9751f3ff1892"),
"name": "Johnny Utah",
"owner": "Paul M."
Date: 2019-06-26T17:07:41.247Z
Hash: c58e049a483cf92093f5
Time: 18085ms
chunk {0} runtime-es5.741402d1d47331ce975c.js (runtime) 1.41 kB [entry] [rendered]
chunk {1} main-es5.4af9b61479361f268d39.js (main) 128 bytes [initial] [rendered]
chunk {2} polyfills-es5.0abd2975e5ae858be8b6.js (polyfills) 68.1 kB [initial] [rendered]
chunk {3} styles.ff23229eb61c8a3d0e74.css (styles) 62.4 kB [initial] [rendered]
ERROR in : Unexpected value 'undefined' imported by the module 'MyModule in /build/src/node_modules/my-lib/my-lib.d.ts'
@timjonesdev
timjonesdev / my-lib-good.module.ts
Last active June 27, 2019 20:24
The correct way to import modules in an Angular library
import {NgModule} from '@angular/core';
import {MyLibComponent} from './my-lib.component';
import {NavigationModule} from "./navigation/navigation.module"; // <-- lengthened
import {FormModule} from "./form/form.module"; // <-- lengthened
@NgModule({
declarations: [MyLibComponent],
imports: [NavigationModule, FormModule],
exports: [NavigationModule, FormModule]
})