Skip to content

Instantly share code, notes, and snippets.

View fvztdk's full-sized avatar

Felipe Vaz fvztdk

  • Barcelona, Spain
View GitHub Profile
@fvztdk
fvztdk / main.py
Created May 13, 2022 10:41
Read from GCP Pub/Sub and publish to Google Chat webhook (used to send alerts)
import os
from json import dumps
from httplib2 import Http
import base64
def main(event, context):
url = os.environ['WEBHOOK_URL']
bot_message = {
'text' : base64.b64decode(event['data']).decode('utf-8')}
message_headers = {'Content-Type': 'application/json; charset=UTF-8'}
http_obj = Http()
@fvztdk
fvztdk / find_big_files.sh
Created June 4, 2019 15:08
Find the 50 biggest files over 100mb on linux, sort by size
#run as root
find / -xdev -type f -size +100M -exec du -sh {} ';' | sort -rh | head -n50
@fvztdk
fvztdk / remove_crlf.sh
Created January 30, 2019 11:18
Remove CRLF line ending
sed -i 's/\r$//' filename
@fvztdk
fvztdk / dynamic_nginx_brotli.sh
Created December 28, 2018 09:31
Build and install google brotli nginx as a dynamic module (ubuntu xenial)
#install brotli
sudo apt-get install brotli
#check nginx version
nginx -V
#download nginx source
wget http://nginx.org/download/nginx-1.14.1.tar.gz
#extract the source
tar -xzvf nginx-1.14.1.tar.gz
@fvztdk
fvztdk / query.txt
Created October 25, 2018 15:31
get traces of request with 500 error (Azure Log Analytics)
let start=datetime("2018-10-25T06:00:00.000Z");
let end=datetime("2018-10-25T14:00:00.000Z");
requests | where timestamp > start and timestamp < end
| where success == false and resultCode == "500"
| where url contains "your_service_path"
|join (traces
| where message contains "REQUEST: {"
) on $left.id == $right.operation_Id
@fvztdk
fvztdk / script.sql
Created June 11, 2018 13:02
Size of tables on SQL Server
SELECT
t.NAME AS TableName,
s.Name AS SchemaName,
p.rows AS RowCounts,
SUM(a.total_pages) * 8 AS TotalSpaceKB,
CAST(ROUND(((SUM(a.total_pages) * 8) / 1024.00), 2) AS NUMERIC(36, 2)) AS TotalSpaceMB,
SUM(a.used_pages) * 8 AS UsedSpaceKB,
CAST(ROUND(((SUM(a.used_pages) * 8) / 1024.00), 2) AS NUMERIC(36, 2)) AS UsedSpaceMB,
(SUM(a.total_pages) - SUM(a.used_pages)) * 8 AS UnusedSpaceKB,
CAST(ROUND(((SUM(a.total_pages) - SUM(a.used_pages)) * 8) / 1024.00, 2) AS NUMERIC(36, 2)) AS UnusedSpaceMB
@fvztdk
fvztdk / list-packages.sh
Created January 10, 2018 10:41
Generate apt-get package list with version
aptitude -F "%c %p %V" --disable-columns search '!~M ~i' | awk -F " " '{ print "apt-get -y install " $2"="$3 }' > aptshell.sh
@fvztdk
fvztdk / permission_octal.sh
Created November 27, 2017 10:20
Show permisions of file in chmod style (octal)
stat -c '%a' file.tx
@fvztdk
fvztdk / clear_old_docker_images.sh
Created October 4, 2017 12:32
Clear older than X weeks docker images
#!/bin/bash
#use this to remove older docker images left on CI machine, max_week_size represent the number of weeks that should be kept
max_week_size=4
docker images | awk 'NR>1 {print $0}' | while read line; do
# echo $line
id_img=$(echo $line | awk '{print $3}')
# if older then a month
is_month=$(echo $line | grep 'month')
if [ ! -z "$is_month" ]; then
@fvztdk
fvztdk / boxstarter.txt
Last active September 17, 2017 11:13
Boxstarter
#The command to run, built from the raw link of this gist
#START http://boxstarter.org/package/nr/url?https://gist.githubusercontent.com/fvztdk/088d0fda0962fcf25d3059bfd6624c5b/raw/d202d5366271c60fe29139df7bf77097e75fa010/boxstarter.txt
#Special windowsy stuff. see http://boxstarter.org/WinConfig
Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowProtectedOSFiles -EnableShowFileExtension
Disable-BingSearch
Update-ExecutionPolicy
#utilities
cinst jdk8