Skip to content

Instantly share code, notes, and snippets.

View kooba's full-sized avatar
👍
shipping

Jakub Borys kooba

👍
shipping
View GitHub Profile
@kooba
kooba / resizeImage.ts
Last active November 17, 2023 10:17
Resize image after upload to Firebase Storage bucket. Maintain access token of original image.
import * as admin from "firebase-admin";
import * as functions from "firebase-functions";
import * as fs from "fs";
import sharp from "sharp";
export const resizeImage = functions.storage
.object()
.onFinalize(async (object) => {
const bucket = admin.storage().bucket(object.bucket);
const filePath = object.name;
import json
from nameko.web.handlers import http
from nameko_grpc.dependency_provider import GrpcProxy
from products.products_pb2 import GetProduct
from products.products_pb2_grpc import productsStub
class ClientService:
@kooba
kooba / nameko-grpc-examples-2.proto
Created February 28, 2019 09:22
Protobuf Service Definition
syntax = "proto3";
package products;
service products {
rpc get_product(GetProduct) returns (Product);
}
message Product {
int32 id = 1;
@kooba
kooba / nameko-grpc-examples-1.py
Last active February 28, 2019 09:49
nameko-grpc-examples-1
from nameko_grpc.entrypoint import Grpc
from products import dependencies
from products.products_pb2 import Product
from products.products_pb2_grpc import productsStub
grpc = Grpc.implementing(productsStub)
@kooba
kooba / brigade-5.js
Created February 1, 2019 16:37
Development in the Cloud
const { events, Job } = require('brigadier');
const kubernetes = require('@kubernetes/client-node');
const process = require('process');
const yaml = require('js-yaml');
const fetch = require('node-fetch');
const k8sClient = kubernetes.Config.defaultClient();
const BRIGADE_NAMESPACE = 'brigade';
const PROJECT_NAME = 'products';
const kubernetes = require('@kubernetes/client-node');
const yaml = require('js-yaml');
const ulid = require('ulid');
const crypto = require('crypto');
const k8sClient = kubernetes.Config.defaultClient();
const BRIGADE_NAMESPACE = 'brigade';
const GITHUB_API_URL = 'https://api.github.com/repos';
const deployProjects = async (environmentName) => {
@kooba
kooba / brigade-3.js
Created February 1, 2019 12:13
Development in the Cloud
const { Job, Group } = require('brigadier');
const deployDependencies = async (namespace) => {
const postgresql = new Job('postgresql', 'jakubborys/ditc-brigade-worker:latest');
postgresql.storage.enabled = false;
postgresql.imageForcePull = true;
postgresql.tasks = [
'cd /src',
`helm upgrade ${namespace}-postgresql charts/postgresql \
--install --namespace=${namespace} \
@kooba
kooba / brigade-2.js
Created February 1, 2019 12:09
Development in the Cloud
const kubernetes = require('@kubernetes/client-node');
const yaml = require('js-yaml');
const k8sClient = kubernetes.Config.defaultClient();
const BRIGADE_NAMESPACE = 'brigade';
const createEnvironmentConfigMap = async (name, projects) => {
const configMap = new kubernetes.V1ConfigMap();
const metadata = new kubernetes.V1ObjectMeta();
metadata.name = `environment-config-${name}`;
@kooba
kooba / brigade-1.js
Last active February 1, 2019 12:08
Development in the Cloud
const kubernetes = require('@kubernetes/client-node');
const k8sClient = kubernetes.Config.defaultClient();
const createNamespace = async (namespaceName) => {
const existingNamespace = await k8sClient.listNamespace(
true, '', `metadata.name=${namespaceName}`,
);
if (existingNamespace.body.items.length) {
console.log(`Namespace "${namespaceName}" already exists`);
return;
@kooba
kooba / Makefile
Last active August 26, 2020 09:11
Nameko HTTP file upload
install:
pip install -r requirements.txt
run_client:
nameko run services:ClientService --config config_client.yaml
run_server:
nameko run services:ServerService --config config_server.yaml
run: