Skip to content

Instantly share code, notes, and snippets.

View basilevs's full-sized avatar

Vasili Gulevich basilevs

  • Xored Software Inc
  • Tbilisi, Georgia
View GitHub Profile
@basilevs
basilevs / hide_pipeline_success.user.js
Last active March 27, 2024 18:39
Hide successful Jenkins Pipeline steps
// ==UserScript==
// @name Hide successful pipeline steps
// @version 2
// @grant none
// @match https://jenkins-itest.spirenteng.com/jenkins*/job/*/flowGraphTable/
// ==/UserScript==
//icon-blue
@basilevs
basilevs / rcptt_artifact_links.user.js
Last active April 2, 2024 04:58
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 {
@basilevs
basilevs / download_build.py
Created July 3, 2021 18:06
Download and unzip a file via HTTP in Python with disconnect recovery
#!/usr/bin/python3
#from jenkins import Jenkins
#from os import environ
from tempfile import TemporaryFile, gettempdir
from os.path import join, exists
from zipfile import ZipFile
from requests import get
from pprint import pprint
@basilevs
basilevs / resetTouchpad.service
Created April 13, 2021 13:37
A systemd service to reset old Synaptic touchpads after suspend. Put in /etc/systemd/system/
[Unit]
Description=Reset touchpad after suspend
After=suspend.target
[Service]
User=root
Type=oneshot
ExecStart=modprobe -r psmouse ; modprobe psmouse
TimeoutSec=0
StandardOutput=syslog
@basilevs
basilevs / ProjectCopy.java
Created October 23, 2019 09:40
Dumb copy of a project from bundle resource to Eclipse workspace
public static void importProjectFromBundleResource(IWorkspace workspace, Bundle bundle, IPath projectPathInBundle) {
try {
URL descriptionUrl = bundle.getEntry(projectPathInBundle.append(".project").toPortableString());
IProjectDescription description;
try(InputStream descriptorStream = descriptionUrl.openStream()) {
description = workspace.loadProjectDescription(descriptorStream);
}
description.setLocationURI(null);
IProject project = workspace.getRoot().getProject(description.getName());
workspace.run(monitor -> {
@basilevs
basilevs / updateGerritChange.sh
Last active August 16, 2019 10:46
Updates an existing Gerrit change
#!/bin/bash
# updateGerritChange.sh
#
# Updates an existing Gerrit change for master branch with a state of current Git branch based on that change
#
# Allows to keep a history of changes for a Gerrit change in a local Git branch.
#
# Usage:
# git checkout master