Skip to content

Instantly share code, notes, and snippets.

View kzap's full-sized avatar
🏠
Working from home

Andre Marcelo-Tanner kzap

🏠
Working from home
View GitHub Profile
@kzap
kzap / gist:5819745
Last active July 14, 2024 16:13
If you want to give only Travis-CI access to a private key or secret file in your repository, you will need to encrypt it, but rather than storing the entire encrypted file in an environment variable, just store the a secret password in a secure environment variable that you will use to encrypt and decrypt your private key file. The encryption o…
# generate your private key, put the public key on the server you will be connecting to
ssh-keygen -t rsa -f ./my_key
# generate the password/secret you will store encrypted in the .travis.yml and use to encrypt your private key
cat /dev/urandom | head -c 10000 | openssl sha1 > ./secret
# encrypt your private key using your secret password
openssl aes-256-cbc -pass "file:./secret" -in ./my_key -out ./my_key.enc -a
# download your Travis-CI public key via the API. eg: https://api.travis-ci.org/repos/travis-ci/travis-ci/key
@kzap
kzap / dashboard.json
Created April 29, 2020 08:04
Grafana K8s Resources CPU w/ Throttle Dashboard
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
@kzap
kzap / create-lvm.sh
Created June 26, 2015 02:28
LVM Script
echo RTFM >&2;
exit -1;
N=1
yum install -y lvm2
D=$(grep "unknown partition table" /var/log/messages | tail -n 1 | perl -pe 's/.*: ([^:]*): unknown.*/$1/g');
D=/dev/$D
pvcreate $D
vgcreate vg_$N $D
S=$(vgdisplay vg_$N | grep Total | perl -pe 's/[^0-9]+//g')
@kzap
kzap / module.tf
Last active August 8, 2019 21:31
Terraform: How to pass map to module
variable "region" {
default = "tr2"
description = "The region of openstack, for image/flavor/network lookups."
}
variable "image" {
default = {
tr2 = "eee08821-c95a-448f-9292-73908c794661"
tr2-1 = ""
RegionOne = "WRONG VALUE"
@kzap
kzap / terraform-app.sh
Created June 28, 2016 15:54
Wrapper for terraform that lets you specify an environment and calls an $ENV.tfvars file, uses a $ENV.tfstate file and sets the env variable
#!/bin/bash
#
# terraform-app
#
# This to terraform the servers for the Galleon App
# By storing the date now, we can calculate the duration of provisioning at the
# end of this script.
start_seconds="$(date +%s)"
@kzap
kzap / Dockerfile
Created April 22, 2019 13:37
PHP Apache Base Dockerfile
FROM php:7.1-apache
MAINTAINER Andre Marcelo-Tanner <andre@examine.com>
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install -y \
git \
wget \
lsb-release \
@kzap
kzap / circleci-trigger.sh
Last active October 23, 2018 04:15
CircleCI Force Run a Workflow via the API
#!/bin/bash
# FROM https://discuss.circleci.com/t/github-outage-on-21-october-2018/25903/8
PROVIDER=github # or bitbucket
ORG=my-project-org-or-user
PROJECT=my-project-name
if [ -z $CIRCLECI_TOKEN ]
then
echo "Create a token at https://circleci.com/account/api and export it as CIRCLECI_TOKEN."
exit 1
@kzap
kzap / .env
Created August 8, 2018 11:43
Connect to Xdebug running inside your PHP Container by building an image with Xdebug installed and running like this: `docker-compose -f docker-compose.xdebug.yml up`. Then the PHP inside your editor will connect to Xdebug running in your editor.
DOCKER_HOST_IP=IP.OF.YOUR.HOST.MACHINE.FROM.INSIDE.DOCKER
@kzap
kzap / .env
Created August 8, 2018 11:41
Connect to XDebug running inside your PHP Container by building an image with XDebug installed and running like this: ```shdocker-compose -f docker-compose.yml -f docker-compose.xdebug.yml up
DOCKER_HOST_IP=IP.OF.YOUR.HOST.MACHINE.FROM.INSIDE.DOCKER
@kzap
kzap / mysql-mha-logs-cleanup.sh
Created June 20, 2018 14:39
How to clean up logs when running MHA on a Master Replica MySQL Setup
# On Master Server purge binary logs up to latest log file
PURGE BINARY LOGS TO 'mysql-bin.010';
# On Slave Servers, clear relay logs
SET GLOBAL relay_log_purge=1;
FLUSH LOGS;
# wait for relay logs to get deleted
SET GLOBAL relay_log_purge=0;