Skip to content

Instantly share code, notes, and snippets.

View rinx's full-sized avatar
🍵
Drinking sencha all the time

Rintaro Okamura rinx

🍵
Drinking sencha all the time
View GitHub Profile
@rinx
rinx / go-use-internal-errors-package.yml
Created September 1, 2024 13:44
ast-grep rule for forcing to use project-scope internal error packages in Go project
# yaml-language-server: $schema=https://raw.githubusercontent.com/ast-grep/ast-grep/main/schemas/rule.json
## FIXME: Replace <INTERNAL_ERRORS_PACKAGE> as your package path
id: use-internal-errors-package
message: use <INTERNAL_ERRORS_PACKAGE> instead
severity: warning
language: Go
rule:
kind: import_spec
any:
@rinx
rinx / google-resource-no-project-attr.yml
Created August 24, 2024 11:01
ast-grep rule for detecting terraform resources that does not have `project` attribute.
# yaml-language-server: $schema=https://raw.githubusercontent.com/ast-grep/ast-grep/main/schemas/rule.json
id: google-resource-no-project-attr
message: All google resource should have `project` attribute.
severity: warning
language: terraform
rule:
kind: block
all:
- has:
#!/usr/bin/env rq
# rq: query data.awsststoken.token
# rq: output-format yaml
package awsststoken
import rego.v1
# METADATA
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
name: vald-ing
spec:
routes:
- kind: Rule
match: Host(`localhost`) && Headers(`Content-Type`, `application/grpc`)
priority: 10
services:
;; https://github.com/vdaas/vald-client-python
(import grpc)
(import [vald.v1.vald [insert_pb2_grpc
search_pb2_grpc
update_pb2_grpc
remove_pb2_grpc]])
(import [vald.v1.payload [payload_pb2]])
(setv channel (grpc.insecure-channel "localhost:8080"))
@rinx
rinx / helmify-kustomize
Created June 3, 2020 02:45 — forked from mumoshu/helmify-kustomize
Run `helmify-kustomize build $chart $env` in order to generate a local helm chart at `$chart/`, from kustomize overlay at `${chart}-kustomize/overlays/$env`
#!/usr/bin/env bash
cmd=$1
chart=$2
env=$3
dir=${chart}-kustomize
chart=${chart/.\//}
build() {
@rinx
rinx / compress_tar_gzip.go
Created May 27, 2020 06:52 — forked from mimoo/compress_tar_gzip.go
How to compress a folder in Golang using tar and gzip (works with nested folders)
package main
import (
"archive/tar"
"bytes"
"compress/gzip"
"fmt"
"io"
"os"
"path/filepath"
@rinx
rinx / core.clj
Created October 27, 2019 08:59 — forked from taylorwood/core.clj
GraalVM polyglot interop between Clojure and JavaScript https://blog.taylorwood.io/2018/11/26/graal-polyglot.html
(ns polydact.core
(:import (clojure.lang IFn)
(org.graalvm.polyglot Context Value)
(org.graalvm.polyglot.proxy ProxyArray ProxyExecutable ProxyObject)))
(set! *warn-on-reflection* true)
(comment
(do
(def context
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.15686275064945221</real>
@rinx
rinx / mc1drad.rs
Created August 27, 2017 06:23
a simple monte carlo 1d radiative transfer code in Rust
extern crate rand;
use std::f64;
use rand::Rng;
struct MCInput {
np: u64,
tau: f64,
sal: f64,
omg: f64,