Skip to content

Instantly share code, notes, and snippets.

View kostyay's full-sized avatar

Kostya Ostrovsky kostyay

View GitHub Profile
@kostyay
kostyay / Caddyfile
Created April 16, 2024 20:47
Rails app with Postgres and Caddy on Hetzner VPS with Docker Compose
{
email my@email.com
}
my.host.com {
encode zstd gzip
log {
output stdout
}
@kostyay
kostyay / sublime_close_without_saving.py
Created January 9, 2023 09:44
Sublime 3 Close All Windows without saving
# This will close all views (files open in specific window) without asking to save them
# You can register it to a keyboard shorcut using this snippet
# {"keys": ["ctrl+shift+q"], "command": "close_without_saving"}
import sublime
import sublime_plugin
class CloseWithoutSaving(sublime_plugin.WindowCommand):
def run(self):
window = self.window
@kostyay
kostyay / service-account-admin-sdk.go
Last active November 29, 2022 15:52
[Golang] Use google admin sdk from service account impersonating as user #adminsdk
// It took me few hours how to get this to work
// Have a service account in GCP which wanted to use Admin SDK with Google Workspace
// The service account needs to have the following role: `roles/iam.serviceAccountTokenCreator`
// You need to create a domain wide delegation for the service account client id
import (
"google.golang.org/api/impersonate"
"google.golang.org/api/option"
"context"
)
/BTS7960 motor driver sketch
int R_IS = 1;
int R_EN = 2;
int R_PWM = 3;
int L_IS = 4;
int L_EN = 5;
int L_PWM = 6;
void setup() {
@kostyay
kostyay / envoy.yaml
Created September 26, 2020 16:39
Envoy configuration
admin:
access_log_path: /dev/stdout
address:
socket_address: { address: 0.0.0.0, port_value: 9901 }
static_resources:
listeners:
- name: listener_0
address:
socket_address: { address: 0.0.0.0, port_value: 8080 }
@kostyay
kostyay / client.js
Created September 26, 2020 16:34
grpc-web javascript
// Import the client and the message definition
import { TimeServiceClient } from '../jsclient/time/v1/time_service_grpc_web_pb';
import { GetCurrentTimeRequest } from '../jsclient/time/v1/time_service_pb';
// Connect to the gprc-web server
const client = new TimeServiceClient("http://localhost:8080", null, null);
// This is a neat chrome extension that allows you to spy on grpc-web traffic just like you would on normal traffic.
// You can find it here: https://chrome.google.com/webstore/detail/grpc-web-developer-tools/ddamlpimmiapbcopeoifjfmoabdbfbjj?hl=en
const enableDevTools = window.__GRPCWEB_DEVTOOLS__ || (() => {});
enableDevTools([
@kostyay
kostyay / main.go
Created September 26, 2020 16:31
time-server
package main
import (
"context"
"log"
"net"
"time"
pb "github.com/kostyay/grpc-web-example/time/goclient/time/v1"
"google.golang.org/grpc"
@kostyay
kostyay / time_service.proto
Created September 26, 2020 16:20
Time Service
syntax = "proto3";
package smpl.time.api.v1;
option go_package = "github.com/kostyay/grpc-web-example/api/time/v1";
message GetCurrentTimeRequest {
}
message GetCurrentTimeResponse {
@kostyay
kostyay / protodep.toml
Created April 3, 2020 15:02
Example protodep.toml file
proto_outdir = "./protodep"
[[dependencies]]
target = "github.com/mwitkow/go-proto-validators"
branch = "master"
path = "github.com/mwitkow/go-proto-validators"
ignores = ["./test", "./examples"]
[[dependencies]]
target = "github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis/google/api"
@kostyay
kostyay / prototool.json
Created April 3, 2020 13:41
StackPulse prototool configuration
{
"excludes": [
"protodep",
"js"
],
"protoc": {
"version": "3.11.4",
"includes": [
"/project",