Tag Archives: Groovy

Tutorial: Create Server with CenturyLink Cloud Java SDK

via Tutorial: Create Server with CenturyLink Cloud Java SDK – CenturyLink Cloud Developer Center.

At CenturyLink Cloud, our culture incorporates a DevOps mindset where each team owns the services they develop from implementation to production. In order to apply the DevOps mindset we adhere to these enabling principles: Automate, Self-Service, and Programmable. As an extension of these principles, we also provide public APIs and SDKs for multiple programming languages to enable our customers to also automate, self-serve and program infrastructure and service interactions.

In this tutorial we’ll take a look at the CenturyLink Cloud Java SDK and how we can use it to create a server using a CentOS 6 operating system template in a specific server group in a US East data center. For scripting in the Java Runtime Environment I tend towards using the Groovy programming language and Gradle for build automation. In order to execute the build commands later in this tutorial you must install Gradle so it can be used from your terminal.

Regular Expressions in 10 Different Languages

via Regular Expressions in 10 Different Languages – Treehouse Blog.

You might’ve heard that the word “OK” is the most globally recognized phrase in the world. It’s found in almost every spoken language from Arabic to Zulu.

In the programming world, we have something similar: Regular Expressions.

Regular Expressions, or regexes as the cool kids say, are powerful tools used to validate, manipulate, and extract data from text.  The way they work is by defining a pattern that describes what’s trying to be found.  This pattern is the “OK” of the programming world.

First, let’s take a look at how to construct a common pattern. We can use the title of this blog post as an example:

Groovy List Example

via Groovy List Example | Examples Java Code Geeks.

List is generally used as stack in software development world in order to push items in it for future use and to be able to fetch back in a desired way. In this tutorial, I will show you how to use Groovy list like a senior developer. I assume, you have already set up Groovy on local machine and executed Hello World project. So, let’s get started

Table Of Contents

1. Introduction
2. List Declaration
3. Add Items
4. Remove Items
5. Item Lookup
6. Split List
7. Count
8. Apply
9. Conclusion

Groovy Closure Example

via Groovy Closure Example | Examples Java Code Geeks.

In this example I’ll explain closures in Groovy.

According to Sabesta’s nice book Concepts of Programming Languages, defining a closure is a simple matter: “a closure is a subprogram and the referencing environment where it was defined.” But explaining it is not that simple. Sabesta explains the closure as a subprogram that can be assigned to a variable or passed to another subprogram so that it can be called anywhere. So far this may not be astonishing. But what is interesting is the fact that assigned or passed subprogram should be able to access all of the variables in its referencing environment. So we can call a closure an anonymous function with a storage.

Groovy as many other programming languages with some functional structures provides closures.

And now the real question comes: why do I need such an awkward structure? Of course to write shorter and more modular programs. Let’s imagine you have several methods that share only a few lines. Most of the time you factor out those shared lines into another method so that your original methods would make a call to this new method. That is modularising the methods. You can think of a closure as the function factored out in this example with one huge difference: Instead of calling the closure in your original methods, you are passing the closure back to those methods as if it were a variable.

That’s why in languages that support closures, they are called “first-class objects”. On the other hand the functions that receive or return (or both) closures are called higher-order function.

Instead of delving into the theoretical details of the concept, let’s focus on how Groovy provides closures as one of its main structures. According to Groovy’s standard documentation a closure in Groovy is an open, anonymous, block of code that can take arguments, return a value and be assigned to a variable. That means as we can pass a variable around the program we can pass closures back and forth in the program.

Integrating jOOQ with Grails Featuring the UWS-jOOQ Plugin

Introduction Grails is a web framework aimed to boost development productivity. One of the main features is domain centric database schema generation. Applications built with Grails are able to update existing schema just before they start. To do this, Grails is using built-in domain mappers or migrations in more advanced cases. The goal of the […]


Grails with MongoDB Tips Part 1

When working on Grails projects that requires persistent data my database of choice is MongoDB. MongoDB is a noSql database that is very scalable, and at home for those who are familar with JSON (called a document in MongoDB). When applying Grails RESTful resource functionality to a domain there are some tips to ensure that […]


Custom Authentication Success Handler with Grails and Spring Security

It’s Sunday and instead of devoting this day to our Lord I will dedicate it to the great Machine and its coding brethren. The jokes aside, this is a quick show up of how to establish custom Authentication Success Handler if you are working with Grails Framework + Spring Security Core Plugin. Well first, why […]