Skip to main content

Posts

Groovy Grails POST/GET Requests

Just a snippet of how to do GET/POST request in Groovy Grails. try{       HttpBuilder http = new HTTPBuilder('your URL here')       def postBody = [name: 'bob', title: 'construction worker']       http.post(body: postBody,                         requestContentType: ContentType.JSON) { resp, json ->                     //This is to assume everything is successful within this                         //closure                     println "response status " + resp.statusLine                     println "json response " + json                                      } }catc...

How To Generate Signed APK using Gradle in Android Studio

So Android Studio doesn't encourage you to sign your APK the UI way using Android Studio, instead they're directing you to use Gradle to generate it (or in complex cases, there'll be a lot of APKs generated according to different build types and flavors) 1. Declare these inside the android bracket within the gradle file within your main Android project as shown below (while putting your keystore files in your project root directory): signingConfigs{         debug {             storeFile file("example.keystore")             storePassword "example"             keyAlias "example"             keyPassword "example"         }         release {             storeFile file("example-release.keystore")             storePassword "exam...

Grails Deployment on Openshift

Just a simple guide on how to get started on deploying a Grails app up to Openshift. The prerequisites to get started, we need two things being Git and the Openshift RHC tool. Guide on how to install them in different OS platforms are available here . This is only a simple static website developed using Grails. This guide is based off on https://www.openshift.com/blogs/day-6-rapid-web-development-on-the-jvm-with-grails Step 1: Don't bother creating the free app on the Openshift application console. Instead we're gonna use the Openshift RHC command line tool and create the free app. Do this in your user directory: rhc create-app appname tomcat-7 This will create a gear that is assumed to be Jboss EWS 2.0, but it's not. Anyways, assuming that you're not doing any data storing functionality on the Grails app, tomcat-7 is what you need. So let everything being taken cared of for you, and a repo will be cloned based on the appname that yo...

Install Git Bash Completion on Mac OS X

Bash completion for Git isn't available by default on the Mac's Terminal. So you have to assign it yourself in the environment path setup. By default your git directory should be at /usr/local/git in Mac. Assuming you're at your user directory: Step 1: sudo nano .bash_profile Step 2: add the line  source /usr/local/git/contrib/completion/git-completion.bash Ctrl+X to save, Ctrl+Y to save file name. Step 3: source .bash_profile Logout and Login again.

EventBus for Android Quick Tutorial

Here I wanna demonstrate to you guys on how to get started on using GreenRobot's EventBus for Android. This is worked using Android Studio. To get started, add EventBus into Gradle dependency, inside build.gradle. dependencies {     compile 'de.greenrobot:eventbus:2.1.0' } (versions may vary. You need to check Maven Central for the latest version) The sample code is right here. https://github.com/L0rDKadaj/EventBusSample In this sample code, I have demonstrated how to pass an object from the PlaceHolderFragment to the SecondFragment by using sticky events, with a trigger of a Button. No more headaches on whether to convert an object into a Parcelable object or not. There are a lot of use cases that you can use EventBus for. For example, if you have a three pane layout in a 10 inch tablet, you can probably code two fragments to listen to the same event and the values will pass, which proves the decoupled concept.  But, you have to know ...

Setting Up Android CheckStyle in Android Studio

So we all want to abide by the Android Code Style Guidelines shown in the official Android developer website here . How do we get started by helping ourselves by abiding by the Java and Android code style rules? Simple. Set it in Android Studio with the instructions below:  1. Copy the file in  https://github.com/android/platform_development/blob/master/ide/intellij/codestyles/AndroidStyle.xml 2. Paste the file into ~/.AndroidStudioPreview/config/codestyles/ (in Ubuntu) or ~/Library/Preferences/AndroidStudioPreview/codestyles (in Mac OS X) 3. Go to Settings (or Preferences in Mac OS X) > Code Style > Java, select AndroidStyle, as well as Code Style > XML and select AndroidStyle. 4. Start code inspection and see the results by selecting Analyze > Inspect Code. You will see the results of inspection on the Inspection pane at the bottom and and you will notice things that you can improve in your Java code such as Code Style Issues, A...