Skip to content

Instantly share code, notes, and snippets.

@martiell
martiell / plugins.py
Created November 19, 2018 17:07
Find transitive dependencies of a set of Jenkins plugins using update centre metadata
#!/usr/bin/env python3
# Finds the transitive closure of dependencies for a set of jenkins plugins.
# The jenkins puppet module does not resolve transitive dependencies, so all
# the transitive dependencies need to be listed in the yaml of plugins to
# install.
#
# This script reads JSON from the update centre for the relevant version of
# Jenkins. For Jenkins 2.60, run the following before this script:
# curl -sLO http://updates.jenkins-ci.org/2.60/update-center.actual.json
#
@martiell
martiell / Configuration.java
Created August 24, 2015 20:01
Jackson serialization/deserialization of dot-separated property keys
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import java.io.IOException;
import java.util.ArrayList;
@martiell
martiell / download.php
Created May 14, 2014 17:27
The Genius of Creative State.
<?php
$file = urldecode($_GET['F']);
$boom = explode("/", $file);
$count = count($boom);
$file_name = $boom[$count - 1];
header("Content-disposition: attachment; filename=".$file_name);
header("Content-type: application/pdf");
readfile($file);
?>
### Keybase proof
I hereby claim:
* I am martiell on github.
* I am martiell (https://keybase.io/martiell) on keybase.
* I have a public key whose fingerprint is 8C0A 0901 744D 269A D508 3E28 F56F AB41 85E1 CE7F
To claim this, I am signing this object:
@martiell
martiell / vnc
Created March 4, 2013 18:57
Faster alternative to vncserver script
#!/bin/sh
# Output PID of process listening on given port
pid_of_port() {
netstat -ntpl 2>/dev/null | \
PORT=$1 awk 'substr($4, match($4, "[0-9]*$")) == ENVIRON["PORT"] {
print substr($7, 0, match($7, "/") - 1)}'
}
success() {
@martiell
martiell / interfaces
Last active February 10, 2018 16:58
macvlan and bridge networking
auto lo
iface lo inet loopback
iface eth0 inet manual
auto br0
iface br0 inet dhcp
bridge_ports eth0
auto macvlan0
@martiell
martiell / Main.java
Created November 15, 2012 16:14
Ranges
import java.util.Map.Entry;
import java.util.TreeMap;
// See http://stackoverflow.com/a/13400317/611182
public class Main {
private static TreeMap<Double, String> m = new TreeMap<Double, String>();
static {
m.put(1.0, "A");
m.put(2.9, null);
@martiell
martiell / gist:2975183
Created June 22, 2012 21:02
Gerrit and jenkins-maven-plugin
<job>
<id>review</id>
<parent>base</parent>
<abstract>true</abstract>
<process>{{
node.scm.buildChooser[0].attributes().class =
'com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.GerritTriggerBuildChooser'
def name = node.scm.userRemoteConfigs[0].children()[0].url.text()
name = name.substring(name.lastIndexOf('/') + 1, name.lastIndexOf('.'))
def c = new NodeBuilder().
@martiell
martiell / gist:2889674
Created June 7, 2012 16:01
Write pom dependencies to a file
<plugin>
<groupId>org.codehaus.groovy.maven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.0</version>
<configuration>
<source>
// Write the compile/runtime classpath to a file, with one entry per line.
// Each line contains the relative path to a jar from the root of a Maven
// repository.
layout = new org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout()
@martiell
martiell / gist:2106993
Created March 19, 2012 10:36
Textograms
import Data.Char (ord, toLower, intToDigit)
import Data.Function (on)
import Data.List
import System.Environment (getArgs)
key char = case c of
c | c >= 'a' && c < 'p' -> 2 + (ord(c) - a) `div` 3
c | c >= 'p' && c <= 's' -> 7
c | c >= 't' && c <= 'v' -> 8
c | c >= 'w' && c <= 'z' -> 9