Skip to content

Instantly share code, notes, and snippets.

View thushan's full-sized avatar

Thushan Fernando thushan

View GitHub Profile
@thushan
thushan / migrate-disco.sh
Last active August 13, 2025 07:03
Index number of files in a directory
#!/usr/bin/env bash
# License: Apache-2.0
# Author: Thushan Fernando <[email protected]>
# http://github.com/thushan/migration-tools/
#
# Usage: ./migrate-disco.sh /path/to/directory [max_jobs] [max_depth] [strategy]
# Examples:
# ./migrate-disco.sh /mnt/efs
# ./migrate-disco.sh /mnt/efs 16 3 auto
@thushan
thushan / sql-server-errors-to-markdown.sh
Created May 15, 2025 00:36
SQL Server Errors to Markdown Table
#!/usr/bin/env bash
# License: MIT
# Author: Thushan Fernando <[email protected]>
# http://github.com/thushan/
#
# USAGE:
# ./sql-server-errors-to-markdown.sh errors.txt
set -euo pipefail
@thushan
thushan / ConvertAzureAppSettingsToLocalSettings
Last active June 27, 2024 04:46
Azure App Settings to local.settings.json converter
<#
Azure App Settings / Environment Variables to local.settings.json Converter
| v1.0.1 |-----------------------------------------------------------------
This script will take an Azure App Settings JSON file and convert it to a
local.settings.json file for use with Azure Functions.
It also moves some of the Azure specific settings to the top of the file.
@thushan
thushan / riscv-pid-controller.riscv
Created December 18, 2023 10:45
PID Controller for riscv for use in our balance bot
# init
.setpoint .word 100 # Setpoint value
.current .word 0 # Current value
.error .word 0 # Error
.integrel .word 0 # integrel term
.derivative .word 0 # Derivative term
.prev_error .word 0 # Previous error
# PID Constants
.Kp .word 0.5 # Proportional gain
@thushan
thushan / _waveshare-ico-10dof-imu-for-raspberrypi-pico.md
Last active January 18, 2024 23:26
WaveShare PICO 10DOF IMU for RaspberryPi Pico CircuitPython Example
@thushan
thushan / home-assistant-m5stack-atomlite-env-ii.yaml
Last active January 31, 2022 21:39
ESPHome configuration for M5Stack's AtomLite + ENV-II *SHT30 / BMP280* Sensor
substitutions:
device_name: atomlite-outdoor-sensor
friendly_name: "Outdoor Sensor"
device_description: "Detects ambient temperature and pressure."
esphome:
name: ${device_name}
comment: ${device_description}
esp32:
@thushan
thushan / windows-terminal-settings.json
Last active February 27, 2022 14:02
My Windows Terminal Settings profile with elevated prompt for PowerShell via gsudo.
// latest version is now here:
// https://github.com/thushan/dotfiles/blob/main/windows/windows-terminal/settings.json
@thushan
thushan / elevate-batch-example.bat
Created July 2, 2018 07:38
Auto-Elevate Batch Script
REM Credit: https://stackoverflow.com/a/25756858
REM Save current directory which lets us come back to our working directory
pushd %~dp0
net file 1>nul 2>nul && goto :run || powershell -ex unrestricted -Command "Start-Process -Verb RunAs -FilePath '%comspec%' -ArgumentList '/c %~fnx0 %*'"
goto :eof
:run
REM Run any elevated tasks here

Keybase proof

I hereby claim:

  • I am thushan on github.
  • I am thushanfernando (https://keybase.io/thushanfernando) on keybase.
  • I have a public key whose fingerprint is ABA1 8310 D88F F570 F873 657F 1E33 92B8 9BA2 CB78

To claim this, I am signing this object:

@thushan
thushan / import-gnaf-sqlserver.sql
Created March 8, 2016 00:53
Import G-NAF to SQL Server Instance
use [G-NAF]
-- Clean existing
delete FROM dbo.ADDRESS_ALIAS
TRUNCATE TABLE dbo.ADDRESS_ALIAS
SELECT COUNT(*) FROM dbo.ADDRESS_ALIAS
GO
BULK
INSERT dbo.ADDRESS_ALIAS
FROM 'D:\G-NAF\FEB16_GNAF_PipeSeparatedValue_20160222170142\G-NAF\G-NAF FEBRUARY 2016\Standard\ACT_ADDRESS_ALIAS_psv.psv'
WITH