This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"unsafe" | |
) | |
// A demo of things you can do with strings and []byte slices | |
// in a dangerous and exciting ways. I got here by having to verify | |
// if two given strings point to the same storage in memory. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# A kind of an alias support for the Perforce p4. | |
# | |
# This one aliases "interchanges" and "changes" commands to be printed out nicely in format: | |
# | |
# Change <change_no> on <date> by <user>@<workspace> [<status>] | |
# <first line of change description> | |
# -- | |
# Change <change_no> on <date> by <user>@<workspace> [<status>] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module LogAgent = | |
// Log writer implementation using F# asynchronous agents | |
// Written as an excersise | |
open System | |
open System.IO | |
type private Message = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"net/http" | |
"net/http/httputil" | |
) | |
func handler(w http.ResponseWriter, r *http.Request) { | |
var formatted, err = httputil.DumpRequest(r, true) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
open System.Text | |
/// Join a sequence of strings using a delimiter. | |
/// Equivalent to String.Join() but without arrays. | |
let join (items : seq<string>) (delim : string) = | |
// Collect the result in the string builder buffer | |
// The end-sequence will be "item1,delim,...itemN,delim" | |
let buff = | |
Seq.fold |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Shows how to get auth token for VSTS (Azure Devops) from Azure CLI. | |
# | |
# Extracted from various github projects: Azure CLI and Azure SDK for Go | |
# See: https://github.com/Azure/azure-sdk-for-go/blob/ca5ebc8601ba1af17b289bb42161b7afb496423f/eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1#L17 | |
# VSTS / Azure Devops resource identifier is: "499b84ac-1321-427f-aa17-267ca6975798" | |
organisation="your_org" | |
project="your_project" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
# This creates a deployment where each pod has two containers: | |
# - Docker Server: the actual docker engine. | |
# - Docker Client: simple Ubuntu instance with docker cli so we can | |
# test the docker things. In practice this would be some CI agent | |
# like Azure Devops agent or Jenkins or anything at all. | |
# | |
# After this deployment is created, wait for a bit for docker CLI to be installed | |
# in the client container. Then shell into it and use docker commands like docker build etc | |
# to test that things actually work. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Many a time we have HTML articles published across multiple pages. | |
% And sometimes we want to print all those pages as one PDF. | |
% Here is how to do it: | |
% - Print into PDF from the browser into files like p01.pdf, p02.pdf etc | |
% - Use LaTeX to assemble these into one PDF. | |
% | |
% Here is the example. The \includepdf command supports scaling too, | |
% and I'm sure some other interesting commands as well. | |
% | |
% [copylifted from: http://yusung.blogspot.com/2007/02/combine-several-pdf-files-using-latex.html] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a hack to obtain azurerm_user_assigned_identity data item from | |
# the cluster.identity object. | |
# | |
# The reason we need this is depending on the kind of identity (SystemAssigned, | |
# UserAssigned) we have different fields in that object. In particular if we | |
# have UserAssigned identity, the value of principal_id will be empty, and | |
# we need to assign roles to it like Network Contributor. | |
# | |
# To use: | |
# # Grab the cluster data item |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -eu | |
# Noddy script to encrypt/decrypt files using openssl private (ssh) key. | |
# Works with files and stdin. | |
# Results are stdout. | |
# | |
# Requirements: | |
# - openssl | |
# - ssh private key: ~/.ssh/id_rsa |
NewerOlder