Skip to content

Instantly share code, notes, and snippets.

View zedar's full-sized avatar

Robert Zakrzewski zedar

  • Twitter@zedar185
View GitHub Profile
@zedar
zedar / DestroyableClass.js
Created January 8, 2014 23:46
Destroyable dojo class - keep track of reference (handlers) to DOM events and event subscription. Remove them (automatically) when class instance is destoyed. dijit/Destroyable is a mixin class to track handles and release them.
define([
"dojo/_base/declare",
"dojo/_base/lang",
"dojo/topic",
"dijit/Destroyable"
], function(declare, lang, topic, Destroyable) {
var _class = declare("DestroyableController", [Destroyable], {
constructor: function(args) {
declare.safeMixin();
@zedar
zedar / CasperJS and UnderscoreJS
Created February 8, 2014 11:02
CasperJS and underscore.js
Casper.js - testing library for web pages and javascript.
Underscore.js - utility library for javascript
Install casper.js globally
$ npm install -g casperjs
Install underscore.js globally
$ npm install -g underscore
@zedar
zedar / CSSFontsRewriterResourceMapper.groovy
Last active August 29, 2015 13:57
Grails resources plugin - add custom resource mapper to map urls from css files that contain ? or # attributes.
import org.grails.plugin.resource.CSSLinkProcessor
import org.grails.plugin.resource.mapper.MapperPhase
/**
* This mapper is the second phase of CSS rewriting but for fonts references.
* Some fonts, like awesome, require attributes after the '?'.
*
* It finds any "resource:" URIs and then re-relativizes the absolute URI that follows it, using the final
* locations of all the resources now that all the other CSS-processing mappers have been applied.
*
@zedar
zedar / circularObjStringify
Last active August 29, 2015 14:00
JSON.stringify - workaround for "converting circular structure to JSON"
// Assume obj is an object with circular structure
var cache = [];
var str = JSON.stringify(obj, function(key, value) {
if (typeof value === "object" && value !== null) {
if (cache.indexOf(value) !== -1) {
return;
}
cache.push(value);
}
return value;
@zedar
zedar / FilteringSelectClass.js
Last active August 29, 2015 14:02
dojo FilteringSelect with cached entries
declare([
"dojo/_base/declare",
"dojo/store/JsonRest",
"dojo/store/Memory",
"dojo/store/Cache",
"dijit/form/FilteringSelect"
], function(declare, JsonRest, Memory, Cache, FilteringSelect) {
var _class = declare("FilteringSelectClass", null, {
createFileringSelect: function(domNode) {
var memoryStore = new Memory(),
@zedar
zedar / VagrantAndNginxAsProxy
Created July 16, 2014 12:22
Vagrant and nginx as proxy configuration
## Install vagrant:
* install virtualbox
* install vagrant
## Configure vagrant
$ mkdir vagrant
$ cd vagrant
@zedar
zedar / ratpackWithLog4J2.md
Last active March 2, 2021 03:50
ratpack & log4j2 basic configuration

Install ratpack

Ratpack is microservices framework written in Java but with very strong Groovy support. Ratpack is set of libraries. There are 2 main tools required for ratpack project: gradle and lazybones. Both could be installed with gvm (Groovy enVironment Manager).

$ gvm install gradle
$ gvm install lazybones

Create project structure with lazybones.

@zedar
zedar / ratpackRespondByContent.md
Last active August 29, 2015 14:05
ratpack respond by content

Ratpack handler with byContent response

Ratpack is a Java/Groovy framework for rapid development of microservices.

Define set of handlers in src/main/Ratpack.groovy. Define common prefix api for REST APIs.

import static ratpack.groovy.Groovy.groovyTemplate
import static ratpack.groovy.Groovy.ratpack
import org.slf4j.Logger

import org.slf4j.LoggerFactory

@zedar
zedar / ratpackWithRemoteJmx.md
Last active August 29, 2015 14:06
ratpack with remote jmx

Intro

To enable remote jmx monitoring across firewall it is necessary to pass following JVM arguments:

-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=5999
-Dcom.sun.management.jmxremote.local.only=false
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false

-Dcom.sun.management.jmxremote.rmi.port=5998

@zedar
zedar / ratpackGradleWatch.md
Last active July 18, 2019 13:53
ratpack gradle & watch for changes

Ratpack and runtime class reloading

Ratpack works very smoothly with spring-loaded library. It is defined as dependency in build.gradle file. Spring-loaded enables runtime hot class reloading.

dependencies {
    springloaded "org.springframework:springloaded:1.2.0.RELEASE"
}

But default configuration reloads only changes in Ratpack.groovy file.