Skip to content

Instantly share code, notes, and snippets.

@muvaf
muvaf / EmotionService.cs
Last active September 19, 2023 11:01
Here is the script I used for Emotion Recognition in Unity [Microsoft Cognitive Services]
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Globalization;
using System;
public class EmotionService : MonoBehaviour {
WebCamTexture webCamTexture;
@muvaf
muvaf / copy_image_to_cluster.sh
Created July 18, 2019 08:33
Copy images from your local host to minikube cluster
# This is an excerpt from https://github.com/crossplaneio/crossplane/blob/master/cluster/local/minikube.sh
# I think it's pretty useful on its own.
#!/usr/bin/env bash
set -eE
function copy_image_to_cluster() {
local build_image=$1
local final_image=$2
docker save "${build_image}" | (eval "$(minikube docker-env --shell bash)" && docker load && docker tag "${build_image}" "${final_image}")
@muvaf
muvaf / apply.sh
Last active May 15, 2020 01:43
How to do kubectl apply to a github folder
# This feature is provided by kustomize that is embedded into kubectl.
# So, you have to have a kustomization.yaml in the folder that has a list of files and folders under `resources:` array.
# Here is the folder we'll deploy: https://github.com/muvaf/crossplane/tree/kapp-coredef/cluster/composition/clusterroles
# Assuming you got that right:
# With git commit hash
kubectl apply -k 'github.com/muvaf/crossplane/cluster/composition/clusterroles?ref=2d2c011'
# With branch name
apiVersion: v1
kind: Config
clusters:
- cluster:
server: https://proxy.upbound.io/env/<env-id>
name: uimeta
contexts:
- context:
cluster: uimeta
user: acme-corp
@muvaf
muvaf / get-kubeconfig.sh
Last active March 8, 2021 23:40
Get kubeconfig for a Service Account without modifying existing kubeconfig
#!/bin/bash
set -eE
# jq has to be installed.
# ./get-kubeconfig.sh sa-name > tmp-cfg
SA_NAME=${1}
SECRET_NAME=$(kubectl get serviceaccount ${SA_NAME} -o jsonpath='{.secrets[0].name}')
CERT_AUTH_DATA=$(kubectl get secret ${SECRET_NAME} -o jsonpath='{.data.ca\.crt}')
@muvaf
muvaf / provider-aws-ack.md
Last active January 25, 2021 23:17
provider-aws ack code generation availability

v1alpha1: might miss some functionality.
v1beta1: fully supported.
available: can be generated today.
buggy: a bug needs to be fixed for code generation to work.

AWS Service Current Status Next Milestone Crossplane
Amazon [ACM][Amazon ACM] PROPOSED v1beta1
Amazon [API Gateway V2][Amazon API Gateway v2] DEVELOPER PREVIEW BETA v1alpha1
apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
name: compositepostgresqlinstances.aws.database.example.org
labels:
provider: aws
guide: quickstart
vpc: default
spec:
writeConnectionSecretsToNamespace: crossplane-system
@muvaf
muvaf / example.sh
Created May 30, 2021 17:25
Partial find and replace with regex
# In most text editors, there is an option to find a string using regex.
# But what if you'd like to replace a specific sentence in the expression?
# For example, let's say there are following strings in different files:
#
# NewGeneratorForService(t, "apigatewayv2")
# NewGeneratorForService(t, "rds")
#
# And you'd dike to add a new argument to all these calls and make them like following:
#
# NewGeneratorForService(t, "apigatewayv2", ackgenconfig.DefaultConfig)
{
"typeName": "AWS::ACMPCA::Certificate",
"description": "A certificate issued via a private certificate authority",
"sourceUrl": "https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/AWS_ACMPCA.html",
"definitions": {
"ApiPassthrough": {
"description": "Structure that specifies fields to be overridden in a certificate at the time of issuance. These requires an API Passthrough template be used or they will be ignored.",
"type": "object",
"additionalProperties": false,
"properties": {
@muvaf
muvaf / groups.go
Last active March 9, 2024 03:39
A small script to get all package-based groupings from TF AWS Provider
package main
import (
"fmt"
"sort"
"strings"
)
func main() {
lines := strings.Split(resources, "\n")