Skip to content

Instantly share code, notes, and snippets.

View sparkprime's full-sized avatar

Dave Cunningham sparkprime

View GitHub Profile
local function gfx_hud_object_add(name, tab)
print('gfx_hud_object_add("' .. name .. '", ' .. tostring(tab) .. ')')
end
local function thingy(path)
self = {
path = path
}
setmetatable(self, {
__index = function(self, k)
@sparkprime
sparkprime / kpm.jsonnet
Created May 31, 2016 18:29
KPM-themed example of using jinja expansion in Jsonnet
local native_expand_template = std.native("expand_template");
{
expand_template(template, env): [
native_expand_template(template, std.toString(env))
],
expand_sharded_template(template, env, all_shards): [
native_expand_template(template, std.toString(env + { shard_name: shard_name }))
for shard_name in all_shards
@sparkprime
sparkprime / test.jsonnet
Created May 28, 2016 18:27
Expanding Jinja within Jsonnet via Python bindings
local expand_template(template, vars) =
std.native("expand_template")(template, std.toString(vars));
{
response: expand_template(|||
Hello {{ title }} {{ family_name }}, please take a seat.
|||, {
title: "Dr",
family_name: "Frankenstein",
@sparkprime
sparkprime / main.jsonnet
Last active March 15, 2021 06:43
Example of string templating within Jsonnet
{
template: (importstr "template.yaml") % {
name: "rabbitmq",
image: "whatever",
cookie: "XXXX",
data_volume: std.toString({ name: "thing", foo: [1, 2, 3] }),
nodes: std.toString(['rabbit@rabbitmq-%s' % shard_name for shard_name in [1, 2, 3]]),
},
}
@sparkprime
sparkprime / manifest.jsonnet
Created May 19, 2016 17:18
rabbitmq kpm jsonnet
local resources = import "resources.libsonnet";
// "Top-level" function -- parameters can be overridden from the commandline.
// (Syntax is like Python)
function(
cookie="Dffds9342",
data_volume={
emptyDir: {
medium: "",
},
@sparkprime
sparkprime / Makefile
Created May 5, 2016 23:48
g++ pch problem
%.h.gch: %.h
@mkdir -p out
g++ -Wall -Wextra -pedantic -x c++-header -I. $< -o out/$@
main: main.cpp header.h.gch
@mkdir -p out
g++ -Wall -Wextra -pedantic -Winvalid-pch -I out $< -o out/$@
clean:
rm -rfv out *~
package main
import (
"bytes"
"encoding/json"
"fmt"
"github.com/Masterminds/sprig"
"github.com/cloudfoundry-incubator/candiedyaml"
"github.com/ghodss/yaml"
"io"