Skip to content

Instantly share code, notes, and snippets.

View pangkalizer's full-sized avatar

Allan Andal pangkalizer

  • Sydney, Australia
View GitHub Profile
@pangkalizer
pangkalizer / Terraform on Mac M1.md
Created September 26, 2023 01:59 — forked from straubt1/Terraform on Mac M1.md
Notes to install Terraform on M1

Installing the amd64 version of Terraform on Mac with M1

Not all Terraform providers are built for arm64.

One solution here is to install Terraform as amd64 which can be easily done from the downloads page.

However, for those who are using and switching between versions of Terraform often, a more streamlined approach is desirable.

Enter asdf.

alias deploydiff="git log production..master --pretty=format:'%<(25)%an %s' --abbrev-commit"
@pangkalizer
pangkalizer / sidekiq.rb
Created October 27, 2017 00:50 — forked from stevenharman/sidekiq.rb
The best solution I've found for reliably configuring Sidekiq's ActiveRecord connection pool size on Heroku.
# /config/initializers/sidekiq.rb
current_web_concurrency = Proc.new do
web_concurrency = ENV['WEB_CONCURRENCY']
web_concurrency ||= Puma.respond_to?
(:cli_config) && Puma.cli_config.options.fetch(:max_threads)
web_concurrency || 16
end
local_redis_url = Proc.new do
desc 'Generates jmeter test plan'
task :generate_jmeter_plan, [:url, :email, :password, :count] do |t, args|
require 'ruby-jmeter'
generate_report *extract_options_from(args)
end
def extract_options_from(args)
defaults = {
url: 'http://lvh.me:3000',
email: 'user@example.com',
@pangkalizer
pangkalizer / convert_all_tables_to_innodb.sql
Created May 19, 2016 07:22
convert MEMORY tables to InnoDB
DELIMITER $$
DROP DATABASE IF EXISTS `test` $$
CREATE DATABASE `test` $$
DROP PROCEDURE IF EXISTS `test`.`convert_all_tables_to_innodb` $$
CREATE PROCEDURE `test`.`convert_all_tables_to_innodb`()
BEGIN
DECLARE done INT DEFAULT FALSE;
DECLARE alter_sql VARCHAR(5000);
DECLARE cur1 CURSOR FOR
SELECT CONCAT('ALTER TABLE ', TABLE_SCHEMA, '.', TABLE_NAME, ' ENGINE=innodb, ALGORITHM=copy;') as alter_sql
@pangkalizer
pangkalizer / gist:86f158f0b13520854e920a4a5be669b1
Created May 19, 2016 06:41
MySQL to Aurora migration (minimal downtime)
MySQL Database to Aurora Migration
Preparation Check-list
Update the production Security Group so that Inbound accepts connection from same VPC group as source (requires for replication).
On the production server, set bin log retention hours, this is duration in hours before binary logs are automatically deleted. This also acts a window time to copy and migrate the production server into a Aurora replica. Currently the production server is set to NULL which means AWS delete the logs as soon as it doesn't need it any more.
CALL mysql.rds_set_configuration('binlog retention hours', 48);
Convert all tables using MEMORY engine to InnoDB, AWS converts all tables to InnoDB during migration, however keeping MEMORY engine tables on production causes issues on replication.
@pangkalizer
pangkalizer / update_image
Created March 8, 2016 01:25
update docker image with squash
#!/bin/bash
# Syntax: update_image <CONTAINER_NAME> <IMAGE_REPO>
CONTAINER_NAME="$1"
IMAGE_REPO="$2"
if [ "$CONTAINER_NAME" = "" ]; then
echo "Error: Missing container name"; exit 1;
fi
@pangkalizer
pangkalizer / KernelAwareTest.php
Last active August 29, 2015 14:27 — forked from jakzal/KernelAwareTest.php
KernelAwareTest
<?php
require_once dirname(__DIR__).'/../../../../app/AppKernel.php';
/**
* Test case class helpful with Entity tests requiring the database interaction.
* For regular entity tests it's better to extend standard \PHPUnit_Framework_TestCase instead.
*/
abstract class KernelAwareTest extends \PHPUnit_Framework_TestCase
{
upstream supatest {
server 192.168.35.110:80;
}
upstream jenkins {
server 192.168.35.110:8001;
}
upstream selenium_hub {
server 192.168.35.110:4444;
@pangkalizer
pangkalizer / docker_cheats
Last active June 28, 2017 10:01
docker cheats
Online liner commit running container, then squashed image
docker save $(docker commit supatest supatest) | docker-squash -t supatest -verbose | docker load
One liner to stop / remove all of Docker containers:
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
Remove all non-running container
sudo docker ps -a | grep 'Exited' | awk '{print $1}' | xargs --no-run-if-empty sudo docker rm