Skip to content

Instantly share code, notes, and snippets.

View basilevs's full-sized avatar

Vasili Gulevich basilevs

View GitHub Profile
package org.basilevs.example.flush;
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.Objects;
final Display display = Display.getDefault();
final Image captureImage = new Image(display, display.getBounds().width, display.getBounds().height);
GC gc = new GC(display);
gc.copyArea(captureImage, display.getBounds().x, display.getBounds().y);
gc.dispose();
Imagewriter.write(...)
@basilevs
basilevs / jenkins-autologin.user.js
Created October 23, 2024 10:27
Jenkins auto-login
// ==UserScript==
// @name Jenkins auto-login
// @version 1
// @match https://jenkins-itest.spirenteng.com/jenkins/*
// @match https://ci.eclipse.org/*
// @grant none
// ==/UserScript==
function findSingleNode(query) {
const buttons = document.evaluate(query, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE);
@basilevs
basilevs / Jenkinsfile
Last active October 11, 2024 09:58
Minimal declarative Jenkins pipeline definition
pipeline {
agent any
options {
buildDiscarder(logRotator(numToKeepStr: '2', daysToKeepStr: '7', removeLastBuild: true))
}
stages {
stage("test") {
steps {
echo "q"
@basilevs
basilevs / hide_pipeline_success.user.js
Last active October 20, 2024 17:11
Hide successful Jenkins Pipeline steps
// ==UserScript==
// @name Hide successful pipeline steps
// @version 5
// @grant GM.setValue
// @grant GM.getValue
// @match https://jenkins-itest.spirenteng.com/jenkins*/job/*/flowGraphTable/
// @match https://ci.eclipse.org/*/job/*/flowGraphTable/
// ==/UserScript==
@basilevs
basilevs / rcptt_artifact_links.user.js
Last active September 3, 2024 13:18
Add useful artifact links to RCPTT build page.
@basilevs
basilevs / cleanupJenkinsWorkspaces.groovy
Last active January 31, 2023 20:06 — forked from EvilBeaver/cleanupJenkinsWorkspaces.groovy
A jenkins script to clean up workspaces on slaves
// Check if a slave has < 50 GB of free space, wipe out workspaces if it does
import hudson.model.*;
import hudson.util.*;
import jenkins.model.*;
import hudson.FilePath.FileCallable;
import hudson.slaves.OfflineCause;
import hudson.node_monitors.*;
@basilevs
basilevs / gist:9645529d4738e8d6b363ac475af6f297
Last active November 17, 2022 18:33
A jenkins script to clean up workspaces on slaves
// Check if a slave has < 10 GB of free space, wipe out workspaces if it does
import hudson.model.*;
import hudson.util.*;
import jenkins.model.*;
import hudson.FilePath.FileCallable;
import hudson.slaves.OfflineCause;
import hudson.node_monitors.*;
import org.jenkinsci.plugins.workflow.job.WorkflowRun
import org.jenkinsci.plugins.workflow.flow.FlowExecution;
@basilevs
basilevs / ExclusiveRunnerMutex.java
Created July 27, 2021 08:47
Locking implementation
import java.util.Objects;
/** Executes a runnable as a critical section but without any blocking.
* Number of executions is not guaranteed to match a number of invocations.
* Last invocation happens-before last execution.
*
* **/
public final class ExclusiveRunner implements Runnable {
private final Runnable delegate;
private final Object lock = new Object();
@basilevs
basilevs / ExclusiveRunner.java
Created July 27, 2021 08:15
Explain concurrency error
import java.util.Objects;
import java.util.concurrent.Semaphore;
import java.util.concurrent.atomic.AtomicBoolean;
/** Executes a runnable as a critical section but without any blocking.
* Number of executions is not guaranteed to match a number of invocations.
* Last invocation happens-before last execution.
*
* **/
public final class ExclusiveRunner implements Runnable {