Skip to content

Instantly share code, notes, and snippets.

View Duologic's full-sized avatar

Jeroen Op 't Eynde Duologic

View GitHub Profile

${\textsf{\color{violet}I}}$ $${\color{blue}should}$$ $${\color{red}not}$$ $${\color{green}use}$$ $${\color{purple}this}$$ $${\color{orange}in}$$ $${\color{yellow}README}$$

@Duologic
Duologic / tfconstructors.jsonnet
Created February 22, 2025 13:34
Trying out different constructor options.
{
resource:: {
// 1: Render resource with manifest function
route53: {
new(name):
{
local this = self,
manifest(key=self.name):: {
resource+: {
route53+: {
// 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": {