Skip to content

Instantly share code, notes, and snippets.

@iamazeem
iamazeem / check-repos-in-org.sh
Created December 22, 2023 07:22
Bash script to list repos with deprecated NodeJS 12 using annotations with GitHub CLI
#!/bin/bash
set -e
ORG=""
REPOS="$(gh repo list "$ORG" --json name --jq '.[] | join("")')"
NODEJS12_DEPRECATION_MSG="Node.js 12 actions are deprecated."
for REPO in $REPOS; do
echo -n "$ORG/$REPO "
@iamazeem
iamazeem / get-local-listening-ports-as-csv.ps1
Last active July 31, 2023 14:55
Get local listening ports as CSV on Windows
((Get-NetTCPConnection -State Listen | Select-Object -Property LocalPort | ConvertTo-csv -NoTypeInformation | Select-Object -skip 1) -join ",") -replace '"'
# List IPv4 listening local ports
(Get-NetTCPConnection -State Listen | Where-Object -Property LocalAddress -NotContains '::' | Select-Object -Property LocalPort | ConvertTo-csv -NoTypeInformation | Select-Object -skip 1 -Unique) -replace '"'
@iamazeem
iamazeem / install-cppcheck.bash
Created June 26, 2023 13:16
CppCheck 2.11 on Ubuntu 18.04 (build from source)
#!/bin/bash
# uninstall existing cppcheck
sudo apt purge cppcheck -y
# download, build and install
cd ~/Downloads
wget https://github.com/danmar/cppcheck/archive/refs/tags/2.11.tar.gz
tar -xvf 2.11.tar.gz
cd cppcheck-2.11
@iamazeem
iamazeem / s3-zstd-compressor.rb
Created May 27, 2023 07:26
fluentd S3 zstd compressor
require 'zstd'
module Fluent::Plugin
class S3Output
class LZMA2Compressor < Compressor
S3Output.register_compressor('zstd', self)
def initialize(options = {})
begin
require 'zstd'
@iamazeem
iamazeem / gh-close-prs.bash
Created May 26, 2023 11:38
GitHub - close PRs with no linked issues (Bash script)
#!/bin/bash
set -e
owner="" # owner name here
repo="" # repo name here
prs=$(gh pr list --repo "$owner/$repo" --json number --jq '.[] | join("")')
for pr in $prs; do
@iamazeem
iamazeem / vcpkg_sqlite3_setup_and_install.txt
Last active March 11, 2024 20:44
SQLite3: set up and install with vcpkg
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg search sqlite3
./vcpkg install sqlite3[tool]
# headers, static library, and command-line tool
$ tree installed/x64-linux/{include,lib,tools}
@iamazeem
iamazeem / gh-push-docker-image.sh
Last active June 19, 2022 04:17
Bash script to push docker image to GitHub Container Registry
#!/bin/bash
set -e
if [[ -z $GITHUB_ACTOR || -z $GITHUB_TOKEN || -z $GITHUB_REPOSITORY ]]; then
echo "[ERR] Run $0 under GitHub Actions context!"
exit 1
fi
IMAGE_NAME=${1:-''}
@iamazeem
iamazeem / timestamp.cpp
Created June 13, 2022 06:22
C++ timestamp [15 characters]
#include <iostream>
#include <iomanip>
#include <sstream>
#include <chrono>
#include <ctime>
std::string get_timestamp() noexcept
{
const auto now = std::chrono::system_clock::now();
const auto time = std::chrono::system_clock::to_time_t(now);
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>fp_Ben-Doherty</title>
</head>
<body>
<style type="text/css">
@page{size: 319.83594508009156mm 235.36mm;}
body {
@iamazeem
iamazeem / log.proto
Created June 9, 2020 14:41
ProtoBuf Schema and Ruby Script for Generating Messages Samples (Binary and JSON)
syntax = "proto3";
package service.logging;
import "google/protobuf/timestamp.proto";
message Log {
message Context {
google.protobuf.Timestamp timestamp = 1;
string host_or_ip = 2;