These are some simple examples for JavaScript’s Promise object. Use it to make your asynchronous operations code more managable and avoid callback hells.
Using Google Cloud DNS
Google Cloud DNS service provides an interesting pay as you use pricing model. Announced in March 2014, Google Cloud DNS can only be managed via Google’s gcloud command line tool or REST APIs.
Remember-Me Authentication With Spring Security on Google App Engine
Spring Security has built-in “remember-me” authentication capability to remember the identity of a user (principle) between session.
However, default implementations for “persistent token” only support in-memory (for testing) and JDBC. I wanted to implement this with App Engine using Objectify for persistence.
All it takes is to implement a custom PersistentTokenRepository
and configure Spring Security to use it. This post assumes that Spring Security has been configured to work correctly with App Engine.
Optional Dependency for Method Parameter With Spring @Configuration
I started with a Spring Java configuration that looks like this:
1 2 3 4 5 6 |
|
Basically Collection<RelatedService>
is telling Spring to look for all beans matching the type of RelatedService
and put them in a Collection
for me to use in myService()
.
Then I wanted to make relatedServices
an optional dependency. Ideally, I would like to be able to do something like this:
1 2 3 4 5 6 7 |
|
However, @Autowired
cannot annotate a parameter. This is what I end up doing.
1 2 3 4 5 6 7 8 9 |
|
I would prefer to limit the visibility/scope of relatedServices
within the method but it does not look possible.
Developing a Bower Package While Using It
The bower link
feature makes it easy to change & test packages while using it as a dependency in other packages. If you are using Bower, you should be using this.
Change User Within JUnit Test Case in Google AppEngine
Google AppEngine (Java) provides ability to mock UserService
in JUnit test cases with the help of LocalUserServiceTestConfig
. However, switching user within a test case is not so simple.
Groovy Support in Maven Projects
Groovy has a unique quality that other dynamic/scripting languages does not – you can write plain Java code in a Groovy class.
This attribute makes it an excellent choice for Java developers trying to pick up this dynamic language – start by writing Java and ease into Groovy’s style as you practice.
Creating GitHub Pages With Jekyll & LiveReload
Composing blog posts in Markdown is great but it would be even better if I can see how pages are rendered live. So, let’s have that.