-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSNIPPETS
113 lines (76 loc) · 4.96 KB
/
SNIPPETS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# Mongo shell query to fetch specific element from an array in a document
db.organizations.aggregate([ { $match:{} }, { $project: { nameOfField: { $filter: { input: "$nameOfField", as:"tmp", cond: { $eq: [ "$$tmp.prop", "query" ] } } } } } ])
# Random 32 character string
cat /dev/urandom | LC_ALL=C tr -dc 'a-z0-9' | fold -w 32 | head -n 1
# Compress iOS scanned PDFs
gs -sDEVICE=pdfwrite -sPAPERSIZE=a4 -dPDFFitPage -dPDFSETTINGS=/ebook -o "$OUTPUT" -q "${INPUT[@]}"
# Split PDF
gs -sDEVICE=pdfwrite -dSAFER -dFirstPage=$FIRST -dLastPage=$LAST -o "$OUTPUT" -q $INPUT
# Merge PDFs
gs -sDEVICE=pdfwrite -o $OUTPUT -q "${INPUT[@]}"
# Pack files into ZIP
find . -type f -name '*.png' -exec zip output.zip {} +
# Resize image
convert $INPUT -resize $SIZE $OUTPUT
# Scale image
convert $INPUT -filter point -resize $SIZE $OUTPUT
# Generate blank image
convert -size $SIZE xc:white $INPUT
# Pack images to spritesheet
montage *.png -tile 4x -geometry +0+0 spritesheet.png
# Generate icon from image
convert $INPUT -define icon:auto-resize=64,48,32,16 $OUTPUT
# Pad image
convert $INPUT -background none -gravity center -resize $SIZE -extent $SIZE $OUTPUT
# Convert PDF to PNG
convert -density 300 $INPUT -resize 35% $OUTPUT
# Speed up GIF
convert -delay 1x30 output.gif fast.gif
# Convert 1024x1024 PNG to multiple sizes
convert icon.png -strip -interlace Plane -resize "1024x>" -write Icon-1024.png -resize "180x>" -write Icon-180.png -resize "167x>" -write Icon-167.png -resize "152x>" -write Icon-152.png -resize "120x>" -write Icon-120.png -resize "80x>" -write Icon-80.png -resize "76x>" -write Icon-76.png -resize "40x>" Icon-40.png
# Convert video to GIF
GIF_SETTINGS='fps=10,scale=860:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse' ffmpeg -i $INPUT_FILE.mov -vf $GIF_SETTINGS -loop 0 $INPUT_FILE.gif
# Cut video from to
ffmpeg -i $INPUT_FILE.mp4 -ss $FROM -to $TO -c copy $INPUT_FILE-cut.mp4
# Cut video by timeframe with subtitles
ffmpeg -i $INPUT -ss $FROM -to $TO -copyts -vf subtitles=$SUBTITLE -c:a copy $OUTPUT
# Extract subtitles from video
ffmpeg -i $INPUT -map 0:s:0 ex-sub.srt
# Convert GIF to mp4
ffmpeg -i $INPUT_FILE.gif -movflags faststart -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" $INPUT_FILE.mp4
# Crop video
ffmpeg -i $INPUT -filter:v "crop=${W}:${H}:${X}:${Y}" $OUTPUT
# List supported devices for recording
ffmpeg -f avfoundation -list_devices true -i ""
# Record whole screen
ffmpeg -f avfoundation -i "1" -framerate 30 "screen-recording-$(date +"%m-%d-%y").mkv"
# Create Kafka topic
kafka-topics.sh --create --topic <topic> --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1
# Export MongoDB collection by query
mongoexport --quiet --uri="mongodb://localhost:27017" --collection=<collection> -q '' | jq '.'
# Publish message to exchange using RabbitMQ API
curl -u test:rabbitmq 'http://localhost:15672/api/exchanges/%2F/<exchange>/publish' --data-raw '{"vhost":"/","name":"<exchange>","properties":{"delivery_mode":2,"headers":{"consistent-hash":""}},"routing_key":"100","delivery_mode":"2","payload":"{}","headers":{"consistent-hash":""},"props":{},"payload_encoding":"string"}'
# Download RabbitMQ CLI from local instance
curl -O http://localhost:15672/cli/rabbitmqadmin
# Run RabbitMQ DOCKER container
FROM rabbitmq:3.9.12-management\nRUN rabbitmq-plugins enable rabbitmq_consistent_hash_exchange rabbitmq_delayed_message_exchange
# Run nodemon with ts-node and debugging
nodemon --watch src --exec 'node --require ts-node/register --inspect' src/app.ts
# Scrape IMGs from HTML page using html-xml-utils.
curl -s $1 | hxwls | grep -E "(jpg|png)" | grep -v thumb | xargs -I{} curl -s -O {}
# Curl Kubernetes API Server from a Pod
curl -k -X GET -H "Authorization: Bearer $(cat /var/run/secrets/kubernetes.io/serviceaccount/token)" https://$KUBERNETES_PORT_443_TCP_ADDR:$KUBERNETES_SERVICE_PORT_HTTPS
# Push new tag to Github
git tag -a $TAG -m $TAG && git push origin refs/tags/$TAG
# Run Kafka UI in Kubernetes
kubectl run kafka-ui --image=provectuslabs/kafka-ui --env="KAFKA_CLUSTERS_0_NAME=local" --env="KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS=kafka:9092" --env="DYNAMIC_CONFIG_ENABLED=true" --restart=Never -- java -jar ./kafka-ui-api.jar
# Spreadsheets formula for calculating monthly expenses based on my Finances sheet
=ArrayFormula({ { unique(text(filter('2022'!F2:F,'2022'!F2:F<>""),"MMMM")) }, { sumif( text(filter('2022'!F2:F,'2022'!F2:F<>""),"MMMM"), unique(text(filter('2022'!F2:F,'2022'!F2:F<>""),"MMMM")), '2022'!B2:B) } })
# Reset Kafka topic offset to latest
kafka-consumer-groups.sh --bootstrap-server localhost:9092 --group <group> --topic <topic> --reset-offsets --to-latest
# Focus on single screen with displayplacer
displayplacer "id:69734272 enabled:false"
# Set environment variable with secret from pass (with error redirection)
export SECRET=$(pass show secret 2>/dev/null)
# Export PCK of Godot project
./Godot.app/Contents/MacOS/Godot --no-window --path ./godot-project --export-pack "EXPORT_TEMPLATE" "../relative/path/to/project/some.pck"