Skip to content

Instantly share code, notes, and snippets.

// Read parameter from widget
let parameter = args.widgetParameter
var parameters = "";
if (parameter) parameters = parameter.split(";")
else
{
// If no parameters were found, ask the user to put them
let w = new ListWidget()
error = w.addText("Introduce tu cuenta y token de IndexaCapital separados por un ; en la configuración del Widget")
error.font = new Font("Avenir-Book", 11)
@deigote
deigote / string-human-to-camel.scala
Last active October 22, 2020 19:43
Transform a human friendly string to camel case in Scala
def humanToCamel(original: String): String =
original
.foldLeft(("", true)) {
case ((acc, upper), e) => (if (e == ' ') acc else if (upper) acc + e.toUpper else acc + e, e == ' ')
}
._1
@deigote
deigote / groovy
Last active August 29, 2015 14:26
Hibernate criteria: Wrong results when join + pagination
class Car {
static hasMany = [brands: Brand]
}
class Brand { }
class CarService {
def searchCars(int firstResult, int maxResults) {
Car.createCriteria().list {
createAlias('brands', 'brands', CriteriaSpecification.INNER_JOIN)
@deigote
deigote / GrailsHibernateSimpleDomainClassPropertyEditor.groovy
Last active August 29, 2015 14:04
Grails - Simple domain class property editor
public class DomainClassLookupPropertyEditor extends PropertyEditorSupport {
Class domainClass
String property
Boolean doAssert = true
String getAsText() {
value."$property"
}
@deigote
deigote / GrailsHibernateSafeDomainClassPropertyEditor.groovy
Last active August 29, 2015 14:04
Grails - Hibernate-safe domain class property editor
import static org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsHibernateUtil.unwrapIfProxy
public class DomainClassLookupPropertyEditor extends PropertyEditorSupport {
Class domainClass
String property
Boolean doAssert = true
String getAsText() {
value."$property"
@deigote
deigote / ExpandoWithDelegate.groovy
Created June 10, 2014 14:17
Groovy - ExpandoWithDelegate
class ExpandoWithDelegate {
private delegate
private Map<String, Closure> mockedMethods
ExpandoWithDelegate(delegate) {
this.delegate = delegate
this.mockedMethods = [:]
}
@deigote
deigote / groovy_closure_params_generics.groovy
Created May 30, 2014 10:24
Trying to use type checked closures in Groovy, including their parameters
private static File findOuputFile() {
this.<File>logAndReturn('info', { File outputFile -> "Using '$outputFile' as output file" }) {
new File("${System.getProperty('outputDir')}/memolo.html")
}
}
private static <O> O logAndReturn(
String logLevel,
@ClosureParams(ThirdParam.FirstGenericType.class) Closure<String> stringMessageGenerator,
Closure<O> resultProducer
@deigote
deigote / add-fish-modules-as-git-submodule.sh
Created May 19, 2014 17:18
Adding fish-modules as a submodule of your fish config repo
cd $HOME/.config/fish
git submodule add git@github.com:deigote/fish-modules.git fish-modules
git ci fish-modules .gitmodules -m 'Added fish-modules as a submodule for convenience'
@deigote
deigote / config.fish
Created May 19, 2014 17:17
Making your fish modules available to each fish shell with fish-modules
# Some other fish configuration goes here
# Fish modules
source $HOME/.config/fish/fish-modules/add_modules_to_path.fish
@deigote
deigote / update-fish-modules.sh
Created May 19, 2014 17:16
Updating your fish modules when using fish-modules
~/.config/fish/fish-modules/update_modules.fish