Skip to content

Instantly share code, notes, and snippets.

View ecyshor's full-sized avatar

Nicu Reut ecyshor

View GitHub Profile
@ecyshor
ecyshor / proxy.ts
Last active March 8, 2023 04:36
nodejs reverse proxy google cloud function
import * as functions from 'firebase-functions';
import * as http from 'http';
const BUCKET_NAME = "target-bucket"
// check original code idea https://stackoverflow.com/a/10435819
exports.rewriteGCSRequest = functions.https.onRequest((oreq: any, ores: any) => {
const redirectPath = oreq.originalUrl === '/' ? '/index.html' : oreq.originalUrl
const options = {
// host to forward to
@ecyshor
ecyshor / temperature.json
Created December 5, 2020 21:10
Grafana dashboard for home temperature
{
"__inputs": [
{
"name": "DS_PROMETHEUS",
"label": "Prometheus",
"description": "",
"type": "datasource",
"pluginId": "prometheus",
"pluginName": "Prometheus"
}
@ecyshor
ecyshor / RestartFlowPlayground.scala
Last active July 30, 2020 15:09
akka streams RestartFlow playground
import akka.actor.ActorSystem
import akka.stream.ActorAttributes
import akka.stream.Supervision.Stop
import akka.stream.scaladsl.{ Flow, RestartFlow, Sink, Source }
import scala.concurrent.Await
import scala.concurrent.duration._
import scala.util.control.NonFatal
import scala.concurrent.Future
@ecyshor
ecyshor / setup-grpc-web.md
Last active November 9, 2020 11:46
Use local build of grpc-web

Using a custom build of grpc-web in your project

Clone the repo

git clone git@github.com:grpc/grpc-web.git

Install the web plugin to generate the code

you might need sudo apt-get install libprotoc-dev

sudo make install-plugin - (this installs the protoc-gen-grpc-web)

@ecyshor
ecyshor / streams.scala
Created May 1, 2020 20:33
Akka streams either partition
implicit class EitherSourceExtension[L, R, Mat](source: Source[Either[L, R], Mat]) {
def partition[LMat, RMat, NewMat](left: Sink[L, LMat], right: Sink[R, RMat])(
combineMat: (Mat, LMat, RMat) => NewMat
): Graph[ClosedShape.type, NewMat] = {
GraphDSL.create(source, left, right)(combineMat)(
implicit builder =>
(source, left, right) => {
import GraphDSL.Implicits._
@ecyshor
ecyshor / EitherSourceExtension.scala
Created March 31, 2020 18:08
Akka streams partition either
implicit class EitherSourceExtension[L, R, Mat](source: Source[Either[L, R], Mat]) {
def partition(left: Sink[L, NotUsed], right: Sink[R, NotUsed]): Graph[ClosedShape, NotUsed] = {
GraphDSL.create() { implicit builder =>
import akka.stream.scaladsl.GraphDSL.Implicits._
val partition = builder.add(Partition[Either[L, R]](2, element => if (element.isLeft) 0 else 1))
source ~> partition.in
partition.out(0).collect {
case Left(value) => value
} ~> left
@ecyshor
ecyshor / index.js
Last active January 15, 2017 17:42
Lambda used to deploy other lambdas
console.log('Preparing deployment function.')
var AWS = require('aws-sdk');
var lambda = new AWS.Lambda();
var lambdasToDeploy = JSON.parse(new Buffer(process.env.CONFIGURATION, 'base64').toString("ascii"));
exports.handler = function(event, context) {
console.log('Running deployment function for ' + JSON.stringify(lambdasToDeploy));
key = event.Records[0].s3.object.key
bucket = event.Records[0].s3.bucket.name
version = event.Records[0].s3.object.versionId