Skip to content

Instantly share code, notes, and snippets.

View kevintanhongann's full-sized avatar
🏠
Working from the cafe

Kevin H.A Tan kevintanhongann

🏠
Working from the cafe
View GitHub Profile
@kevintanhongann
kevintanhongann / carousel
Last active June 18, 2018 07:10
test carousel
@kevintanhongann
kevintanhongann / FirebaseAuthService.groovy
Last active April 15, 2018 12:07
FirebaseAuthService
import grails.gorm.transactions.Transactional
import groovy.json.JsonSlurper
import groovyx.net.http.HttpBuilder
import io.reactivex.Emitter
import io.reactivex.Observable
import org.springframework.http.HttpStatus
import static groovyx.net.http.HttpBuilder.configure
import groovyx.net.http.*
changeListener($event) : void {
this.readThis($event.target);
}
readThis(inputValue: any): void {
var file:File = inputValue.files[0];
var myReader:FileReader = new FileReader();
myReader.onloadend = (e) => {
this.image = myReader.result;
npm uninstall -g angular-cli
npm cache clean
npm install -g @angular/cli@latest
rm -rf node_modules
npm uninstall --save-dev angular-cli
npm install --save-dev @angular/cli@latest
npm install
def esVersion = '5.6.5'
ext['elasticsearch.version'] = esVersion
ext {
elasticsearchVersion = esVersion
}
compile 'org.grails.plugins:elasticsearch:2.4.0.RC1'
compile 'org.elasticsearch.plugin:mapper-attachments:2.3.3'
@kevintanhongann
kevintanhongann / CustomRestInterceptor.groovy
Last active December 26, 2021 21:35
This is a Grails custom REST interceptor that validates auth token with Firebase auth to authenticate to a Grails server.
package haulage.project
import groovyx.net.http.ContentType
import groovyx.net.http.HTTPBuilder
import groovyx.net.http.HttpResponseException
import static javax.servlet.http.HttpServletResponse.*
class CustomRestInterceptor {

Keybase proof

I hereby claim:

  • I am kevintanhongann on github.
  • I am kevinhatan (https://keybase.io/kevinhatan) on keybase.
  • I have a public key ASCd523HXDS-HYKcsXQjSbDuhlFYQNvH-HJzqvlUYkcPzAo

To claim this, I am signing this object:

@kevintanhongann
kevintanhongann / build.gradle
Created May 5, 2016 04:59
Gradle filter alpha beta version out sample gradle file
apply plugin: 'java'
apply plugin: 'project-report'
configurations.all {
resolutionStrategy {
componentSelection {
all {
if(selection.candidate.version.contains('Alpha')) || selection.candidate.version.contains('Beta')){
selection.reject("rejecting non-final")
}
@kevintanhongann
kevintanhongann / TestSpringMicro.groovy
Last active December 18, 2015 12:24
This is a demo on Spring Boot micro service by using only one groovy script. To run this, use 'spring run TestSpringMicro.groovy'.
@Grapes(
@Grab(group='org.springframework', module='spring-web', version='4.2.4.RELEASE')
)
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
@kevintanhongann
kevintanhongann / gist:595c601909d1814641b8
Created March 6, 2015 10:06
An example on what type of volley android errors can be used
public void onErrorResponse(VolleyError error) {
int statusCode = error.networkResponse.statusCode;
NetworkResponse response = error.networkResponse;
Log.d("testerror",""+statusCode+" "+response.data);
// Handle your error types accordingly.For Timeout & No connection error, you can show 'retry' button.
// For AuthFailure, you can re login with user credentials.
// For ClientError, 400 & 401, Errors happening on client side when sending api request.
// In this case you can check how client is forming the api and debug accordingly.
// For ServerError 5xx, you can do retry or handle accordingly.