Skip to content

Instantly share code, notes, and snippets.

@shivanshs9
shivanshs9 / rename-database.sql
Created April 16, 2020 11:15
Rename MySQL Database
DROP PROCEDURE IF EXISTS moveTables;
DROP PROCEDURE IF EXISTS renameDatabase;
DELIMITER $$
CREATE PROCEDURE moveTables(_schemaName varchar(100), _newSchemaName varchar(100))
BEGIN
DECLARE done INT DEFAULT FALSE;
DECLARE table_name VARCHAR(64);
DECLARE table_cursor CURSOR FOR SELECT information_schema.tables.table_name FROM information_schema.tables
WHERE information_schema.tables.table_schema = _schemaName;
@hashbrowncipher
hashbrowncipher / coredump_uploader.sh
Created November 11, 2019 03:38
Example coredump uploader
#!/bin/bash
# Depends on zstd (>1.3.6) and aws-cli
set -o errexit
set -o nounset
set -o pipefail
# Set kernel.core_pattern = | coredump_uploader.sh %P %s %E
PID=$1
shift
SIGNAL=$1
@sakethramanujam
sakethramanujam / simple_bash_dag.py
Last active January 6, 2022 16:09
Sample Dag with Bash Operator.
#!/usr/bin/python3
from airflow.models import DAG
from airflow.operators.bash_operator import BashOperator
from datetime import datetime, timedelta
# let's setup arguments for our dag
my_dag_id = "my_first_dag"
default_args = {
@apolloclark
apolloclark / devsecops_maturity_model.md
Last active January 22, 2024 05:08
DevSecOps Maturity Model

DevSecOps Maturity Model

DevSecOps has finally become popular within the wider IT industry in 2019. I started as a web developer in 2001, learned about testing automation, system deployment automation, and "infrastructure as code" in 2012, when DevOps was becoming a popular term. DevOps became common after the release of The Phoenix Project in Jan 2013. It has taken 7+ years for security to become integrated within the DevOps methodology. The following is a list of concepts I go through with project owners, project managers, operations, developers, and security teams, to help establish how mature their DevOps and security automation is, and to help them increase that maturity over time. This model is based on experience consulting with a variety of US Financial, Healthcare, and Department of Defense, organizations, and combines:

git checkout -b upstream
git remote add upstream git@github.com/upstream1/blah.git
git fetch upstream # or use -f in git remote add
git merge -s subtree upstream/master --allow-unrelated-histories -X theirs
FROM wordpress
# Set environment variables used by the Wordpress image
# DB_USER and DB_PASSWORD are included as an example. However,
# these should be removed and set during docker run.
ENV WORDPRESS_DB_HOST=127.0.0.1 \
WORDPRESS_DB_USER=wpuser \
WORDPRESS_DB_PASSWORD=super-secret-password \
WORDPRESS_DB_NAME=wpsite \
WORDPRESS_TABLE_PREFIX=wp_
@psa-jforestier
psa-jforestier / lambda_function.py
Created February 5, 2019 10:13
AWS Lambda function to gzip compress file when upload to S3 (will replace original file with gz version)
###
### This gist contains 2 files : settings.json and lambda_function.py
###
### settings.json
{
"extensions" : ["*.hdr", "*.glb", "*.wasm"]
}
### lambda_function.py
@mlabouardy
mlabouardy / Jenkinsfile
Created November 4, 2018 12:54
CI/CD for Serverless apps with Jenkins
def bucket = 'deployment-packages-mlabouardy'
def functionName = 'Fibonacci'
def region = 'eu-west-3'
node('slaves'){
stage('Checkout'){
checkout scm
}
stage('Test'){
@mlabouardy
mlabouardy / setup.sh
Created November 4, 2018 09:45
provision jenkins instance
#!/bin/bash
echo "Install Jenkins stable release"
yum remove -y java
yum install -y java-1.8.0-openjdk
wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo
rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key
yum install -y jenkins
chkconfig jenkins on
@mlabouardy
mlabouardy / join-cluster.sh
Created November 3, 2018 17:03
Jenkins cluster discovery
#!/bin/bash
JENKINS_URL="${jenkins_url}"
JENKINS_USERNAME="${jenkins_username}"
JENKINS_PASSWORD="${jenkins_password}"
TOKEN=$(curl -u $JENKINS_USERNAME:$JENKINS_PASSWORD ''$JENKINS_URL'/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)')
INSTANCE_NAME=$(curl -s 169.254.169.254/latest/meta-data/local-hostname)
INSTANCE_IP=$(curl -s 169.254.169.254/latest/meta-data/local-ipv4)
JENKINS_CREDENTIALS_ID="${jenkins_credentials_id}"