Skip to content

Instantly share code, notes, and snippets.

View bruceoutdoors's full-sized avatar
🧗

Lee Zhen Yong bruceoutdoors

🧗
View GitHub Profile
@bruceoutdoors
bruceoutdoors / virt-static-ip.sh
Created May 6, 2026 12:10
Makes IP static for given virtual machine name in virt-manager
#!/bin/bash
# Check if VM name is provided
VM_NAME=$1
if [ -z "$VM_NAME" ]; then
echo "Makes IP static for given virtual machine name in virt-manager"
echo "Usage: $0 <vm_name>"
exit 1
fi

Keybase proof

I hereby claim:

  • I am bruceoutdoors on github.
  • I am bzlee (https://keybase.io/bzlee) on keybase.
  • I have a public key ASACgT3CJdqwlZjLsQ9mVk3lrUFa4SpNZSvD9FCKsxkj5go

To claim this, I am signing this object:

@bruceoutdoors
bruceoutdoors / matrix_calc.cpp
Created April 16, 2014 09:11
Simple C++ console matrix calculator. All it does is add and substract 3x3 matrices.
// simple matrix calculator
#include <iostream>
#include <cstdlib>
#include <limits>
// A 3x3 matrix
const int M_SIZE = 3;
typedef double matrix[M_SIZE][M_SIZE];
// function prototypes
@bruceoutdoors
bruceoutdoors / DbmigrateController.php
Last active May 25, 2024 11:41
Laravel 4 Convert existing MySQL database to migrations. This is a fork of Christopher Pitt's work http://laravelsnippets.com/snippets/convert-an-existing-mysql-database-to-migrations, which is based off michaeljcalkins's work at http://paste.laravel.com/1jdw#sthash.0nEgQzQR.dpuf. His original source code doesn't really work out of the box in my…
<?php
/* * **
*
* This script converts an existing MySQL database to migrations in Laravel 4.
*
* 1. Place this file inside app/controllers/
*
* 2. In this file, edit the index() method to customize this script to your needs.
* - inside $migrate->ignore(), you pass in an array of table
@bruceoutdoors
bruceoutdoors / gen-kaf-conf.sh
Last active May 24, 2024 08:52
Generate kaf (https://github.com/birdayz/kaf) configuration with AWS MSK clusters
#!/bin/bash
set -o errexit -o nounset -o pipefail
# Generate kaf (https://github.com/birdayz/kaf) configuration with AWS MSK clusters
# Usage:
# # Setup new config:
# AWS_PROFILE=dev ./gen-kaf-conf.sh > ~/.kaf/config && kaf config select-cluster
#
# # Append to existing config (tail command removes first line):
# AWS_PROFILE=dev ./gen-kaf-conf.sh | tail -n+2 >> ~/.kaf/config
@bruceoutdoors
bruceoutdoors / wg-addclient.sh
Last active December 30, 2023 10:25
Quick Wireguard VPN setup for AWS. Just run the CloudFormation stack, access the VM via SSM, and execute `wg-addclient` to add a client. See https://bruceoutdoors.wordpress.com/2023/02/01/how-to-build-a-wireguard-vpn/
#!/bin/bash
# Note: Must run as root!
cd /etc/wireguard/
# Get next available internal IP address
IP=$((`tac wg0.conf | grep -m1 -oP "[0-9]+(?=/32)" || echo 1` + 1))
# Generate client key
CLIENT_PRIVATE=`wg genkey`
@bruceoutdoors
bruceoutdoors / hill-cipher.sh
Last active June 2, 2022 21:33
Hill Cipher - use via "hill-decrypt.sh" and "hill-encrypt.sh"
#!/bin/bash
. matrix.sh
. mods.sh
. translator.sh
function hill_decrypt {
key=${1// /} # clear spaces from key
if [ ${#key} -lt 4 ];
then
@bruceoutdoors
bruceoutdoors / scikit-learn-tut.ipynb
Created May 8, 2021 13:56
Scikit-Learn Tutorial | Machine Learning With Scikit-Learn | Sklearn | Python Tutorial | Simplilearn (https://youtu.be/0Lt9w-BxKFQ)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bruceoutdoors
bruceoutdoors / find_target_combination.py
Last active March 10, 2020 15:06
infinitilab algo question
# python3
from collections import deque
# Store combinations as a tree. The size of the tree directly
# corresponds to the running time of the algorithm - O(2^n)
# Worst runtime is when the sum of items is larger than the target
# and no combination exist. An intuitive optimization here is to
# prune combinations away when the sum has already exceeded the target
class Node:
# Python3 port of http://algs4.cs.princeton.edu/code/edu/princeton/cs/algs4/UF.java.html
class DisjointSet:
"""
Execution: python disjoint_set.py < input.txt
Data files: http://algs4.cs.princeton.edu/15uf/tinyUF.txt
http://algs4.cs.princeton.edu/15uf/mediumUF.txt
http://algs4.cs.princeton.edu/15uf/largeUF.txt
Weighted quick-union by rank with path compression.