Skip to content

Instantly share code, notes, and snippets.

Avatar

Renato Athaydes renatoathaydes

View GitHub Profile
@renatoathaydes
renatoathaydes / keybase.md
Created Sep 27, 2017
Keybase - Renato Athaydes
View keybase.md

Keybase proof

I hereby claim:

  • I am renatoathaydes on github.
  • I am renatoathaydes (https://keybase.io/renatoathaydes) on keybase.
  • I have a public key ASD6izZl-Pe5lHzlFdjcZS6HjOG_pPWAkvLfZvAEo2Q9xwo

To claim this, I am signing this object:

@renatoathaydes
renatoathaydes / client.groovy
Last active Jun 16, 2021
HTTP Server / Client in Groovy
View client.groovy
/*
* This is a runnable groovy script.
* Run with "groovy client.groovy".
*
* Don't forget to start the server.groovy script first (shown in this gist).
*/
import groovy.transform.CompileStatic
import groovy.transform.Immutable
import groovy.transform.ToString
@renatoathaydes
renatoathaydes / fixIntellijProject.groovy
Created Jun 16, 2016
Adds src/test/groovy as test sources to all projects under the current directory
View fixIntellijProject.groovy
import groovy.io.FileType
import groovy.util.slurpersupport.GPathResult
import groovy.xml.XmlUtil
def intellijFileVisitor = { File intellijFile ->
def groovyDir = new File(intellijFile.parentFile, 'src/test/groovy')
if (groovyDir.isDirectory() && groovyDir.list()?.size() > 0) {
def module = new XmlSlurper().parse(intellijFile)
GPathResult sources = module.component.content.sourceFolder
def groovySources = sources.any { it.@url == 'file://$MODULE_DIR$/src/test/groovy' }
@renatoathaydes
renatoathaydes / nBody.ceylon
Last active Aug 29, 2015
Ceylon Solution for the n-body problem
View nBody.ceylon
/* The Computer Language Benchmarks Game
http://benchmarksgame.alioth.debian.org/
contributed by Renato Athaydes
*/
import ceylon.math.decimal {
decimalNumber,
@renatoathaydes
renatoathaydes / world.ceylon
Created Apr 1, 2015
The world modelled in Ceylon
View world.ceylon
abstract class Thing() {
string => className(this).split('.'.equals).last?.string else "";
}
abstract class World(shared Thing+ contents) {}
abstract class Ocean() extends Thing() {}
abstract class Land() of Continent|Island extends Thing() {}
View mortgage.groovy
totalValue = 4500000
pantbrev = 1534900
///////////////////////////////////
fromApt = 699500
lagFart = 0.015 * totalValue
toPay = 0.15 * totalValue + 0.02 * (Math.max(0, totalValue - pantbrev)) + lagFart
println "Total to pay $toPay"
@renatoathaydes
renatoathaydes / simpleMathsHelper.ceylon
Created Aug 25, 2014
Simple Maths helper program with between 1 and 3 inputs
View simpleMathsHelper.ceylon
String askUser(String question) {
process.write(question);
return process.readLine();
}
Float? askUserForNumber(String question) => parseFloat(askUser(question));
void printResult(Float(Float, Float=, Float=) operation, Float x, Float? y, Float? z) {
Float result;
if (exists y) {
@renatoathaydes
renatoathaydes / InstanceManager.java
Created May 25, 2014
Simple cloud instance manager based on jclouds
View InstanceManager.java
import org.jclouds.ContextBuilder;
import org.jclouds.compute.ComputeService;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.RunNodesException;
import org.jclouds.compute.domain.ComputeMetadata;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.domain.Template;
import org.jclouds.ec2.domain.InstanceType;
@renatoathaydes
renatoathaydes / simpleGroovlet.groovy
Created May 24, 2014
A groovlet that logs access and serves a simple HTML page
View simpleGroovlet.groovy
if (!session) {
session = request.getSession(true);
}
if (!session.counter) {
session.counter = 1
}
html.html {
head {
@renatoathaydes
renatoathaydes / webServer.groovy
Last active Mar 9, 2021
A simple web server written in Groovy that provides static and code-generated content
View webServer.groovy
#!/usr/bin/env groovy
import org.eclipse.jetty.server.Server
import org.eclipse.jetty.servlet.*
import groovy.servlet.*
@Grab(group='org.eclipse.jetty.aggregate', module='jetty-all', version='7.6.15.v20140411')
def startJetty() {
def server = new Server(8080)