Skip to content

Instantly share code, notes, and snippets.

View itaysk's full-sized avatar

Itay Shakury itaysk

View GitHub Profile
@itaysk
itaysk / jsonbench_test.go
Created July 18, 2020 10:08
golang json bench
// benchmark various json parsing and querying libraries on the use case of finding the image of the first container of a Kubernetes Pod
package jsonbench
import (
"encoding/json"
"io/ioutil"
"testing"
"github.com/Jeffail/gabs/v2"
"github.com/itchyny/gojq"
@itaysk
itaysk / python-build.20200602081612.15621.log
Created June 2, 2020 08:36
asdf python install 3.8.3 fail log
This file has been truncated, but you can view the full file.
/tmp/python-build.20200602081612.15621 ~/.asdf/plugins/python/pyenv
/tmp/python-build.20200602081612.15621/Python-3.8.3 /tmp/python-build.20200602081612.15621 ~/.asdf/plugins/python/pyenv
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for python3.8... no
checking for python3... python3
checking for --enable-universalsdk... no
checking for --with-universal-archs... no
checking MACHDEP... "linux"
@itaysk
itaysk / Makefile
Last active April 30, 2020 15:32
Embed file in Go using go link flag
b64contents = $(shell base64 -w 0 myfile)
build:
go build -ldflags "-X main.myfile=$(b64contents)"
@itaysk
itaysk / Makefile
Last active April 29, 2020 09:44
Embed file in Go using one line go generate
build:
go generate
go build
@itaysk
itaysk / spark-avro-json-sample.py
Created January 14, 2017 16:40
How to process Event Hub Archive's files using Spark
from pyspark.sql import SparkSession
spark = SparkSession \
.builder \
.appName("spark-avro-json-sample") \
.config('spark.hadoop.avro.mapred.ignore.inputs.without.extension', 'false') \
.getOrCreate()
#storage->avro
avroDf = spark.read.format("com.databricks.spark.avro").load(in_path)
@itaysk
itaysk / get-kubectl-jq.sh
Last active March 27, 2019 11:45
Kubernetes Pod Conditions
kubectl get po mypod -ojson | jq '.status.conditions[] | select(.type=="mycondition") | .status' -r
@itaysk
itaysk / legacy-query-oms
Created November 10, 2018 16:13
Determine who created resources in Azure using Log Analytics
(ResourceGroup=<ResourceGroupName>) (Resource=<ResourceName>) (ActivityStatus=Succeeded)
| Sort TimeGenerated asc
| Top 1
| Select Caller
@itaysk
itaysk / index.js
Created January 19, 2017 10:08
Securing Single Page Applications with Azure AD
var aadTenant = "yourTenant.onmicrosoft.com",
spaClientId = "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}", //AAD app client id for this app
serviceClientId = "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}", //AAD app client id for the service API app
var serviceUrl = "http://localhost:8081/api/doSomething"; // the service API endpoint
var authContext = new AuthenticationContext({
instance: 'https://login.microsoftonline.com/',
tenant: aadTenant,
clientId: spaClientId,
postLogoutRedirectUri: window.location.origin,
@itaysk
itaysk / azure_batch_quick_start.py
Created October 7, 2016 19:49
Azure Batch quick start
import os
import azure.batch.batch_service_client as batch
import azure.batch.batch_auth as batchauth
import azure.batch.models as batchmodels
#---------------------parameters---------------------#
#--------------this is the part you edit-------------#
batch_account_name = "<your batch account name here>"
batch_account_url = "<your batch account url here>"
@itaysk
itaysk / multi_request_retry.js
Last active August 28, 2016 14:07
Submit multiple http promised requests with retry
//demonstrates how to submit multiple http requests, while making sure each is resilient to transient errors using retries
var Promise = require('bluebird');
var rp = require('request-promise');
var retry = require('bluebird-retry');
var createPromise = function(i) {
return retry(function () {
return rp('http://localhost:8000?q='+i).promise();
}, {