Skip to content

Instantly share code, notes, and snippets.

@iocanel
iocanel / jenkins-setup-credentials.groovy
Created September 1, 2015 09:12
Setup Jenkins Credentials
import jenkins.model.*
import com.cloudbees.plugins.credentials.*
import com.cloudbees.plugins.credentials.common.*
import com.cloudbees.plugins.credentials.domains.*
import com.cloudbees.plugins.credentials.impl.*
import com.cloudbees.jenkins.plugins.sshcredentials.impl.*
import hudson.plugins.sshslaves.*;
domain = Domain.global()
store = Jenkins.instance.getExtensionList('com.cloudbees.plugins.credentials.SystemCredentialsProvider')[0].getStore()
@sorenlouv
sorenlouv / cpu-intensive.js
Last active December 19, 2023 06:00
A CPU intensive operation. Use to test imitate blocking code, test WebWorkers etc.
function mySlowFunction(baseNumber) {
console.time('mySlowFunction');
let result = 0;
for (var i = Math.pow(baseNumber, 7); i >= 0; i--) {
result += Math.atan(i) * Math.tan(i);
};
console.timeEnd('mySlowFunction');
}
mySlowFunction(8); // higher number => more iterations => slower
@aoitaku
aoitaku / chunkBy.ts
Last active May 30, 2022 19:32
chunkBy mixin for lodash
/// <reference path='typings/index.d.ts' />
import * as _ from 'lodash'
declare module 'lodash' {
// tslint:disable-next-line:interface-name
interface LoDashStatic {
chunkBy <T> (array: T[], predicate: (element: T) => boolean): T[][]
}
}
_.mixin({
chunkBy <T> (array: T[], predicate: (element: T) => boolean): T[][] {
@mladenp
mladenp / iframe-listener.js
Created October 8, 2018 16:53
iframe URL redirect listener
function iframeURLChange(iframe, callback) {
var unloadHandler = function () {
// Timeout needed because the URL changes immediately after
// the `unload` event is dispatched.
setTimeout(function () {
callback(iframe.contentWindow.location.href);
}, 0);
};
function attachUnload() {