Skip to content

Instantly share code, notes, and snippets.

View automaticalldramatic's full-sized avatar
🦊
this is a useless feature

riz automaticalldramatic

🦊
this is a useless feature
View GitHub Profile
@automaticalldramatic
automaticalldramatic / server.go
Created December 30, 2022 14:34 — forked from josue/server.go
Simple Golang HTTP server with signal capturing (ie: SIGINT/SIGTERM) & pprof debugger
/*
go build for linux:
env GOOS=linux go build -o /tmp/server server.go
run with docker:
docker run -it --rm --name test -v /tmp/server:/server -p 3000:80 -p 3001:6060 alpine /server
run pprof debugger:
go get github.com/google/pprof
pprof --seconds 30 -http=:4444 /tmp/server http://localhost:3001/debug/pprof/profile

Keybase proof

I hereby claim:

  • I am automaticalldramatic on github.
  • I am reeseone (https://keybase.io/reeseone) on keybase.
  • I have a public key ASDcrqAF-d20V6sFhvrFoQqWZH8QdE7o_lDOm2EDLFt7awo

To claim this, I am signing this object:

export interface ObservablePaginatedResult {
cards: Observable<Array<SomeCards>>;
stop: () => void;
}
// returns an observable to subscribe to for changes and a method to stop listening to the snapshot
public SyncCards(pageSize: number = this.DefaultPageSize): <ObservablePaginatedResult> {
// an internal subject to handle streaming until the connection is closed. The buffer size of 1 fits my scenario and is up to the readers discretion
const cards$: ReplaySubject<Array<SomeCards>> = new ReplaySubject<SomeCards[]>(1);
// this method accepts the property to order by. In our example, this would be priority
// sortByDesc('priority')
sortByDesc(prop: string) {
return this.returnedCardsArr.sort((a, b) => a[prop] < b[prop] ? 1 : a[prop] === b[prop] ? 0 : -1);
}
// also a slightly verbose way of keeping only unique IDs replacing the ones received from the new call - cause the data also might have changed.
for (const card of c) {
if (!this.uniqueMap.has(card.id)) {
this.uniqueMap.set(card.id, true);
private snapshotWatchers: Array<() => void> = [];
private syncRequest: Partial<ObservablePaginatedQuery>;
private syncCards() {
// assume some code here to initialise variables, create a service instance et al
// syncRequest is a class variable
this.syncRequest = WatchPaginatedCards();
this.syncRequest.cards.pipe().subscribe(
// I updated the interface
export interface ObservablePaginatedResult {
cards: Observable<Array<SomeCards>>;
nextPage: IterableIterator<() => void>; // the method returned by iterator should be called to stop listening for changes on this page
}
public WatchPaginatedCards(pageSize: number = this.DefaultPageSize): <ObservablePaginatedQuery> {
const cards$: ReplaySubject<Array<SomeCards>> = new ReplaySubject<SomeCards[]>(1);

Keybase proof

I hereby claim:

  • I am automaticalldramatic on github.
  • I am rizwaniqbal (https://keybase.io/rizwaniqbal) on keybase.
  • I have a public key ASBIwoVK08YsA2ZKfvShz-SYOLALs9SwVTOdzEDXrSgbtAo

To claim this, I am signing this object:

@automaticalldramatic
automaticalldramatic / postgres-brew.md
Created November 11, 2019 22:38 — forked from ibraheem4/postgres-brew.md
Installing Postgres via Brew (OSX)

Installing Postgres via Brew

Pre-Reqs

Brew Package Manager

In your command-line run the following commands:

  1. brew doctor
  2. brew update
@automaticalldramatic
automaticalldramatic / app.yaml
Last active September 6, 2019 12:32
A cloudbuild that works for me with private packages
env: flex
runtime: go1.12
main: cmd/some-service-name/main.go