Skip to content

Instantly share code, notes, and snippets.

View AvnerCohen's full-sized avatar
🌍
Working from home

Avner Cohen AvnerCohen

🌍
Working from home
View GitHub Profile
@AvnerCohen
AvnerCohen / bash_redo.sh
Created February 16, 2023 13:14
Retry bash and sleep between retries, also limit number retries
#!/bin/bash
RETRIES=5
SLEEP_IN_SECONDS=2
RETURN_CODE=99
counter=0
until [[ $RETURN_CODE -eq "0" || $counter -ge $RETRIES ]] ; do
# next line you should run the command, false and echo are just sample placeholders for the test
@AvnerCohen
AvnerCohen / osx_volume_balance_fix.script
Last active March 7, 2023 09:56
OSX Apple Script - Jabra mute fix (input volume) and Balance fix (just a wtf)
#!/bin/bash
while true ; do
osascript -e "set volume input volume 100"
echo "$(date): Increased volume"
sleep 1;
done;
@AvnerCohen
AvnerCohen / elb-with-no-targets.py
Created June 23, 2022 12:48
boto3 based script to find ELB (AWS Load balancers) without targets (very näive, use with cautios)
import boto3
LB_TO_TARGET_ARN = {}
def main():
client = boto3.client('elbv2')
load_balancers = client.describe_load_balancers()
for lb in load_balancers['LoadBalancers']:
lb_arn = lb['LoadBalancerArn']
attr_for_lb = client.describe_listeners(LoadBalancerArn=lb_arn)
@AvnerCohen
AvnerCohen / iterm2_install.sh
Created April 25, 2022 18:00
Find and Install On Mac, Latest Iterm2
#!/bin/bash -e
URL_TO_DOWNLOAD=$(curl -s "https://iterm2.com/downloads.html" | grep "https://iterm2.com/downloads/stable/" | head -1 | awk '/http/{ print $4 }' | sed -e 's/"/\n/g' | sed -n '2p')
curl -L -s -o iTerm2.zip $URL_TO_DOWNLOAD
unzip iTerm2.zip
mv iTerm.app /Applications
rm iTerm2.zip
echo "Done - Installed - ${URL_TO_DOWNLOAD}"
@AvnerCohen
AvnerCohen / auto-tag.sh
Created May 20, 2021 06:31
Automatic Git Tagging for Shared Libraries
#!/bin/bash
# When executing in circleci, make sure a user is defined in git config
CURRENT_NAME=$(git config user.name)
if [[ -z $CUR_NAME ]]; then
git config user.name "CI USER"
git config user.email ci-user@companyname.biz
echo "Git names init done."
fi
@AvnerCohen
AvnerCohen / example.ts
Created May 31, 2020 13:54
Deno standard library MD5 example.
import { Md5 } from "https://deno.land/std/hash/md5.ts"
const md5 = new Md5();
d5.update("moshe").toString();
// Other hash functions - https://deno.land/std/hash
@AvnerCohen
AvnerCohen / sox_examples.md
Last active May 24, 2020 20:53
SOX Examples - Various Audio manipulations

Use to cut 5 seconds from end of the file.

sox input output reverse trim 5 reverse

Converts the samplerate to 48kHz:

sox infile.wav -r 48k outfile.wav

@AvnerCohen
AvnerCohen / changed_since_last_commit.sh
Created November 27, 2019 20:13
Show List of files changed since last commit - allow to feed that into CI operations that needs some optimization, say linting on YAMLs
#!/bin/bash -e
LATEST_TAG=$(git describe --tags $(git rev-list --tags --max-count=1))
git diff --name-only --diff-filter=ACM $LATEST_TAG HEAD
@AvnerCohen
AvnerCohen / install_poppler.sh
Created July 26, 2018 11:57
Install popller and pdfparser on Centos 6 / Amazon AMI
#!/bin/bash -e
set -x
# Poppler is used by resume parser for a faster PDF data extraction.
# Deploy is a bit man ual and complicated because of the C libs involved
# the fact no pip is used (anaconda and not virtualenev) and that the
# Cmake version eeds to be be udpated as part of it.
CMAKE_VERSION='3.6.2'
POPPLER_VERSION="poppler-0.67.0"
TARGET_DIR='/opt/poppler'
@AvnerCohen
AvnerCohen / random.rb
Created July 1, 2018 14:04
Test Gist
Random gist with no data.
Testing the alers