Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / qt_run_notepad.cpp
Created December 16, 2016 07:10
Qt QProcess - Example using Lambda - Run Notepad on Windows
// ----------------------------------------------
// Open Notepad on Windows using QProcess
// Asynchronously using std::async and
// Wait for it to exit with std::future
// ----------------------------------------------
#include <QProcess> // QProcess
#include <QDebug> // qDebug(), qCritical(), ...
#include <future>
@iamazeem
iamazeem / rapidjson_file_read_write_test.cpp
Last active September 4, 2023 14:21
RapidJSON - File Read/Write Test
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <rapidjson/document.h>
#include <rapidjson/istreamwrapper.h>
#include <rapidjson/writer.h>
#include <rapidjson/stringbuffer.h>
#include <rapidjson/ostreamwrapper.h>
int main()
@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 / qt_directory_watcher.cpp
Last active January 9, 2023 17:04
Qt QFileSystemWatcher Example - Watch a directory and do some processing if it is changed with QEventLoop
// ----------------------------------------------
// List the contents of a directory if changed
// Using QFileSystemWatcher, QDirIterator and
// QEventLoop, and lambda function for connect
// ----------------------------------------------
#include <QObject>
#include <QEventLoop>
#include <QDebug>
#include <QFileSystemWatcher>
@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:-''}