This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import groovy.sql.Sql | |
def sql = new Sql(dataSource) | |
def query = "select * from table" | |
def rows = sql.rows(query) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def query_params = [] | |
def and_where_string = '' | |
if (params.name) { | |
and_where_string = " and where upper(name) like ? " | |
query_params << "%" + params.name.toUpperCase() + "%" | |
} | |
def query = """ | |
select * from table | |
where table.id is not null | |
$and_where_string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//bind user connection to groovy sql | |
Connection conn = dataSource.getConnection(username, password) | |
def hibernateSession = sessionFactory.currentSession | |
hibernateSession.reconnect(conn) | |
def sql = new Sql(sessionFactory.getCurrentSession().connection()) | |
// | |
//perform sql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def user_params = ['firstName', 'lastName'] | |
//put params in request in case of errors | |
for (e in params) { | |
if (e.key in user_params) { | |
request."$e.key" = e.value | |
} | |
} | |
//in view, value="${request?.firstName}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def send_params = [:] | |
for (e in request.parameterMap) { | |
if (e.key & e.key instanceof java.lang.String && e.key in user_params && e.value) { | |
send_params."${e.key}" = e.value[0] | |
} | |
} | |
<g:link action="" params="${send_params}"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Hadoop --> | |
<!-- core-site.xml --> | |
<?xml version="1.0"?> | |
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?> | |
<!-- Put site-specific property overrides in this file. --> | |
<configuration> | |
<property> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GrailsTest extends GroovyTestCase implements ApplicationContextAware { | |
ApplicationContext app | |
def controller | |
void setUp() { | |
super.setUp() | |
controller = MyController() | |
controller.dataSource = app.getBean("dataSource") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static String anInvalidCharacter = /[^-A-Za-z9-9@\s()\,\;\:\.]+/ | |
if (s =~ anInvalidCharacter) | |
//an invalid character |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A = load '/tmp/alice.txt'; | |
B = foreach A generate flatten(TOKENIZE((chararray)$0)) as word; | |
C = filter B by word matches '\\w+'; | |
D = group C by word; | |
E = foreach D generate COUNT(C), group; | |
store E into '/tmp/alice_wordcount'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let maplocalleader = "," | |
let mapleader = "," | |
set number | |
set nowrap | |
syntax on | |
filetype plugin indent on | |
colorscheme koehler | |
set guioptions-=T |
OlderNewer