Skip to content

Instantly share code, notes, and snippets.

View raykao's full-sized avatar
🇨🇦
¯\_(ツ)_/¯

Raymond Kao raykao

🇨🇦
¯\_(ツ)_/¯
View GitHub Profile
trigger:
- master
variables:
- group: akv-credentials
pool:
vmImage: 'ubuntu-latest'
steps:
module "subnet" {
source = "./subnet_module.tf"
}
resource "azurerm_virtual_machine" "some_name" {
...
depends_on = module.subnet
subnet_id = module.subnet.id
}
@raykao
raykao / batcherize.js
Created August 20, 2019 02:06
Turn an array into an array of arrays...to batch process some data.
function batcherize(batchSize, unbatchedData) {
const batchedData = [];
const batchNumber = Math.ceil(unbatchedData.length/batchSize)
for (let batchIndex = 0; batchIndex < batchNumber; batchIndex++) {
const currentBatchPosition = (batchIndex * batchSize);
const currentBatchOffset = currentBatchPosition + (batchSize);
const currentBatchData = unbatchedData.slice(currentBatchPosition, currentBatchOffset);
batchedData.push(currentBatchData);

Keybase proof

I hereby claim:

  • I am raykao on github.
  • I am raykao (https://keybase.io/raykao) on keybase.
  • I have a public key ASB1OgQWgG4JUJOHAv70PW8fEe3X6JWJkrpd1146kA4TpAo

To claim this, I am signing this object:

@raykao
raykao / sublime as default editor for ubuntu.md
Last active April 28, 2018 13:07
How to add sublime as the default editor on Ubuntu
sudo mv Sublime\ Text\ 2 /opt/
sudo ln -s /opt/Sublime\ Text\ 2/sublime_text /usr/bin/sublime
sudo sublime /usr/share/applications/sublime.desktop

Copy/Paste to file

[Desktop Entry]
Version=1.0
apiVersion: v1
kind: Service
metadata:
name: bobble
labels:
name: bobble
spec:
type: LoadBalancer
ports:
- name: http
@raykao
raykao / azuregfs.sh
Last active February 20, 2018 21:28
#!/bin/bash
# This script is only tested on CentOS 6.5
# You can customize variables such as MOUNTPOINT, RAIDCHUNKSIZE and so on to your needs.
# You can also customize it to work with other Linux flavours and versions.
# If you customize it, copy it to either Azure blob storage or Github so that Azure
# custom script Linux VM extension can access it, and specify its location in the
# parameters of powershell script or runbook or Azure Resource Manager CRP template.
NODENAME=$(hostname)
{
"$schema": "https://schema.management.azure.com/schemas/2016-09-01/deploymentTemplate.json",
"contentVersion": "1.0.0.0",
"parameters": {
"deploymentPrefix": {
"type": "string"
},
"indexCount": {
"type": "int"
},
{
"$schema": "http://schema.management.azure.com/schemas/2016-09-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"deploymentPrefix": {
"type": "string",
"metadata": {
"description": "Deployment Prefix name. Added to the beginning of each resource."
}
},
@raykao
raykao / first-node.sh
Created February 10, 2017 19:58
Downloads the galera.cnf config file to the MariaDB config.d path, then replaces values with the current machine's info.
#!/usr/bin/env bash
sudo -i
cd /etc/mysql/conf.d
wget https://gist.githubusercontent.com/raykao/027e42847392a0eafb6c7b51c3291191/raw/a328e20eb13e2e129101dea460e1bd592d7f1c3b/galera.cnf
sed -i "s/first_ip/$(ip -4 addr ls eth0 | awk '/inet / {print $2}' | cut -d"/" -f1)/g" galera.cnf