Skip to content

Instantly share code, notes, and snippets.

View edupo's full-sized avatar

Edu P. edupo

View GitHub Profile
@edupo
edupo / csr_one_line.sh
Last active October 13, 2017 07:22
crt to one line
#!/bin/bash
if [ -f "$1" ]; then
sed s/$/\\\\n/ "$1" | tr -d '\n'
fi
@edupo
edupo / Jenkinsfile.groovy
Created September 29, 2017 12:14 — forked from Faheetah/Jenkinsfile.groovy
Jenkinsfile idiosynchrasies with escaping and quotes
node {
echo 'No quotes in single backticks'
sh 'echo $BUILD_NUMBER'
echo 'Double quotes are silently dropped'
sh 'echo "$BUILD_NUMBER"'
echo 'Even escaped with a single backslash they are dropped'
sh 'echo \"$BUILD_NUMBER\"'
echo 'Using two backslashes, the quotes are preserved'
sh 'echo \\"$BUILD_NUMBER\\"'
echo 'Using three backslashes still results in preserving the single quotes'
@edupo
edupo / Makefile
Created May 26, 2017 19:44
Shell script test Makefile
#!/usr/bin/make
# exclude switches are useful for git and vim users. Other may apply here.
test: shellcheck.check
grep -rIl '^#![[:blank:]]*/bin/\(bash\|sh\|zsh\)' \
--exclude-dir=.git --exclude=*.sw? \
| xargs shellcheck
# .check targets just tests for a command to be available on your PATH.
.PHONY: %.check
package main
import (
"fmt"
"sync"
)
type Fetcher interface {
Fetch(url string) (body string, urls []string, err error)
}
@edupo
edupo / twoline_prompt.sh
Last active April 17, 2019 00:28 — forked from mkottman/twoline_prompt.sh
A two-line colored Bash prompt (PS1) with Git branch and a line decoration which adjusts automatically to the width of the terminal. Recognizes SVN, Git and Fossil version control systems and shows the current branch/revision.
# A two-line colored Bash prompt (PS1) with some version control
# system prompts (git, mercurial, svn adn fossil) aligned to the right.
# Author: Michal Kottman, 2012
# Contributor: DrumMeister, 2016
# Contributor: Eduardo Lezcano, 2016
RESET="\[\033[0m\]"
RED="\[\033[0;31m\]"
GREEN="\[\033[01;32m\]"
BLUE="\[\033[01;34m\]"