Skip to content

Instantly share code, notes, and snippets.

View murphyslaw's full-sized avatar
🎯
Focusing

Falk Köppe murphyslaw

🎯
Focusing
View GitHub Profile
@murphyslaw
murphyslaw / shell-variables.sh
Created May 20, 2024 11:26
Sorted list of unique shell variables used in a file
grep -o '${[^}]*}' FILE | sort | uniq
@murphyslaw
murphyslaw / README.md
Created May 18, 2024 18:33
[Bitbucket Pipeline] Handle a repository-dependent dynamic step environment variable with default value from package.json version

PROBLEM

When, for example, you are sharing a step between a custom and a branch pipeline which requires a variable to be set, then you can set this variable in the custom pipeline with a custom manual pipeline variable , but this leaves the variable unset in the branch pipelines.

SOLUTION

If the VERSION variable is a static value in the branch pipelines, you can set it in the workspace , deployment or repository variables configuration. But if it is a dynamic value, based on your repository content, then shell parameter expansion [↑](https://www.gnu.org/software/bash/m

@murphyslaw
murphyslaw / ubuntu-install-ruby-1.8.7.sh
Last active June 13, 2023 14:14
Install Ruby 1.8.7 with rbenv on Ubuntu
# Install system libraries.
sudo apt-get install zlib1g-dev openssl libssl-dev libreadline-dev git-core
# Install rbenv.
git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
# Setup bash.
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL
@murphyslaw
murphyslaw / array_transformer.rb
Created June 3, 2011 19:18
A ruby script that transforms an array from a csv file into an array with the same structure but with transformed column names and values. You can optionally define transformations on each column.
#!/usr/bin/ruby -w
require 'active_support/core_ext'
# The transformer class uses a source array and a mapping table to
# create a target array, with the same structure as the source array
# but transformed values. The structure of the source array is oriented
# on what is returned after parsing a csv file.
#
# Optionally, it is also possible to define transformation methods for each column, which
@murphyslaw
murphyslaw / CSV Duplication Remover
Created May 28, 2011 07:49
A ruby script that removes duplicate rows in a csv file. Duplicates are found based on an identifier column and a criteria column, which are configurable.
#!/usr/bin/ruby -w
require 'csv'
require 'active_support/core_ext'
class Parser
attr_accessor :input_folder
attr_accessor :output_folder
attr_accessor :filename