Skip to content

Instantly share code, notes, and snippets.

View gamunu's full-sized avatar

Gamunu Balagalla gamunu

  • Sri Lanka
View GitHub Profile
@gamunu
gamunu / docker.yaml
Last active December 31, 2022 05:21
GitHub packages build and push image pipeline.
# Create a directory path .github/workflows/
# put the docker.yaml in the workflows directory
# once the build is working, change `on:` to build on tags
# on:
# create:
# tags:
# - v*
# this will make sure the build will only trigger when a new git tag is created
name: Build and Publish Docker Image
@gamunu
gamunu / wsl-kernel-xt-recent.sh
Last active May 3, 2022 07:13
WSL kernel build instructions to include xt_recent module
docker run --name wsl-kernel-builder --rm -it ubuntu:latest bash
WSL_COMMIT_REF=linux-msft-wsl-5.10.16.3 # change this line to the version you want to build
# Install dependencies
apt update
apt install -y git build-essential flex bison libssl-dev libelf-dev bc
# Checkout WSL2 Kernel repo
mkdir src
@gamunu
gamunu / move-image-by-size.sh
Last active December 11, 2021 08:30
Move all files with low resolution to backup location
function mvImgBySize
{
minX=128
miny=96
xres=`identify -format "%[fx:w]" "$1"`
yres=`identify -format "%[fx:h]" "$1"`
if [ $xres -lt $minX ] || [ $yres -lt $minY ]
then
mv "$1" /path/to/backup/location/
fi
@gamunu
gamunu / pipewire-input-filter-chain.service
Last active December 11, 2021 08:31
Systemd service for PipeWire Input Filter Chain
[Unit]
Description=PipeWire Input Filter Chain
After=pipewire.service
BindsTo=pipewire.service
[Service]
ExecStart=/usr/bin/pipewire -c /home/<username>/.config/pipewire/input-filter-chain.conf
Type=simple
Restart=on-failure
@gamunu
gamunu / input-filter-chain.conf
Last active December 11, 2021 08:31
PipeWire filter chain config for rnnoise
# Noise canceling source
#
# start with pipewire -c filter-chain/input-filter-chain.conf
#
context.properties = {
log.level = 0
}
context.spa-libs = {
audio.convert.* = audioconvert/libspa-audioconvert
@gamunu
gamunu / firefox-quantum-telemetry
Last active September 26, 2023 13:56
Disabling Firefox Quantum telemetry
Disabling telemetry takes a little more work but can be accomplished in about five minutes. Type "about:config" in the address bar, and you will be notified that you could void your warranty (Firefox has a warranty?). Click on "I accept the risk." Type in "telemetry" in the search bar to see the results. Only some can be changed, and according to Mozilla, they are:
browser.newtabpage.activity-stream.feeds.telemetry
browser.newtabpage.activity-stream.telemetry
browser.ping-centre.telemetry
toolkit.telemetry.archive.enabled
toolkit.telemetry.bhrPing.enabled
toolkit.telemetry.enabled
toolkit.telemetry.firstShutdownPing.enabled
toolkit.telemetry.hybridContent.enabled
@gamunu
gamunu / vagrant-ubuntu-sudores
Created May 19, 2017 05:16
Using NFS shares from Vagrant without password prompts
# Allow Vagrant to manage /etc/exports
Cmnd_Alias VAGRANT_EXPORTS_ADD = /usr/bin/tee -a /etc/exports
Cmnd_Alias VAGRANT_NFSD_CHECK = /usr/bin/systemctl status --no-pager nfs-server.service
Cmnd_Alias VAGRANT_NFSD_START = /usr/bin/systemctl start nfs-server.service
Cmnd_Alias VAGRANT_NFSD_APPLY = /usr/sbin/exportfs -ar
Cmnd_Alias VAGRANT_EXPORTS_REMOVE = /bin/sed -r -e * d -ibak /*/exports
Cmnd_Alias VAGRANT_EXPORTS_REMOVE_2 = /bin/cp /*/exports /etc/exports
%vagrant ALL=(root) NOPASSWD: VAGRANT_EXPORTS_ADD, VAGRANT_NFSD_CHECK, VAGRANT_NFSD_START, VAGRANT_NFSD_APPLY, VAGRANT_EXPORTS_REMOVE, VAGRANT_EXPORTS_REMOVE_2
Afterwards add yourself to the vagrant group if you are not there already by running:

Reading data before application startup in Angular 2

In this demonstration I will show you how to read data in Angular2 final release before application startup. You can use it to read configuration files like you do in other languages like Java, Python, Ruby, Php.

This is how the demonstration will load data:

a) It will read an env file named 'env.json'. This file indicates what is the current working environment. Options are: 'production' and 'development';

b) It will read a config JSON file based on what is found in env file. If env is "production", the file is 'config.production.json'. If env is "development", the file is 'config.development.json'.

@gamunu
gamunu / gpg-import-and-export-instructions.md
Created February 20, 2017 15:20 — forked from chrisroos/gpg-import-and-export-instructions.md
Instructions for exporting/importing (backup/restore) GPG keys

Every so often I have to restore my gpg keys and I'm never sure how best to do it. So, I've spent some time playing around with the various ways to export/import (backup/restore) keys.

Method 1

Backup the public and secret keyrings and trust database

cp ~/.gnupg/pubring.gpg /path/to/backups/
cp ~/.gnupg/secring.gpg /path/to/backups/
cp ~/.gnupg/trustdb.gpg /path/to/backups/

or, instead of backing up trustdb...

@gamunu
gamunu / rpm-digital-signature.sh
Created February 20, 2017 15:16 — forked from fernandoaleman/rpm-digital-signature.sh
How to sign your custom RPM package with GPG key
# How to sign your custom RPM package with GPG key
# Step: 1
# Generate gpg key pair (public key and private key)
#
# You will be prompted with a series of questions about encryption.
# Simply select the default values presented. You will also be asked
# to create a Real Name, Email Address and Comment (comment optional).
#
# If you get the following response: