Skip to content

Instantly share code, notes, and snippets.

@DALDEI
DALDEI / rpm-normalize-path.py
Created October 5, 2016 00:53
rpm utils - normalize an rpm path. Given an rpm file print its normalized path as name-version-release-arch.rpm
#! /usr/bin/python
# normalize an rpm path.
# Given an rpm file print its normalized path as name-version-release-arch.rpm
# Note: this reads the metadata from the rpm file itself to generate the path
import sys
import re
import rpmUtils.transaction
from rpmUtils.miscutils import splitFilename
from rpmUtils.miscutils import hdrFromPackage
from rpmUtils.miscutils import pkgTupleFromHeader
@DALDEI
DALDEI / rpm-parse-name.py
Created October 5, 2016 00:48
rpm utils - print how yum and rpmUtils parses an RPM filename as a 'NVREA'
#! /usr/bin/python
# Print the 'NEVRA' of an rpm file using its path only
# This is what yum tools does when given only an rpm filename
import sys
import re
from rpmUtils.miscutils import splitFilename
for path in sys.argv[1:]:
x = path[path.rfind( '/' )+1:]
# print "Path: {0} File: {1}".format(path,x)
@DALDEI
DALDEI / rpm-read-name.py
Last active October 5, 2016 00:50
rpm utils - extract the metadata from an rpm and print its 'nevra' and the path file name convention
#! /usr/bin/python
# Same as rpmname.sh but using rpmUtils python library
import sys
import re
import rpmUtils.transaction
from rpmUtils.miscutils import splitFilename
from rpmUtils.miscutils import hdrFromPackage
from rpmUtils.miscutils import pkgTupleFromHeader
ts = rpmUtils.transaction.initReadOnlyTransaction()
@DALDEI
DALDEI / build.gradle
Created August 22, 2016 00:43
s3 gradle repository with instance credentials
// from
// http://stackoverflow.com/questions/35852475/how-to-use-the-default-aws-credentials-chain-for-an-s3-backed-maven-repository-i
apply plugin: 'java'
apply plugin: 'maven-publish'
buildscript {
repositories {
mavenCentral()
}
dependencies {
@DALDEI
DALDEI / git-mv-with-history
Created May 16, 2016 15:20 — forked from emiller/git-mv-with-history
git utility to move/rename file or folder and retain history with it.
#!/bin/bash
#
# git-mv-with-history -- move/rename file or folder, with history.
#
# Moving a file in git doesn't track history, so the purpose of this
# utility is best explained from the kernel wiki:
#
# Git has a rename command git mv, but that is just for convenience.
# The effect is indistinguishable from removing the file and adding another
# with different name and the same content.
@DALDEI
DALDEI / README.md
Created December 30, 2015 18:52
Gradle Artifactory Publish - Conditionally skip publishing

Conditionally publishing with Artifactory in Gralde

The artifactory gradle plugin ( https://www.jfrog.com/confluence/display/RTF/Gradle+Artifactory+Plugin ) documents a property to skip publications.
artifactoryPublish.skip = true However this doesnt fully disable artifactory. It still publishes a "Build" with no artifacts. To conditionally skip a publication the following code block seems to work. This is useful, for example, if you want the same build to run in a CI server and standalone and/or if you want to run test or dev builds without publishing then rerun the same build with only a property change to have it publish - reguardless of if artifactoryPublish task is invoked.

@DALDEI
DALDEI / ml-rewriter-redirect.txt
Last active November 15, 2015 16:12
MarkLogic Declarative Rewriter - Simulate a Redirect using xdbc eval
Demonstrate invoking the internal /eval xdbc endpoint on a HTTP server in MarkLogic to create a Redirect.
Note that there are simplier and easier ways to accomplish this, e.g using the user defined error handler or
rewriting to a endpoint that calls xdmp:redirect-response(). This example shows that it can be done 'out of the box'
by utilizing the builtin support for XDBC handling.
On Port 8000 in the default installation, and on any new REST servers a block of the declarative rewriter dispatches
XDBC requests to the internal XCDBC endpoints directly.
The xdbc.xml attached file shows the relevent block of XML. The enableing factor is the use of <dispatch xdbc="true">.
A custom rewriter can rewrite any request to one of the builtin endpoints ( /eval, /invoke , /spawn , /insert ) and then dispatch to xdbc.
@DALDEI
DALDEI / variadic.cpp
Last active November 2, 2015 16:59
C++ Portable Varargs for "Variadic Macros" - Portable to GCC and MS Visual Studio
/*
* Vairiadic Macros used in this form are portable to MSVC and GCC
* https://gcc.gnu.org/onlinedocs/gcc/Variadic-Macros.html#Varia
* https://msdn.microsoft.com/en-us/library/ms177415(v=vs.100).aspx
*/
#include <stdio.h>
#if __GNUC__
#define __FUNCSIG__ __PRETTY_FUNCTION__
#endif
@DALDEI
DALDEI / cfvalidate
Last active October 29, 2015 14:59
AWS-CLI Cloud Formation Validation
#!/bin/sh
#############################################################################
## Usage: cfvalidate file.template [ file ...]
##############################################################################
## Convenience wrapper script for aws cli 'cloudformation validate-template'
## which requires a inline, file URL or S3 url for templates to validate
## This script takes simple, absolute or relative filenames and validate them
## using the AWS API
## https://aws.amazon.com/cli/
##
@DALDEI
DALDEI / bash-getopt-example.sh
Last active August 29, 2015 14:26 — forked from hercynium/bash-getopt-example.sh
declarative getopt in bash
#!/bin/bash
set -o errexit
set -o nounset
set -o pipefail
source /bath/to/bash-getopt
foo_dflt="wibble"
bash-getopt "$@" <<END_OPTS