It would be “do your job best way you can do it, but expect others to screw up”. And this advice is not only regarding code, but everything you work with. If there is some chance that something can go wrong, eventually, it will go wrong. If there is possibility of Database getting files corrupted, eventually it will. If there is possibility that some query will take too long and as the result of it, your system will become unresponsive, it will.
Recently I encountered really nasty error in grails which took quite some time to fix. It was really hard to find reason because of the really weird stacktrace and it was only happening when being deployed on tomcat server. Exception looked something like this: First it seem to have something to do with log4j system, but it turns out that HttpBuilder was to blame! It has different version of groovy specified as dependency, which was conflicting with version of groovy coming with grails, causing this nasty error.
One day I needed to lock a record in grails application for update so other transactions does not mess with it while I am updating it. I started digging through the doc and found a section about locking in official documentation. It was pretty straightforward: you just need to use *lock() *method. So I did this: And this was working fine. In this basic case. My actual scenario was more complicated, it involved constantly polling database for new messages to process which are not been taken by other workers.
This post will be not about technical stuff of Android or Grails, but about programming in general. Yesterday, when I was waiting for my program to start on android I start thinking that I lose quite some time for this start-click-see result cycle. If it takes 30-50 seconds to build upload and start new apk on android, then it can easily end up as half an hour a day just restarting the app.
Recently, when I was going through 2-step verification process for my gmail account, I thought that it would be nice if I did not have to peek my phone and check the text. If there would be an app just to read that code out loud so I can enter it. So, I created it! It is now on google play and you can download it to your android phone here: speak the code
Just small note to all you guys if you are using google protobuf library for communicating with server. Lets say you have simple protobuf message with one optional numeric field: If you are using some dynamic language in your server backend, you can end up having code like this: Now question, what value of limit variable will be, if message will not have limit field set? Answer is: 0.
I think that Android is a platform created by developers for developers. That’s why sometimes it offers several different ways to do the same thing. Let’s say you want to execute some periodic task in background, even if currently none of your Activities is active. How you can achieve this? First of all, you should be careful with Application process lifecycle. Basically, if none of your activities are visible, Android will destroy your app at some point in the future.
Remember I told you that Groovy is really good for scripting? Time for some proof. Lets say you want to download and parse some html page and get the content of the third list on page. How do you do that? Using URL and Regular expressions? Here I`ll tell you how it can be done in groovy. I will use gumtree search result as an example: // Grap HTTPBuilder component from maven repository @Grab(group='org.
Before I introduce *Grails *to you, I want to write a little bit about Groovy, because it is used as the main language in grails. What is Groovy? Groovy is a dynamic language build on top of Java Virtual Machine whose features are inspired by the success of languages like Python, Ruby and smalltalk. Lets go forth step by step. Groovy is a language for Java Virtual Machine What does that mean?
Hi everybody. While I am writing introduction post about grails, I would like to share solution for a problem I have encountered today. Lets say inside Grails application you want to get a Class object for some Groovy/Java class, which is located in src/groovy or src/java folders by class name. For example, in BootStrap.groovy. You might end up with code like this: // Somewhere in BootStrap.groovy def obj = Class.forName("com.binarybuffer.grails.MyCoolClass") You may find that this code throws ClassNotFoundException.