Skip to content

Instantly share code, notes, and snippets.

@satiridev
satiridev / gist:e808d48248a119bba623adeabb108372
Created September 12, 2023 03:28
Example of send mail command in ubuntu
# mail -s "subject" to-address < ./bodyfile.txt
mail -s "test email" some-user@some-domain < ./testemail.txt
@satiridev
satiridev / check-connection-with-node.js
Last active November 17, 2022 07:42
check-connection-with-nodejs.js
/**
* this file can be used when the pod doesn't have curl or wget and also non root user.
* assumed the pod is linux with nodejs installed
*
* copy the content to memory of your pc/mac, and in the pod, do :
* echo "{the-content-of-the-file}" > /tmp/example.js
* node /tmp/example.js
*/
const https = require('https');
#!/bin/bash
# tested in .zshrc
#
# kubectl scale deploy name-of-deployment --replicas=0
# kubectl scale deploy name-of-deployment --replicas=1
alias kscale="kubectl scale deploy "
function krestart(){
for i in {0..1};
#!/bin/bash
# -F',' will split by comma
# BEGIN{RS="\r\n"} will remove \r\n (crlf) from the end of the string
# {print $3} will take the 3rd column and pass it to the next command
# -G option will read the data-urlencode
cat some.csv | awk -F',' 'BEGIN{RS="\r\n"}{print $3}' | while read x; do curl -v -G --data-urlencode "email=$x" \
-X POST "https://path/to/the/host" \
-H "accept: */*" \
-H "Authorization: Bearer some-jwt-string-for-authorization"; done
#!/bin/bash
# git
alias gp='git pull '
alias gpo='git push origin '
alias gs='git status '
alias gsl='git stash list '
alias gss='git stash save '
alias gcm='git commit -m '
alias ga='git add '
@satiridev
satiridev / delete-files-in-bucket.sh
Created November 6, 2020 03:26
delete list of files from AWS S3 bucket list result
#!/bin/bash
cat my-target-files-in-s3.txt | awk '{print $4}' | while read x; do aws s3 rm "s3://my-bucket-name/$x"; done > my-delete-result.txt
@satiridev
satiridev / collect-files-in-s3-bucket.sh
Last active November 6, 2020 03:27
Collect All Files in A AWS S3 Bucket
#!/bin/bash
# produce list of all files in buckets
echo "collecting..."
aws s3 ls --recursive my-bucket > my-files-in-bucket.txt
@satiridev
satiridev / createimage.py
Last active August 19, 2019 03:28
create written image using truetype font in python
# from https://code-maven.com/create-images-with-python-pil-pillow
from PIL import Image, ImageDraw, ImageFont
# mode L for grayscale
img = Image.new('RGB', (100, 30), color = (73, 109, 137))
# font path
fnt = ImageFont.truetype('/Library/Fonts/Arial.ttf', 15)
d = ImageDraw.Draw(img)
d.text((10,10), "Hello world", font=fnt, fill=(255, 255, 0))
# get system fonts
import matplotlib.font_manager
matplotlib.font_manager.findSystemFonts(fontpaths=None, fontext='ttf')
@satiridev
satiridev / cmd.sh
Created August 16, 2019 06:56 — forked from kelvinn/cmd.sh
Example of using Apache Bench (ab) to POST JSON to an API
# post_loc.txt contains the json you want to post
# -p means to POST it
# -H adds an Auth header (could be Basic or Token)
# -T sets the Content-Type
# -c is concurrent clients
# -n is the number of requests to run in the test
ab -p post_loc.txt -T application/json -H 'Authorization: Token abcd1234' -c 10 -n 2000 http://example.com/api/v1/locations/