Skip to content

Instantly share code, notes, and snippets.


Renato Athaydes renatoathaydes

View GitHub Profile
renatoathaydes / util.js
Created Nov 3, 2012
Util JavaScript functions
View util.js
(function() {
var chars = "abcdefghijklmnopqrstuvxzwyABCDEFGHIJKLMNOPQRSTUVXZWY0123456789~`!@#$%^&*()-_=+{[}]|\\;:'\"<,>.?/";
* Get a random char according to the optionsl options given.
* @param options can be one of:
* <ul>
* <li><b>'alpha'</b>: only returns alphabetic chars</li>
* <li><b>'lowercase'</b>: only returns alphabetic chars</li>
renatoathaydes / createOsgiBluePrintProject.groovy
Created Feb 3, 2013
Creates a simple Osgi Blueprint Project using a Maven Archetype.
View createOsgiBluePrintProject.groovy
// Creates an empty OSGi Blueprint project using the Maven archetype
def MAVEN_HOME = 'C:/Program Files/Maven/apache-maven-3.0.3/bin'
def cli = new CliBuilder()
cli.with {
g args: 1, 'GroupId of the artifact being created'
a args: 1, 'ID of the artifact being created'
renatoathaydes / JavaFX in OSGi
Last active Mar 9, 2020
Packages needed by JavaFX 2.2 to work in OSGi
View JavaFX in OSGi
# Added the following extra packages to OSGI to enable JavaFX 2.2 (JRE 7 update 13)
# Extra packages appended after standard packages
org.osgi.framework.system.packages.extra=javafx.application;version=0.0.0, \
com.sun.browser.plugin; version=0.0.0, \
com.sun.deploy.uitoolkit.impl.fx; version=0.0.0, \
com.sun.deploy.uitoolkit.impl.fx.ui; version=0.0.0, \
com.sun.deploy.uitoolkit.impl.fx.ui.resources; version=0.0.0, \
com.sun.deploy.uitoolkit.impl.fx.ui.resources.image; version=0.0.0, \
View HaskellVSGroovy.groovy
// This is a comparison between Haskell and Groovy based on some simple problems found in the following
// Haskell Introduction:
// Ex 1. If we have two lists, [2,5,10] and [8,10,11] and we want to get the products of all the possible
// combinations between numbers in those lists, here's what we'd do.
[ x*y | x <- [2,5,10], y <- [8,10,11]]
renatoathaydes /
Created Apr 17, 2013
Converter of Arabic numbers to Roman numbers
import java.util.HashMap;
import java.util.Map;
public class RomanNumeral
private static final Map<Integer, String[]> romanCharsByDecimalPlace = new HashMap<Integer, String[]>()
put( 0, new String[]
renatoathaydes /
Last active Feb 15, 2016
ThrownMatcher is a Hamcrest matcher that can be used to verify a Throwable of a certain type has been thrown.
package com.athaydes.automaton.internal;
import org.hamcrest.Description;
import org.hamcrest.Factory;
import org.hamcrest.Matcher;
import org.junit.internal.matchers.TypeSafeMatcher;
* User: Renato
renatoathaydes / CheckGraphicsDeviceBounds.groovy
Last active Dec 26, 2015
Groovy script that prints information about the graphics devices currently in use.
View CheckGraphicsDeviceBounds.groovy
import java.awt.*
def virtualBounds = new Rectangle()
GraphicsEnvironment ge = GraphicsEnvironment.localGraphicsEnvironment
GraphicsDevice[] gs = ge.screenDevices
println Arrays.toString(gs)
gs.each { GraphicsDevice gd ->
GraphicsConfiguration[] gc = gd.configurations
renatoathaydes / ceylon-generics.ceylon
Created Nov 28, 2013
Playing with Ceylon generics.
View ceylon-generics.ceylon
shared void run() {
object mouseDownBus extends EventBus<MouseDown>() {}
object mouseUpBus extends EventBus<MouseUp>() {}
mouseDownBus.listen(void (MouseDown event) => print("1 - " + event.string));
mouseDownBus.listen(void (MouseDown event) => print("2 - " + event.string));
mouseUpBus.listen(void (MouseUp event) => print("3 - " + event.string));
renatoathaydes / Bindables.ceylon
Last active Dec 30, 2015
Example of binding properties for Ceylon.
View Bindables.ceylon
"A read-only property."
shared interface Property<out Prop> {
"Gets the value of this property."
shared formal Prop get;
"On change of the value of this property, the given function will be invoked."
shared formal void onChange(Anything(Prop) runOnChange);
View ScalaVSCeylon.scala
// This is a comparison between Scala and Ceylon based on this previous comparison I made between Haskell and Groovy:
// Ex 1. If we have two lists, [2,5,10] and [8,10,11] and we want to get the products of all the possible
// combinations between numbers in those lists, here's what we'd do.
/* SCALA */
for { x <- List(2,5,10); y <- List(8,10,11) } yield x*y