During the last few months I’ve spent substantial amount of free time learning Scala and consider it time well spent. This article is first part describing my favorite features of Scala
Whenever you define a val or var, what comes after the keyword is not simply an identifier but rather a pattern.
val regex = "(\\d+)/(\\d+)/(\\d+)".r
val regex(year, month, day) = "2015/7/29"
The val regex is an instance of Regex, and when you use it in a pattern, you’re implicitly calling regex.unapplySeq , which extracts the match groups into a Seq[String], the elements of which are assigned in order to the variables year, month, and day.
When developing OSGi based application in Eclipse adding required import package declaration is assisted by PDE. In practice, it means that import package declarations are never missing – otherwise Eclipse project won’t comile and run. What programmers almost never do is to remove unnecessary declarations. Why would they if it works? In practice bundle manifests polluted with unnecessary imported packages can cause performance issues during bundle resolution and classloading and sometimes confuse Eclipse PDE during development.
To mitigate this problem I’ve created a small application leveraging the power of excellent BND library. I was really surprised when I run this tool against bundles from application I’m currently working on – some had literally hundreds of unnecessarily imported packages.
Usage: oipv [options]
-j <jar1>,<jar2>... | --jars <jar1>,<jar2>...
jars or folders to include
-e <package1>,<package2> | --exclude-package <package1>,<package2>
Package prefixes to exclude from analysis. You may want to
excluded packages exported by JRE - javax.swing, javax.sql, etc.
to avoid false positives
print usage text
Application code available at GitHub (github.com) – https://github.com/jarek-przygodzki/osgi-import-package-verifier. The app itself is available here: oipv-1.0-master-f6c5c79.zip
Recently I found myself doing some Bamboo maintenance. Namely, I had to delete all disabled branches of build plan related to already deleted feature branches that Bamboo failed to automatically remove. At first, I tried this shell script, but it didn’t work for me with Bamboo 5.6.2 and I ended writing my own version. I’m posting it here hoping it will be useful for others too
Usage is very simple
groovy bamboo_delete_disabled_branches.groovy \
--bamboo-url <BAMBOO_URL, i.e. http://mycompany/bamboo> \
--plan-key <PLAN_KEY> \
--user <USER> --password <PASSWORD>
You can also perform a simulation without actually deleting anything with „–dry-run” option.