Instantly share code, notes, and snippets.

View vscode.itermcolors
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.0</real>
View get-latest-version-dockerhub.sh
curl -L --fail "https://hub.docker.com/v2/repositories/${DOCKERHUB_REPO}/${DOCKERHUB_IMAGE}/tags/?page_size=1000" | \
jq '.results | .[] | .name' -r | \
sed 's/latest//' | \
sort --version-sort | \
tail -n 1
View prepull.yaml
apiVersion: apps/v1beta2
kind: DaemonSet
metadata:
name: prepull
annotations:
source: "https://gist.github.com/itaysk/7bc3e56d69c4d72a549286d98fd557dd"
spec:
selector:
matchLabels:
name: prepull
View prepull.yaml
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
name: prepull
annotations:
source: "https://gist.github.com/itaysk/46b518906b62b6ff24c992f16606e157"
spec:
selector:
matchLabels:
name: prepull
View index.js
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,
View spark-avro-json-sample.py
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)
View azure_batch_quick_start.py
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>"
View multi_request_retry.js
//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();
}, {
View AzureWebApp-AddVirtuallApplication.ps1
$webAppProperties = (Get-AzureRmResource -ResourceGroupName $name -ResourceType Microsoft.Web/sites/config -ResourceName "$(WebAppName)/web" -ApiVersion 2015-08-01).Properties
$webAppProperties.VirtualApplications += [pscustomobject]@{VirtualPath="/$($VirtualPath)"; PhysicalPath="$PhisicalPath"; PreloadEnabled="False"; VirtualDirectories=$null}
#VirtualPath = a the URL path to create. PhisicalPath = a folder in the server to map to, relative to "Home" directory (to create an app parallel to wwwroot, physicalPath should be like "site\newVA")
Set-AzureRmResource -ResourceGroupName $RGname -ResourceType Microsoft.Web/sites/config -ResourceName "$(WebAppName)/web" -ApiVersion 2015-08-01 -Properties $webAppProperties -Force
View Test_LB.js
var request = require('request');
var a=0 ,b = 0, c=0;
var count=100;
for (var i = 0; i < count; i++) {
request('http://23.97.149.255/', function (error, response, body) {
if (!error && response.statusCode == 200) {
if (body == "10.2.0.4\n") {
a++;
}
else if (body == "10.2.0.6\n") {