Skip to content

Instantly share code, notes, and snippets.

@oak-tree
oak-tree / gist:8708433
Created January 30, 2014 13:36
spring controller integration test
MvcResult result = (MvcResult) mockMvc.perform(post("/api/search/report/advanced").contentType(TestUtil.APPLICATION_JSON_UTF8)
.content(pageRequest.getBytes()))
.andExpect(status().isOk())
.andExpect(content().contentType(TestUtil.APPLICATION_JSON_UTF8))
.andExpect(jsonPath("$[0].page").value(page.intValue()))
.andExpect(jsonPath("$[0].page").exists()).andReturn();
booolView.render().$el.find('img').one('load', function(event) {
/* make sure to cancel timeout first */
model.trigger('boool:load-event');
self.collection.trigger('boool:load-event');
console.log('loaded');
}).one('error', function(event) {
console.log('error loading the img');
connect: {
options: {
port: 9000,
// // change this to '0.0.0.0' to access the server from outside
// // hostname: 'localhost'
hostname: '0.0.0.0'
},
livereload: {
options: {
middleware: function (connect) {
/**
*
* add bind to function prototype example
* model.on('click',myobject.somefunction.bind(this));
*
*/
Function.prototype.bind = function(context) {
var fn = this; // correlates to this.onTimeout
return function() { // what gets passed: an anonymous function
/* this WORKS */
@RequestMapping(value = "{field}/image/{name}.jpg", method = RequestMethod.GET)
public void getImage(HttpServletResponse response, @PathVariable("field") String field,@PathVariable("name") String name)
throws NoSuchImageException, BadFieldNameException, IOException, PathTraversalException {
model.uploadMagdirImageFile(MagdirPrecondition.fieldNameOk(field),name, response);
based on http://stackoverflow.com/a/19346375/1211174
UPDATE `reports` r
INNER JOIN
`reportstemp` as t
ON
`r`.`REPORT_ID`= `t`.`REPORT_ID`
SET
`r`.`LAST_MODIFIED` = `t`.`LAST_MODIFIED`,
`r`.`modifier_id` = `t`.`modifier_id`
@oak-tree
oak-tree / gist:6fadc29cf852a3f874eb
Created August 26, 2014 10:33
MySql: search for all tables and db with collation different than utf_8_general_c
SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME, COLLATION_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLLATION_NAME != 'utf8_general_ci'
LIMIT 0 , 30
Hibernate:
select
count(reportqs0_.REPORT_ID) as col_0_0_
from
reports reportqs0_
inner join
reports_projects projects1_
on reportqs0_.REPORT_ID=projects1_.report_id
inner join
projects project2_
@oak-tree
oak-tree / gist:9f710374d33fbb2caf03
Created September 3, 2014 14:52
select all records that doesn't have relation to another table
SELECT rp.report_id, rp.project_id, rp.project FROM `reports_projects` as rp where rp.project not in (select p.CODE from projects as p) limit 50
@oak-tree
oak-tree / git start point
Last active August 29, 2015 14:08
git start point
##version control:
http://git-scm.com/video/what-is-version-control
##git installing:
http://git-scm.com/
##git learning:
http://git-scm.com/documentation
https://training.github.com/kit/downloads/github-git-cheat-sheet.pdf