Skip to content

Instantly share code, notes, and snippets.

View akarca's full-sized avatar
🏠
Working from home

Serdar Akarca akarca

🏠
Working from home
View GitHub Profile
@akarca
akarca / kill_cmfsyncagent.sh
Last active January 8, 2024 19:02
Kill CMFSyncAgent and sharingd processes if they demand high cpu
#!/bin/bash
#
# Sometimes my mac's fans run loud because CMFSyncAgent and sharingd processes are consuming high amount of CPU.
# This script watches the processes and kills them. Stop this script if you want to use AirDrop
# Kill CMFSyncAgent if it consumes more than 70% cpu
# Kill sharingd if it consumes more than 30% cpu
#
while true
do
ps aux | grep CMFSyncAgent | awk '$3>70 {print $2}' | xargs kill -9
@akarca
akarca / isimler
Created January 6, 2023 14:16 — forked from emrekgn/isimler
Türkçe İsim Listesi
JALE
ALİ
MAHMUT
MANSUR KÜRŞAD
GAMZE
MİRAÇ
YÜCEL
KUBİLAY
HAYATİ
BEDRİYE MÜGE
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
const origSet = XMLHttpRequest.prototype.setRequestHeader;
XMLHttpRequest.prototype.setRequestHeader = function(header, value) {
if(header == "authorization") { window.authorization = value; }
origSet.apply(this, arguments);
};
@akarca
akarca / generate_vpa.sh
Last active April 15, 2021 09:07
Automatic VPA generator for all deployments in namespace
#!/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 {} \;
@akarca
akarca / config.fish
Created April 14, 2021 08:29
Kubernetes Resource Optimizer Tool
#
# 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 "}}}}")
@akarca
akarca / fish_config_kubernetes.fish
Last active January 8, 2023 22:47
kubectl alias functions with grep for fish shell
# 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
#!/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]
@akarca
akarca / gist:d3a44e2a629d8581179cab086a012fbf
Created September 24, 2018 13:11
credit card formatter
var getFormattedValue = function (value, blocks, delimiter) {
var result = '',
currentDelimiter;
var blocksLength = blocks.length;
// no options, normal input
if (blocksLength === 0) {
return value;
}
@akarca
akarca / install_ffmpeg.sh
Created May 13, 2018 22:04 — forked from Piasy/install_ffmpeg.sh
brew install ffmpeg with all options
brew options ffmpeg
brew install ffmpeg \
--with-chromaprint \
--with-fdk-aac \
--with-fontconfig \
--with-freetype \
--with-frei0r \
--with-game-music-emu \
--with-libass \