Skip to content

Instantly share code, notes, and snippets.

@imayobrown
imayobrown / InitialePrototype Examination
Created April 9, 2015 15:39
Javascript prototype and object examination
//Here we define Person object by creating a constructor for it. We could also do this by doing new Object() then dynamically
//adding attributes and functions to it.
var Person = function(name, age){
this.name = name;
this.age = age;
this.getAge = function(){
return this.age;
};
this.toString = function(){return "Person";};
};
@imayobrown
imayobrown / migrate_jenkins_job.py
Last active January 26, 2023 20:44
Python script to migrate jenkins job from one sever to another via config.xml file
# Script to migrate jenkins job from one server to another via cli
# Make sure python-jenkins is installed in order to use script
import argparse
import jenkins
def get_parser():
parser = argparse.ArgumentParser()
parser.add_argument('-j', '--job_name', type=str, required=True, help='Name of job that is to be migrated')
parser.add_argument('-o', '--original_server', type=str, required=True, help='Server to migrate from')
@imayobrown
imayobrown / TestThing.groovy
Last active August 15, 2018 22:46
Testing format example (no subfunctions)
#!groovy
package tests
import support.PipelineSpockTestBase
class TestThing extends PipelineSpockTestBase {
def scriptPath = 'vars/thing.groovy'
@imayobrown
imayobrown / isolate_instance
Last active June 19, 2019 18:16
Isolate a machine from 2 others
#!/bin/bash
INSTANCE_TO_ISOLATE=$1
INSTANCE_TO_ISOLATE_FROM_1=$2
INSTANCE_TO_ISOLATE_FROM_2=$3
PEM_PATH=$4
ssh -i $PEM_PATH -t centos@$INSTANCE_TO_ISOLATE "sudo iptables -I INPUT -s $INSTANCE_TO_ISOLATE_FROM_1 -j DROP && sudo iptables -I INPUT -s $INSTANCE_TO_ISOLATE_FROM_2 -j DROP"
ssh -i $PEM_PATH -t centos@$INSTANCE_TO_ISOLATE "sudo iptables -I OUTPUT -d $INSTANCE_TO_ISOLATE_FROM_1 -j DROP && sudo iptables -I OUTPUT -d $INSTANCE_TO_ISOLATE_FROM_2 -j DROP"
@imayobrown
imayobrown / restore_instance
Last active June 12, 2019 16:27
Restore instances that have been isolated
#!/bin/bash
INSTANCE_TO_RESTORE=$1
PEM_PATH=$2
ssh -i $PEM_PATH -t centos@$INSTANCE_TO_RESTORE "sudo iptables -D OUTPUT 1 && sudo iptables -D OUTPUT 1"
ssh -i $PEM_PATH -t centos@$INSTANCE_TO_RESTORE "sudo iptables -D INPUT 1 && sudo iptables -D INPUT 1"