Skip to content

Instantly share code, notes, and snippets.

@everpeace
everpeace / docker-compose.yml
Last active April 7, 2024 10:00
kafka cluster in docker-compose.
# WARNING: This docker-compose.yml is only for testing purpose.
# Parameters:
# - name: CONFLUENT_PLATFORM_VERSION
# default: 3.0.0
# reference: https://hub.docker.com/u/confluentinc/
# Ports:
# - description: Major ports are exposed to host computer
# - zookeeper: 2181
# kafka1: 9091
# kafka2: 9092
@jesselucas
jesselucas / protogen.md
Last active January 29, 2019 01:23
Tips for generating gRPC protocol buffers

Tips for generating gRPC protocol buffers

You can use the flag -I or -proto_path to specify the path to your protobuffer. The next flag specifies the language to compile to. The Go command is fairly well documented but the Node.js documents seem to only show how to dynamically load a proto file. This is how you generate a compiled file for use in your Node.js project.

GO

protoc --proto_path=$SRC_PATH --go_out=plugins=grpc:$DEST_PATH $SRC_PATH/service.proto

Node.js

protoc --proto_path=$SRC_PATH --js_out=import_style=commonjs,binary:$DEST_PATH --grpc_out=./ --plugin=protoc-gen-grpc=node_modules/grpc-tools/bin/grpc_node_plugin $SRC_PATH/service.proto

@mgoodness
mgoodness / helm-rbac.md
Last active October 30, 2021 17:04
Helm RBAC setup for K8s v1.6+ (tested on minikube)
kubectl -n kube-system create sa tiller
kubectl create clusterrolebinding tiller --clusterrole cluster-admin --serviceaccount=kube-system:tiller
helm init --service-account tiller
@swftvsn
swftvsn / FirebasePushIdGenerator.java
Created March 15, 2017 10:36
Firebase Java Push Id Generator
package firebase;
public class FirebasePushIdGenerator {
// Modeled after base64 web-safe chars, but ordered by ASCII.
private final static String PUSH_CHARS = "-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz";
// Timestamp of last push, used to prevent local collisions if you push twice in one ms.
private static long LAST_PUSH_TIME = 0L;
@onecrayon
onecrayon / example_models.py
Created December 13, 2016 20:05
Custom MappedCollection example for SQLAlchemy returning a dict of lists
from sqlalchemy import Model, Column, Integer, ForeignKey, String, Text
from orm_helpers import KeyedListCollection
class ItemAttribute(Model):
__tablename__ = 'item_attributes'
id = Column(Integer, primary_key=True, autoincrement=True)
item_id = Column(Integer, ForeignKey('items.id'))
attribute = Column(String(255))
value = Column(Text)
@pgchamberlin
pgchamberlin / keycloak_aws_deployment.md
Last active May 19, 2022 12:17
Deploying Keycloak to AWS using a Ubuntu AMI

Deploying Keycloak to AWS

The objective of this guide is to deploy Keycloak to AWS in a minimally complex way for testing and discovery purposes. This means using the standalone build of Keycloak backed with Hibernate H2. The result is not a production ready system. It won't scale, it won't survive significant load, it can't be clustered.

Mostly this Gist is a distillation of the Keycloak Server Installation guide for a specific use case: to spin up a quick and dirty Keycloak instance for testing and experimenting.

Steps

  • Spin up and configure a Ubuntu AMI
  • Install and configure Keycloak with an SSL cert
@kevin-smets
kevin-smets / 1_kubernetes_on_macOS.md
Last active May 5, 2024 10:12
Local Kubernetes setup on macOS with minikube on VirtualBox and local Docker registry

Requirements

Minikube requires that VT-x/AMD-v virtualization is enabled in BIOS. To check that this is enabled on OSX / macOS run:

sysctl -a | grep machdep.cpu.features | grep VMX

If there's output, you're good!

Prerequisites

@jamesmacwhite
jamesmacwhite / ffmpeg_mkv_mp4_conversion.md
Last active May 13, 2024 10:18
Easy way to convert MKV to MP4 with ffmpeg

Converting mkv to mp4 with ffmpeg

Essentially just copy the existing video and audio stream as is into a new container, no funny business!

The easiest way to "convert" MKV to MP4, is to copy the existing video and audio streams and place them into a new container. This avoids any encoding task and hence no quality will be lost, it is also a fairly quick process and requires very little CPU power. The main factor is disk read/write speed.

With ffmpeg this can be achieved with -c copy. Older examples may use -vcodec copy -acodec copy which does the same thing.

These examples assume ffmpeg is in your PATH. If not just substitute with the full path to your ffmpeg binary.

Single file conversion example

@andymatuschak
andymatuschak / States-v3.md
Last active May 1, 2024 12:32
A composable pattern for pure state machines with effects (draft v3)

A composable pattern for pure state machines with effects

State machines are everywhere in interactive systems, but they're rarely defined clearly and explicitly. Given some big blob of code including implicit state machines, which transitions are possible and under what conditions? What effects take place on what transitions?

There are existing design patterns for state machines, but all the patterns I've seen complect side effects with the structure of the state machine itself. Instances of these patterns are difficult to test without mocking, and they end up with more dependencies. Worse, the classic patterns compose poorly: hierarchical state machines are typically not straightforward extensions. The functional programming world has solutions, but they don't transpose neatly enough to be broadly usable in mainstream languages.

Here I present a composable pattern for pure state machiness with effects,

Real-time Grid Component with Laravel, Vue.js, Vuex & Socket.io (Google Docs-like Functionality)

Motivation

The exercise of writing this tutorial -- as well as recording it as a screencast -- has helped me better understand the concepts behind a couple of my favorite open source tools. Both the tutorial and screencast will be of personal use in the future as references. If they are of help to others, that will be great too.

I love Google Docs' real-time, multi-user interactive capability, and I've have always been a fan of spreadsheets. I wanted to see if I could replicate that type of functionality. What I've done is taken the basic Vue.js Grid Component example and altered it a bit so that when a user clicks on a cell, that cell becomes highlighted or "active", not just in the user's browser but in any browser instance cur