Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Tung Nguyen V. N. ntung

🏠
Working from home
Block or report user

Report or block ntung

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@aeischeid
aeischeid / ErrorController.groovy
Last active May 28, 2019
Alternate grails controller template and url mapping for adding a scaffolded JSON API
View ErrorController.groovy
package gvl
import grails.converters.JSON
class ErrorController {
// Forbidden
def error403() {
withFormat {
html { render(view: 'error403') }
@olivierobert
olivierobert / CI Detect Ajax
Created Nov 22, 2012
Code Igniter // Detect and return AJAX / JSON response
View CI Detect Ajax
/** Within the controller method **/
// If this is an ajax request, then return a JSON string
if ( $this->input->is_ajax_request() ):
$this->output->set_content_type('application/json');
$this->output->set_output( json_encode($data) );
endif;
View gist:3910584
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@digitaljhelms
digitaljhelms / gist:3099010
Created Jul 12, 2012
Squash the first two commits in a git repository's history
View gist:3099010

The scenario

Your repository has two commits:

$ git log --oneline
957fbfb No, I am your father.
9bb71ff A long time ago in a galaxy far, far away....
@eliotsykes
eliotsykes / DataNukerService.groovy
Created May 10, 2012
Grails GORM Truncate Tables in H2
View DataNukerService.groovy
package com.jetbootlabs.services
/*
* Truncates H2 tables mapped by the domainClasses variable. Useful for cleaning up test data.
*
* Temporarily disables referential integrity to avoid constraint violation errors when
* deleting records.
*
* Inspired by Luke Daley's blog post on how to do this in MySQL:
* http://ldaley.com/post/398082618/brute-force-fixture-cleanup-in-grails
@kdabir
kdabir / get_content.groovy
Created Feb 22, 2012
get content from url and write to a file in groovy
View get_content.groovy
// saving from url to a file (append)
new File("output.xml") << new URL ("http://some.url/some/path.xml").getText()
You can’t perform that action at this time.