Skip to content

Instantly share code, notes, and snippets.

View longfellowone's full-sized avatar

Matt Wright longfellowone

  • Vancouver, Canada
View GitHub Profile
@longfellowone
longfellowone / ObserverDesignPattern.go
Created December 21, 2018 00:36 — forked from sayden/ObserverDesignPattern.go
Observer Pattern in Golang
package main
import "fmt"
//Listener is a
type Listener struct {
ID int
}
//ListenerInterface is an
@longfellowone
longfellowone / 0_main.dart
Created April 24, 2019 17:16 — forked from boformer/0_main.dart
Flutter Service Architecture
import 'package:architecture_playground/home_page.dart';
import 'package:architecture_playground/services.dart';
import 'package:flutter/material.dart';
void main() async {
// perform long-running tasks before "runApp" to display the native splash screen
final services = await Services.initialize();
runApp(ServicesProvider(
services: services,
@longfellowone
longfellowone / group-objects-by-property.md
Created April 29, 2019 03:19 — forked from JamieMason/group-objects-by-property.md
Group Array of JavaScript Objects by Key or Property Value

Group Array of JavaScript Objects by Key or Property Value

Implementation

const groupBy = key => array =>
  array.reduce((objectsByKeyValue, obj) => {
    const value = obj[key];
    objectsByKeyValue[value] = (objectsByKeyValue[value] || []).concat(obj);
    return objectsByKeyValue;
import React from 'react';
import { Provider1, Provider2, Provider3 } from './';
function ProviderComposer({ contexts, children }) {
return contexts.reduceRight(
// kids = accumulator, parent = currentValue
(kids, parent) =>
React.cloneElement(parent, {
children: kids
}),
@longfellowone
longfellowone / Dockerfile
Created August 15, 2020 16:13 — forked from terry90/Dockerfile
Rust Dockerfile to build really small containers with postgres and SSL (~20Mo with rocket and diesel). Dependencies are cached for faster builds.
FROM clux/muslrust as build
WORKDIR /app/
# Deps caching begins
COPY Cargo.toml .
COPY Cargo.lock .
RUN mkdir src
RUN echo "fn main() {}" > src/main.rs
@longfellowone
longfellowone / rust-xp-03-redis.rs
Created October 11, 2021 18:04 — forked from jeremychone/rust-xp-03-redis.rs
Rust Redis with Async/Await (single threaded concurrency) | RustLang by example
#![allow(unused)] // silence unused warnings while exploring (to comment out)
use std::{error::Error, time::Duration};
use tokio::time::sleep;
use redis::{
from_redis_value,
streams::{StreamRangeReply, StreamReadOptions, StreamReadReply},
AsyncCommands, Client,
};