Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

William Penagos fortil

🎯
Focusing
View GitHub Profile
@fortil
fortil / Jenkinsfile.groovy
Created Oct 21, 2020 — forked from Faheetah/Jenkinsfile.groovy
Jenkinsfile idiosynchrasies with escaping and quotes
View Jenkinsfile.groovy
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"
@fortil
fortil / binary_tree.js
Last active Oct 3, 2018
S-Expression to binary tree in JavaScript
View binary_tree.js
function SExpression(nodes) {
if (!/(\(|\))+/g.test(nodes)) {
return 'E5'
}
let a = nodes.split(' ').map(i => i.replace(/\(|\)/g, '').split(','))
let keyPair = a.map(i => i[0])
let valuePair = a.map(i => i[1])
let aE1 = keyPair.reduce((prev, curr) => {
prev[curr] = (prev[curr] || 0) + 1
return prev
You can’t perform that action at this time.