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 | |
unameOut="$(uname -s)" | |
case "${unameOut}" in | |
Darwin*) yesterday=$(date -v-1d "+%s");; | |
*) yesterday=$(date +%s --date="-1 days");; | |
esac | |
echo $yesterday |
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
import logging | |
import socket | |
log = logging.getLogger('udp_server') | |
def udp_server(host='127.0.0.1', port=1234): | |
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | |
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) |
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
brew options ffmpeg | |
brew install ffmpeg \ | |
--with-chromaprint \ | |
--with-fdk-aac \ | |
--with-fontconfig \ | |
--with-freetype \ | |
--with-frei0r \ | |
--with-game-music-emu \ | |
--with-libass \ |
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
var getFormattedValue = function (value, blocks, delimiter) { | |
var result = '', | |
currentDelimiter; | |
var blocksLength = blocks.length; | |
// no options, normal input | |
if (blocksLength === 0) { | |
return value; | |
} |
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 python | |
list1 = [5, 9, 23, 4, 3, 8, 1, 12, 2, 9, 15, 19, 11, 27, 0] | |
list2 = [77, 21, 23, 29, 51, 40, 15, 72, 18, 44, 96, 92, 86, 24, 2, 26, 16, 71, 46, 56, 92, 34, 97, 51, 3, 14, 31, 71, 29, 4, 72, 28, 41, 50, 52, 1, 51, 8, 83, 57] | |
list3 = [] | |
list4 = [1] | |
list5 = [1, 2] | |
list6 = [2, 1] | |
list7 = [1, 2, 3] | |
list8 = [3, 1, 2] |
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
# Usage: kg deploy consumer // shows all deploy names containes consumer | |
# Usage: kg pods listener // shows all pod names containes listener | |
# Usage: kg pods listener -A // shows all pod names containes listener in all namespaces | |
function kg | |
set ARGS (count $argv) | |
if test $ARGS -gt 2 | |
kubectl get $argv[1] $argv[3..-1] | grep "NAME\|$argv[2]" | |
else if test $ARGS -gt 1 | |
kubectl get $argv[1] | grep "NAME\|$argv[2]" | |
else |
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
# | |
# Usage: krecommend namespace deployname | |
# Collect recommendations from vpa, patch cpu and memory resource of a deployment. | |
# | |
# usage: patchrequests namespace deploy 250m 500Mi | |
function patchlimits | |
set --local pdata (kubectl get deploy -n $argv[1] $argv[2] -o json | jq '.spec.template.spec.containers' | jq '.[0].resources.limits = {"cpu": "'$argv[3]'","memory":"'$argv[4]'"}') | |
set --local pdata2 (echo "{\"spec\":{\"template\":{\"spec\":{\"containers\":" $pdata "}}}}") |
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 | |
# | |
# Usage: ./generate_vpa.sh namespace | |
# | |
# Generates yaml files for vpa and applies. | |
# | |
mkdir -p "yaml/"$1"/" | |
kubectl get deploy -n $1 | grep -v NAME | awk -v namespace=$1 '{print $1" "namespace}' | awk '{ system("sed -e \"s/\{namespace}/"$2"/\" -e \"s/\{name}/"$1"/\" vpa.tpl > yaml/"$2"/"$1".yaml") }' | |
find "yaml/"$1 -name "*.yaml" -exec kubectl apply -f {} \; |
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
const origSet = XMLHttpRequest.prototype.setRequestHeader; | |
XMLHttpRequest.prototype.setRequestHeader = function(header, value) { | |
if(header == "authorization") { window.authorization = value; } | |
origSet.apply(this, arguments); | |
}; |
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
def grep(text, match, after=0, before=0): | |
""" | |
Return matched lines in given text as a list. Similar to grep function but a simple one. | |
""" | |
idx = [] | |
lines = text.split("\n") | |
for i, line in enumerate(lines): | |
if str(match) not in line: | |
continue |
OlderNewer