Skip to content

Instantly share code, notes, and snippets.

View cmaggiulli's full-sized avatar

Chris Maggiulli cmaggiulli

View GitHub Profile
@cmaggiulli
cmaggiulli / CalculateAverageRuntime
Last active September 20, 2022 00:11
A variety of Jenkins Groovy Script Console scripts for administering Jenkins
def job = Hudson.instance.getJob('job-name')
def cardinality = job.builds.size()
def summation = job.builds*.duration.sum()
print( ( ( summation/cardinality/1000 as double ) ).round(1) )
@cmaggiulli
cmaggiulli / README.md
Created September 16, 2022 08:07 — forked from MattFanto/README.md
Django appenddata

Alternative command to django loaddata when it is necessary to append fixture objects into an existing database. Instead of merging fixture data with your existing models (as it does loaddata) it appends all fixtures object by resetting all pk. M2M relations are managed at the end of the process, mapping the old primary keys with the new primary keys:

Example of test (appending data from Website2 into Website1):

# Website 1
python manage.py dumpdata app1 app2 ... > test_append_data_fixtures_pre.json

# Website 1
python manage.py dumpdata app1 app2 ... > fixture_to_import.json
/*****************************
Author: Christopher Maggiulli
Student ID: 000911211
Email: [email protected]
*****************************/
#include <stdio.h>
#include <ctype.h> /* use the function "tolower", "isupper" */
#include <string.h> /* use the function "strlen", "strcmp" */
@cmaggiulli
cmaggiulli / chase-paymentech-password-reset.sh
Last active August 17, 2022 19:05
A shell script to automated the creation of the XML and zip file as per the Chase Paymentech specification
#!/bin/bash
# Payment tech sftp password reset file.
# Script creates password and zip file based of PaymentTech specification
# Chase should be ashamed of themselves for this
# Author : Chris Maggiulli
FILENAME="password_`date +'%y%m%d'`000.xml"
ZIPNAME="password_`date +'%y%m%d'`000.zip"
# Not using /dev/random so this can be ran by less privileged users
@cmaggiulli
cmaggiulli / jenkins_export_last_successful_build_log.py
Last active August 19, 2022 02:20
Exports the last successful build log for all Jenkins project types
#!/usr/bin/env python3
import code
import os, sys
from re import sub
import argparse
from typing import Any, AnyStr, Dict
import constant
import validators
final static int RegDst = 0;
final static int ALUSrc = 1;
final static int MemtoReg = 2;
final static int RegWrite = 3;
final static int MemRead= 4;
final static int MemWrite = 5;
final static int Branch = 6;
final static int ALUOp1 = 7;
final static int ALUOp0 = 8;
#include <stdio.h>
#define SIZE 32
int a[SIZE];
int b[SIZE];
int sum[SIZE];
int mux(int a, int b)
{
@cmaggiulli
cmaggiulli / KillJenkinsScriptConsoleThreads.groovy
Created August 17, 2022 01:27
A short functional groovy script to kill Jenkins Script Console threads without raising ThreadDeath
// Kill Jenkins Script Console threads without raising ThreadDeath
Thread.getAllStackTraces().keySet().findAll{
it.id != Thread.currentThread().id && it.name ==~ /^Handling\sPOST\s\/jenkins\/script.*/
}.each { println it.stop() }
@cmaggiulli
cmaggiulli / git-patch.sh
Last active September 3, 2022 07:57
Move file across branches, clobber destination, without merge
#!/bin/bash
source_branch=DA-1819
destination_branch=release-3.2.0
relative_file_path=structures/serializers/node.py
git clone https://github.com/cmaggiulli/app.git -b $source_branch $source_branch
cd $source_branch
git checkout $destination_branch
git checkout --patch $source_branch $relative_file_path
@cmaggiulli
cmaggiulli / datadump.py
Last active September 16, 2022 10:38
Extending the django-admin datadump command
"""
Author: Chris Maggiulli
Rquirements:
1. Place in project/app/management/commands/datadump.py
2. Put this app first in INSTALLED_APPS
"""
from django.core.management.base import BaseCommand, CommandError
from django.apps import apps
from logging import getLogger
from django.contrib.contenttypes.fields import GenericForeignKey