Skip to content

Instantly share code, notes, and snippets.

package io.bazel.kotlin.compiler.plugins.strictdeps
import com.google.protobuf.TextFormat
import com.intellij.openapi.project.Project
import com.intellij.openapi.vfs.VfsUtilCore
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.psi.PsiElement
import io.bazel.kotlin.compiler.BazelCompiler
import io.bazel.kotlin.model.JvmCompilationTask
import io.bazel.kotlin.model.StrictDeps
// Idiomatic and efficient stack. Uses a single array.
type Stack interface {
// Push adds an item to a stack.
Push(i int)
// Pop is the item that was popped, max and sz represent the state of the stack after the pop.
Pop() (cur,max, sz int)
// Peek the current state of the stack. An empty stack returns all zeros.
Peek() (cur,max, sz int)
}
@hsyed
hsyed / kt_grpc_library.bzl
Created June 26, 2018 23:52
Adapted version of java_grpc_library
# adapted from grpc-java
load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_jvm_library")
load("@io_grpc_grpc_java//:java_grpc_library.bzl", "java_grpc_library")
def _path_ignoring_repository(f):
if (len(f.owner.workspace_root) == 0):
return f.short_path
return f.path[f.path.find(f.owner.workspace_root) + len(f.owner.workspace_root) + 1:]
def _gensource_impl(ctx):
@hsyed
hsyed / stubs.kt
Created June 26, 2018 18:46
coroutine binding glue.
package com.axsy.base.grpc.stub
import io.grpc.stub.StreamObserver
import kotlinx.coroutines.experimental.CompletableDeferred
import kotlinx.coroutines.experimental.Deferred
import kotlinx.coroutines.experimental.Job
import kotlinx.coroutines.experimental.channels.LinkedListChannel
import kotlinx.coroutines.experimental.channels.ReceiveChannel
import kotlinx.coroutines.experimental.channels.SendChannel
import kotlinx.coroutines.experimental.launch
package com.github.hsyed.k8s.clusters.model;
import com.github.hsyed.k8s.KubernetesClusterType;
import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import com.google.common.primitives.Booleans;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.ArrayList;
import java.util.List;
@hsyed
hsyed / Supfile
Created September 27, 2017 18:18
# Sup file for https://github.com/pressly/sup
#
version: 0.5
networks:
workers:
inventory: kubectl get nodes -o json | jq -r '.items[] | select(.metadata.labels["axsy.com/role"] =="worker") | .status.addresses[] | select (.type == "InternalIP") | .address | "core@" + . '
controllers:
inventory: kubectl get nodes -o json | jq -r '.items[] | select(.metadata.labels["kubernetes.io/role"] =="master") | .status.addresses[] | select (.type == "InternalIP") | .address | "core@" + . '
def canonacalize_package_name(prefix, pkg_name):
return pkg_name.replace(prefix, "").replace("/", ".")
def junit_suite_test(name, srcs, deps, prefix = "src/test/java", size="small", resources=[], classpath_resources=[], jvm_flags=[], tags=[], data=[]):
tests = []
if not prefix.endswith("/"):
prefix = prefix + "/"
for src in srcs:
if src.endswith("Test.java"):
type AdminM {
# schema mutations
schema: SchemaNodeM!
}
type AdminQ {
# details about this org
info: Org!
# schema queries
@hsyed
hsyed / queryer.go
Last active March 28, 2021 10:14
context queryer outline
package runtime
import (
"context"
"errors"
"github.com/jackc/pgx"
)
const (
existingTXError = "tx allready in progress"
# remove the newline after the next line and it won't work.
# gazelle:ignore
load("@io_bazel_rules_go//go:def.bzl", "go_library")
config_setting(
name = "darwin",
values = {"cpu": "darwin"},
)