Skip to content

Instantly share code, notes, and snippets.

@mkmik
mkmik / main.dart
Last active August 5, 2019 17:35
test
import 'dart:math';
var random = Random.secure();
Future<int> rand() {
return Future.delayed(new Duration(seconds: 1), () { return random.nextInt(200); });
}
Future<int> get() async {
print("beginning to save");

Config file with embedded secrets

Kubernetes Secrets are very flexible and can be consumed in many ways. Secret values can be passed to containers as environment variables or appear as regular files when mouting secret volumes.

Often users end up using the latter method just to wrap full configuration files into k8s secrets, just because one or more fields in the config file happen to be secrets (e.g. a database password, or a session cookie encryption key).

Ideally you should avoid configuring your software that way and instead splitting your configuration from your secrets somehow. Also make sure you know about 12 Factor.

#!/bin/bash
fake_command() {
echo some junk
return 1
}
demo() {
FOO="$(fake_command)"
package main
import (
"fmt"
"log"
"github.com/google/go-jsonnet"
"github.com/google/go-jsonnet/ast"
"github.com/google/go-jsonnet/toolutils"
)
#!/bin/bash
kapp deploy -c -y -a kdemo -f app.yaml
trap 'kill $(jobs -p)' EXIT
kubectl port-forward deploy/kdemo 8080:8080 &
sleep 2
curl http://localhost:8080
#!/bin/bash
set -e
path="$1"
if [ -z "${path}" ]; then
echo "usage: $0 <package or path>"
exit 1
fi
@mkmik
mkmik / fetch.sh
Last active August 14, 2020 09:35
for i in $(crane ls bitnami/node | grep -E '^[0-9]+'); do crane manifest bitnami/node:$i; done >/tmp/layers.jsonish
// Turns out that this iterator is unnecessary since the std::option::Option type
// itself implements this exact semantics
/// An iterator that yields an element once or never.
///
/// This `struct` is created by the [`once_if_ever`] function. See its documentation for more.
pub struct OnceIfEver<T> {
value: Option<T>,
}
[package]
name = "prostdemo"
version = "0.1.0"
authors = ["Marko Mikulicic <[email protected]>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
prost = "0.7"
use std::process::{Command, Stdio};
use std::os::unix::net::UnixStream;
use std::os::unix::io::{AsRawFd,FromRawFd};
fn main() {
let (_sock1, sock2) = UnixStream::pair().unwrap();
Command::new("sleep")
.arg("200")
.stdin(unsafe{Stdio::from_raw_fd(sock2.as_raw_fd())})