Skip to content

Instantly share code, notes, and snippets.

View figaw's full-sized avatar
:octocat:
Config as Code? Kong Figaw's Code!

Nicolaj Græsholt figaw

:octocat:
Config as Code? Kong Figaw's Code!
View GitHub Profile
@figaw
figaw / Log.php
Last active January 7, 2021 21:39
Basic logging for PHP in JSON to stdout with Loglevel configurable from environment variables.
<?php
$LOGLEVEL = 5;
if( isset($_SERVER['LOGLEVEL']) && is_numeric(Log::LEVELS[$_SERVER['LOGLEVEL']])){
$LOGLEVEL = Log::LEVELS[$_SERVER['LOGLEVEL']];
}
abstract class Log
{
@figaw
figaw / benchmark.sh
Created February 8, 2020 16:27
Time a shell command
#!/bin/bash
date +"%T"
SECONDS=0
sleep 5
date +"%T"
duration=$SECONDS
echo "$(($duration / 60)) minutes and $(($duration % 60)) seconds elapsed."
@figaw
figaw / SLACK-API-EXAMPLE.MD
Created September 30, 2019 10:52
An example of using the Slack Api

Slack API Example: How to get a list of channels.

Create a new app

  1. Go to https://api.slack.com/
  2. Click "Start Building"
  3. Create a new app

Figure out needed permissions

@figaw
figaw / charter.sh
Created September 25, 2019 12:29
QoL script for templating a number of "values-*.yaml" files for Helm. #Kubernetes #k8s #Helm
#!/bin/bash
CHARTNAME=oauth2-proxy #used in flatten()
## USAGE
# 000. replace the CHARTNAME above
# 00. `cd` to the `chartname`-folder (the one containing the `Charts.yaml`-file)
# 0. Append the .gitignore
# --- .gitignore ---
# # script
# charter.sh
# # m-folders and values-
This file has been truncated, but you can view the full file.
{
"name": "flare",
"children": [
{
"name": "QueueRemote",
"children": [
{
"name": "Stormy Metsky",
"size": 4,
"color": "#E873B2"
{
"name": "flare",
"children": [
{
"name": "./QueueRemote",
"children": [
{
"name": "Stormy Metsky",
"size": 4,
"color": "#E873B2"
{
"name": "flare",
"children": [
{
"name": "./compat",
"children": [
{
"name": "Anton Serbulov",
"size": 1,
"color": "#FEED4E"
{
"name": "flare",
"children": [
{
"name": "./block-sha1",
"children": [
]
},
{
@figaw
figaw / contribs-wo-contrib-contribcomp-po
Created January 16, 2019 13:50
from contribs-wo-t-builtin-docs
{
"name": "flare",
"children": [
{
"name": "./block-sha1",
"children": [
]
},
{
{
"name": "flare",
"children": [
{
"name": "./block-sha1",
"children": [
]
},
{