Skip to content

Instantly share code, notes, and snippets.

@wheelerlaw
wheelerlaw / elevate.sh
Last active September 29, 2023 16:22
Running elevated commands from a non-elevated git-bash with the ability to pipe/redirect the output of the elevated command.
#!/usr/bin/env bash
elevate() {
powershell -Command "Start-Process cmd -ArgumentList \"/c\",\"$1 2>&1 | clip\" -Verb RunAs"
powershell -sta "add-type -as System.Windows.Forms; [windows.forms.clipboard]::GetText()"
}
@oifland
oifland / Jenkinsfile
Last active March 23, 2024 17:59
Loops in Jenkinsfiles
// Related to https://issues.jenkins-ci.org/browse/JENKINS-26481
abcs = ['a', 'b', 'c']
node('master') {
stage('Test 1: loop of echo statements') {
echo_all(abcs)
}
stage('Test 2: loop of sh commands') {
@wavezhang
wavezhang / java_download.sh
Last active April 29, 2024 14:42
download java from oracle without login
wget -c --no-cookies --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn-pub/java/jdk/12.0.2+10/e482c34c86bd4bf8b56c0b35558996b9/jdk-12.0.2_linux-x64_bin.tar.gz
@Faheetah
Faheetah / Jenkinsfile.groovy
Last active March 6, 2024 18:14
Jenkinsfile idiosynchrasies with escaping and quotes
node {
echo 'Results included as an inline comment exactly how they are returned as of Jenkins 2.121, with $BUILD_NUMBER = 1'
echo 'No quotes, pipeline command in single quotes'
sh 'echo $BUILD_NUMBER' // 1
echo 'Double quotes are silently dropped'
sh 'echo "$BUILD_NUMBER"' // 1
echo 'Even escaped with a single backslash they are dropped'
sh 'echo \"$BUILD_NUMBER\"' // 1
echo 'Using two backslashes, the quotes are preserved'
sh 'echo \\"$BUILD_NUMBER\\"' // "1"
@anildigital
anildigital / gist:862675ec1b7bccabc311
Created July 26, 2014 18:27
Remove dangling docker images
docker rmi $(docker images -q -f dangling=true)
@djangofan
djangofan / endorsedmethod.java
Last active January 6, 2023 22:05
Exercise on safely waiting for unstable web elements with WebDriver.
// This is the official Selenium documention endorsed method of waiting for elements.
// This method is ineffective because it still suffers from
// the stale element exception.
public static void clickByLocator ( final By locator ) {
WebElement myDynamicElement = ( new WebDriverWait(driver, 10))
.until( ExpectedConditions.presenceOfElementLocated( locator ) );
myDynamicElement.click();
}
@josephj
josephj / key-event-with-swf.html
Last active December 14, 2015 10:49
SWF swallows any JavaScript key events while it's focused. This demo illustrates how to make key events always work while SWF exists on page.
<!DOCTYPE html>
<html>
<head>
<title>SWF & JavaScript Key Event</title>
<style>
#focusable-link {
position: absolute;
left: -1000em;
top: -1000em;
}
@davglass
davglass / gist:4675460
Created January 30, 2013 18:26
Local Gallery Loading.
YUI.applyConfig({
groups: {
gallery: {
combine: false,
root: '/build/',
patterns: {
'gallery-': { },
'lang/gallery-': {},
'gallerycss-': { type: 'css' }
}
YUI.add('handlebars-helpers', function(Y) {
var NS = Y.namespace('TDP'),
Handlebars = Y.Handlebars,
Lang = Y.Lang,
isString = Lang.isString,
isArray = Lang.isArray,
isObject = Lang.isObject,
isFunction = Lang.isFunction,
Aeach = Y.Array.each,
@kara-ryli
kara-ryli / loader-config.html
Created April 5, 2012 02:45
FIXME: Configure loader to work correctly with multiple CDNs and a third-party hosted YUI
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Loader Test</title>
<meta name="generator" content="TextMate http://macromates.com/">
<meta name="author" content="Ryan Cannon">
<script src="http://www.nfl.com/yui/3.4.1/build/yui/yui-min.js"></script>
<script>
var YUI_config = {