Skip to content

Instantly share code, notes, and snippets.

View cmaggiulli's full-sized avatar

Chris Maggiulli cmaggiulli

View GitHub Profile
@cmaggiulli
cmaggiulli / django_models_playground.py
Last active July 8, 2022 03:16
django auth model joining
from django.core.management.base import BaseCommand
from django.apps import apps
from persons.models import Person, Organization
import datetime
from django.utils import timezone
from django.contrib.contenttypes.models import ContentType
from django.contrib.auth.models import Permission
class Command(BaseCommand):
@cmaggiulli
cmaggiulli / keep-jenkins-plugins-uptodate-with-no-warnings.groovy
Last active April 3, 2022 05:35 — forked from alecharp/keep-jenkins-plugins-uptodate.groovy
Simple groovy script to upgrade active plugins when new versions are available ( without warnings )
jenkins.model.Jenkins.getInstance().getUpdateCenter().getSites().findAll{ !it.data.warnings }.each { site ->
site.updateDirectlyNow(hudson.model.DownloadService.signatureCheck)
}
hudson.model.DownloadService.Downloadable.all().each { downloadable ->
downloadable.updateNow();
}
def plugins = jenkins.model.Jenkins.instance.pluginManager.activePlugins.findAll {
it -> it.hasUpdate()
@cmaggiulli
cmaggiulli / main.tf
Created April 3, 2022 04:09
Provisioning Lambda Concurrency
esource "aws_cloudwatch_log_group" "entropy-engine-lambda" {
name = "/aws/lambda/${aws_lambda_function.entropy-engine-lambda.function_name}"
retention_in_days = local.log-retention
tags = {
branch = terraform.workspace
project = var.project
}
}
@cmaggiulli
cmaggiulli / pentaho.groovy
Last active March 17, 2022 19:24
Parse KTR
import groovy.io.FileType
import groovy.xml.*
def dirStr = "C:\\integration\\Pentaho\\Projects\\content\\public"
def dir = new File(dirStr)
def slurper = new XmlSlurper()
def connFileMap = [:]
File outputFile = new File("c:\\Users\\CMaggiul\\connections.csv")
@cmaggiulli
cmaggiulli / delete_profile.py
Created February 20, 2022 02:02
django-admin command to delete profiles by ID's passed in via CSV
from logging import getLogger
from django.core.management.base import BaseCommand
from persons.models import StudentProfile
import csv
logger = getLogger(__name__)
class Command(BaseCommand):
def add_arguments(self, parser):
@cmaggiulli
cmaggiulli / SortXMLAttrAlpha.groovy
Last active November 30, 2021 18:18
Sort XML attribute value alphabetically
def xmlStr = '''
<solutions>
<solution solutionName="XYZ.1052">
<settings/>
</solution>
<solution solutionName="XYZ.1012">
<settings/>
</solution>
<solution solutionName="XYZ.1053">
<settings/>
@cmaggiulli
cmaggiulli / ParallelNodeProvisionJenkinsfile
Last active September 3, 2022 10:49
This imperative Jenkinsfile will dynamically create nodes and commands that will be ran in parallel reference impl
/**
* @Author Chris Maggiulli
*
* This is an imperative ( scripted ) Jenkinsfile which will dynamically create nodes and run them in parallel. Modify the List of Hashmaps
* to include the name of the node and the command you wish to run.
*
**/
node('master') {
stage('orchestration') {
@cmaggiulli
cmaggiulli / BuildsBetweenWithBuildDescription.groovy
Last active November 4, 2021 19:40
Get All Builds with Build Description Jenkins Script Console
/**
* This script will print the job name and build number of all jobs in the last N days for all builds with a non null description.
* This script is useful for locating builds that have been earmarked with a build description.
* Example: Assume you have a build that runs every 2 minutes but 90% of the builds do not produce any artifacts. If you earmark the
* builds that produce artifacts by setting a build description you can then use this script to locate all the artifact-producting builds.
*
* Note: We are filtering on build description, which is different from a projects description
*
*/
@cmaggiulli
cmaggiulli / BuildsBetween.groovy
Last active February 26, 2022 18:47
Builds Between
/**
* @author Chris Maggiulli
* @description This script will print the job name and build number of all jobs in the last N days.
*/
final jenkins = Jenkins.instance
final lookBack = -1 // Number of days to look back
@cmaggiulli
cmaggiulli / ExecuteECRTask.sh
Last active November 4, 2021 20:32
AWS CLI command to execute an ECR Task
#!/bin/bash
aws ecs run-task --task-definition appdev-trimesters-81tri --launch-type FARGATE --cluster ecs-appdev-1 --network-configuration '{"awsvpcConfiguration": {"subnets": ["subnet-054bdb3dc221f2a1b","subnet-040d311d49d9e266a","subnet-07deyac98cc06bddb","subnet-0012634yu8b87f579"],"securityGroups": ["sg-04b11d010f5725n91","sg-09ac8f259bvf43b5"],"assignPublicIp": "DISABLED"}}'