Skip to content

Instantly share code, notes, and snippets.

View jweyrich's full-sized avatar
:octocat:
Making some lives easier and happier!

Jardel Weyrich jweyrich

:octocat:
Making some lives easier and happier!
View GitHub Profile
@jweyrich
jweyrich / aws-dotenv-update.py
Last active October 16, 2024 14:58
Update a dotenv file with AWS credentials directly from aws-vault
#!/usr/bin/env python3
#
# AUTHOR: Jardel Weyrich <jweyrich at gmail dot com>
#
import argparse
import os
import subprocess
DEFAULT_DOTENV_FILE = '.env.dev'
DEFAULT_PROFILE = 'default'
@jweyrich
jweyrich / humanize.ts
Last active February 13, 2021 20:36
Dummy humanize functions in TypeScript
interface TimeUnit {
[key: string]: number;
}
const TIME_UNITS: TimeUnit = {
"year": 3.154e+10,
"month": 2.628e+9,
"week": 6.048e+8,
"day": 8.64e+7,
"hour": 3.6e+6,
@jweyrich
jweyrich / pgsql_performance.sql
Created July 8, 2020 14:04
PostgreSQL performance troubleshooting
psql -h <host> -U <user> -W -d postgres
SELECT * from pg_stat_activity;
SELECT * from pg_stat_database;
# Queries running during >5 minutes
SELECT
pid,
datname,
query,
@jweyrich
jweyrich / key.h
Created July 2, 2020 14:13
AbstractKeyGenerator for sslpkix
#pragma once
//#include <cassert>
#include <iostream>
#include <openssl/evp.h>
#include <openssl/pem.h>
#include "sslpkix/iosink.h"
#include "sslpkix/common.h"
namespace sslpkix {
@jweyrich
jweyrich / wp_change_domain.sql
Created June 30, 2020 17:55
WordPress: Change/Update domain
UPDATE wp_options SET option_value = replace(option_value, 'https://OLDDOMAIN', 'https://NEWDOMAIN') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'https://OLDDOMAIN','https://NEWDOMAIN');
UPDATE wp_posts SET post_content = replace(post_content, 'https://OLDDOMAIN', 'https://NEWDOMAIN');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'https://OLDDOMAIN','https://NEWDOMAIN');
@jweyrich
jweyrich / mssql_query_stats.sql
Last active May 16, 2023 09:41
SQL Server query stats & average execution time
SELECT *
FROM sys.dm_exec_requests
CROSS APPLY sys.dm_exec_sql_text(sql_handle);
SELECT TOP 30
creation_time
, last_execution_time
, total_physical_reads
, total_logical_reads
@jweyrich
jweyrich / 10-nat-settings.conf
Last active February 1, 2020 19:11
Customer wants all traffic to go to a single IP and come from the same IP. Here are the steps to configure a custom NAT instance to translate outgoing traffic and forward incoming traffic to internal ALB
# Enable packet forwarding
net.ipv4.ip_forward = 1
# Disable ICMP redirects
net.ipv4.conf.eth0.send_redirects = 0
@jweyrich
jweyrich / aws-ec2-list-instances.sh
Last active August 28, 2021 05:19
List instances attributes using AWS CLI and JQ
#!/bin/bash
PROFILE=default
REGION=us-east-1
aws --profile=$PROFILE --region=$REGION --output=text ec2 describe-instances \
--query "Reservations[*].Instances[*].[InstanceType, State.Name, Platform, Tags[?Key=='Name']]"
aws --profile=$PROFILE --region=$REGION --output=json ec2 describe-instances \
| jq '.Reservations[].Instances[] | "\(.InstanceType); \(.State.Name); \(.Platform); \(.Tags[]//[]|select(.Key=="Name")|.Value)"'
@jweyrich
jweyrich / pev-multi-test.sh
Last active August 2, 2019 16:57
Simple script to run a pev binary on multiple samples and generate a single output file which is validated by a linter at the end
#!/bin/bash
SAMPLES_DIRECTORY="../pev/samples/"
OUTPUT_FILE="result.json"
PEV_TOOL_COMMAND="./src/build/readpe -f json"
# npm install jsonlint -g
LINTER_COMMAND="jsonlint"
counter=0
@jweyrich
jweyrich / buildspec.yml
Last active June 28, 2024 05:56
Sample of buildspec.yml for AWS CodeBuild that builds a Docker image from code and push it to ECR to be deployed via CodePipeline
# Change the following to your desired values:
# __ACCOUNT_NUMBER__
# __ECR_REGION__
# __ECR_REPOSITORY_NAME__
# __ECS_CONTAINER_NAME__
version: 0.2
phases:
install:
runtime-versions: