Skip to content

Instantly share code, notes, and snippets.

View Duologic's full-sized avatar

Jeroen Op 't Eynde Duologic

View GitHub Profile
// Run like this: `eval $(jsonnet -S <this file>)`
//
// versions.libsonnet has entries like this:
// {
// cacheRestore: {
// version: 'v4.0.2',
// sha: '0c45773b623bea8c8e75f6c82b208c3cf94ea4f9',
// action: 'actions/cache/restore',
// },
// ...
local xtd = import 'github.com/jsonnet-libs/xtd/main.libsonnet';
local cp = std.codepoint;
// "1" "9"
local onenine(c) = (cp(c) >= 49 && cp(c) <= 57);
// "0"
local digit(c) = (cp(c) == 48 || onenine(c));
// ==UserScript==
// @name Hit sign-in button on Drone
// @description Hit sign-in button on Drone
// @version 1.0
// @namespace https://drone.grafana.net
// @match https://drone.grafana.net/*
// @run-at document-start
// @grant none
// ==/UserScript==
(function() {
local k = import 'ksonnet-util/kausal.libsonnet';
{
new(status='404', name='return', image='httpd:2.4-alpine'):: {
local configMap = k.core.v1.configMap,
configmap:
configMap.new('%s-%s' % [name, status], {
'httpd.conf': |||
ServerRoot "/usr/local/apache2"
Listen 80
@Duologic
Duologic / disable_textarea_github.js
Last active May 25, 2023 09:43
Greasemonkey script to disable Code view <textarea> on Github
// ==UserScript==
// @name Github: Disable codeview Textarea
// @author Duologic
// @match https://*.github.com/*
// @run-at document-end
// ==/UserScript==
console.log('Github: Disable codeview Textarea');
const selector = '#read-only-cursor-text-area';
local query = 'foo : value1,bar : value2\\,value3';
//local query = 'foo,bar : value2\\,value3';
//local query = 'foo : value1,bar';
//local query = 'foo,bar';
//local query = '1, a : b, ab : , aa: bb, a :b';
local split = std.mapWithIndex(function(i, c) { index: i, char: c }, query);
std.foldl(
function(acc, item)
@Duologic
Duologic / JsonML.jsonnet
Created February 6, 2023 11:06
Write HTML documents with Jsonnet using JsonML
local element = {
new(tagName, attributes={}): {
tagName: tagName,
attributes: attributes,
elementList: [],
render()::
[
self.tagName,
self.attributes,
{
"name": "v1alpha1",
"schema": {
"openAPIV3Schema": {
"properties": {
"apiVersion": {
"default": "tanka.dev/v1alpha1",
"type": "string"
},
"data": {
@Duologic
Duologic / export.jsonnet
Last active June 7, 2022 00:26
Pure jsonnet implementation of `tanka export` (POC)
{
local this = self,
local clusterWideKinds = [
'APIService',
'CertificateSigningRequest',
'ClusterRole',
'ClusterRoleBinding',
'ComponentStatus',
'CSIDriver',
@Duologic
Duologic / dashboard-as-json.yaml
Created April 7, 2022 08:38
Represent dashboard as json (crossplane-provider-grafana)
apiVersion: grafana.jet.crossplane.io/v1alpha1
kind: Dashboard
metadata:
annotations:
crossplane.io/composition-resource-name: dashboard
creationTimestamp: "2022-04-03T22:43:56Z"
generateName: flux-mixin-6ab3a093b9e4c6d1297daf5e42988330-6m6qh-
generation: 1
labels:
crossplane.io/claim-name: flux-mixin-6ab3a093b9e4c6d1297daf5e42988330