Skip to content

Instantly share code, notes, and snippets.

@Susensio
Susensio / profiling_qcachegrind.sh
Last active Apr 15, 2021
Python profiling with QCacheGrind
View profiling_qcachegrind.sh
# Profile with cProfile python module and save to output
python -m cProfile -o output.cprof script.py
# Transform into tree format for QCacheGrind
pyprof2calltree -i output.cprof -o callgrind.cprof
# Open QCacheGrind and load callgrind.cprof file
@jlis
jlis / .gitlab-ci.yml
Created May 15, 2018
AWS ECS and ECR deployment via Docker and Gitlab CI
View .gitlab-ci.yml
image: docker:latest
variables:
REPOSITORY_URL: <AWS ACCOUNT ID>.dkr.ecr.eu-central-1.amazonaws.com/<ECS REPOSITORY NAME>
REGION: eu-central-1
TASK_DEFINTION_NAME: <TASK DEFINITION NAME>
CLUSTER_NAME: <CLUSTER NAME>
SERVICE_NAME: <SERVICE NAME>
services:
@chusiang
chusiang / teams-chat-post.sh
Last active May 5, 2021
Post a message to Microsoft Teams with bash script.
View teams-chat-post.sh
#!/bin/sh
# =============================================================================
# Author: Chu-Siang Lai / chusiang (at) drx.tw
# Filename: teams-chat-post.sh
# Modified: 2018-03-28 15:04
# Description: Post a message to Microsoft Teams.
# Reference:
#
# - https://gist.github.com/chusiang/895f6406fbf9285c58ad0a3ace13d025
#
@dschaaff
dschaaff / notifySlack.groovy
Created Feb 9, 2018
jenkins pipeline library for slack notifications with nice formatting
View notifySlack.groovy
#!/usr/bin/env groovy
/**
* notify slack and set message based on build status
*/
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import hudson.tasks.test.AbstractTestResultAction;
import hudson.model.Actionable;
@miguelmota
miguelmota / remove_tuxera.sh
Last active Apr 30, 2021
Completely uninstall and remove Tuxera NTFS on MacOS (resets trial version)
View remove_tuxera.sh
sudo rm -rf /Applications/Tuxera\ Disk\ Manager.app
sudo rm -rf /Library/Application\ Support/Tuxera\ NTFS
sudo rm -rf /Library/Filesystems/fusefs_txantfs.fs
@lesovsky
lesovsky / bgwr-ckpt-report.sql
Created Mar 27, 2017
Report query for PostgreSQL' bgwriter/checkpointer.
View bgwr-ckpt-report.sql
SELECT
now()-pg_postmaster_start_time() "Uptime", now()-stats_reset "Since stats reset",
round(100.0*checkpoints_req/total_checkpoints,1) "Forced checkpoint ratio (%)",
round(np.min_since_reset/total_checkpoints,2) "Minutes between checkpoints",
round(checkpoint_write_time::numeric/(total_checkpoints*1000),2) "Average write time per checkpoint (s)",
round(checkpoint_sync_time::numeric/(total_checkpoints*1000),2) "Average sync time per checkpoint (s)",
round(total_buffers/np.mp,1) "Total MB written",
round(buffers_checkpoint/(np.mp*total_checkpoints),2) "MB per checkpoint",
round(buffers_checkpoint/(np.mp*np.min_since_reset*60),2) "Checkpoint MBps",
round(buffers_clean/(np.mp*np.min_since_reset*60),2) "Bgwriter MBps",
@lukeplausin
lukeplausin / bash_aws_jq_cheatsheet.sh
Last active Apr 22, 2021
AWS, JQ and bash command cheat sheet. How to query, cut and munge things in JSON generally.
View bash_aws_jq_cheatsheet.sh
# Count total EBS based storage in AWS
aws ec2 describe-volumes | jq "[.Volumes[].Size] | add"
# Count total EBS storage with a tag filter
aws ec2 describe-volumes --filters "Name=tag:Name,Values=CloudEndure Volume qjenc" | jq "[.Volumes[].Size] | add"
# Describe instances concisely
aws ec2 describe-instances | jq '[.Reservations | .[] | .Instances | .[] | {InstanceId: .InstanceId, State: .State, SubnetId: .SubnetId, VpcId: .VpcId, Name: (.Tags[]|select(.Key=="Name")|.Value)}]'
# Wait until $instance_id is running and then immediately stop it again
aws ec2 wait instance-running --instance-id $instance_id && aws ec2 stop-instances --instance-id $instance_id
# Get 10th instance in the account
@pbabics
pbabics / gitlab-gc.sh
Created Nov 11, 2016
Manual garbage collector for gitlab registry, it removes old revisions that are not referenced by any tag
View gitlab-gc.sh
#!/bin/bash
BASE_PATH=/var/opt/gitlab/gitlab-rails/shared/registry/docker/registry/v2/repositories
DRY_RUN=0
KEEP_LAST_IMAGES=10
RUN_GARBAGE_COLLECTOR=0
GITLAB_CTL_COMMAND=`which gitlab-ctl`
@Eyjafjallajokull
Eyjafjallajokull / README.md
Last active May 8, 2021
AWS EBS - Find unused snapshots
View README.md

This script can help you find and remove unused AWS snapshots and volumes.

There is hardcoded list of regions that it searches, adjust the value to suit your needs.

Use snapshot.py snapshot-report to generate report.csv containing information about all snapshots.

snapshot.py snapshot-cleanup lets you interactively delete snapshot if it finds it is referencing unexisting resources.

./snapshots.py --help
@mrw34
mrw34 / gist:b12531d1a8df25f6c170
Last active Apr 27, 2021
Trello JSON to CSV conversion using jq
View gist:b12531d1a8df25f6c170
jq -r '["List", "Card"], ((reduce .lists[] as $list ({}; .[$list.id] = $list.name)) as $lists | .cards[] | select(.closed != true) | [$lists[.idList],.name]) | @csv' <nw3RUeLl.json