Skip to content

Instantly share code, notes, and snippets.

View renatoathaydes's full-sized avatar

Renato Athaydes renatoathaydes

View GitHub Profile
@renatoathaydes
renatoathaydes / simpleMathsHelper.ceylon
Created August 25, 2014 20:36
Simple Maths helper program with between 1 and 3 inputs
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 08:50
Simple cloud instance manager based on jclouds
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 11:44
A groovlet that logs access and serves a simple HTML page
if (!session) {
session = request.getSession(true);
}
if (!session.counter) {
session.counter = 1
}
html.html {
head {
@renatoathaydes
renatoathaydes / webServer.groovy
Last active October 23, 2023 15:28
A simple web server written in Groovy that provides static and code-generated content
#!/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)
@renatoathaydes
renatoathaydes / updateAll.groovy
Last active August 29, 2015 14:01
Update all Saas projects
//#!/usr/bin/env groovy
// Change this to your projects home
home = "D:/Programming/Projects"
// Change this to where your Maven installation is located
mvn = "C:/Program Files (x86)/Maven/apache-maven-3.0.4"
if ('help' in args || 'h' in args) {
println """
{
"results": [
{
"max": 1245,
"min": 1245,
"count": 3352,
"variable": "responseSize",
"resource": "http://win-srvmontest.sthlm.smartbear.local/welcome.png",
"average": 0
},
{
"results": [
{
"resource": "http://win-srvmontest.sthlm.smartbear.local/welcome.png",
"minLatency": 1,
"maxLatency": 2,
"averageLatency": 1,
"percentile90thLatency": 2,
"minTimeElapsed": 1,
"maxTimeElapsed": 9,
@renatoathaydes
renatoathaydes / treeMapPrinter.ceylon
Last active August 29, 2015 14:01
Prints a TreeMap in an easy-to-see what's going on way. This code must be pasted inside TreeMap code.
void traverse(Integer level, Node node, MutableMap<Integer, MutableList<Node>> nodes) {
value list = nodes[level] else ArrayList<Node>();
nodes.put(level, list);
list.add(node);
if (exists l = node.left) {
print("Left of ``node.key`` is ``l.key``");
traverse(level + 1, l, nodes);
}
if (exists r = node.right) {
// no assets
{
"results": [
{
"sent": ${sent},
"averageTimeElapsed": ${avgTe},
"minTimeElapsed": ${minTe},
"maxTimeElapsed": ${maxTe},
"averageLatency": ${avgLatency},
{"timestamp":1398694754046,"source":"main","variable":"sent","total":0,"perSecond":0}
{"timestamp":1398694754049,"resource":"http://win-srvmontest.sthlm.smartbear.local","source":"main","variable":"sent","total":0,"perSecond":0}
{"timestamp":1398694754477,"resource":"http://win-srvmontest.sthlm.smartbear.local/welcome.png","source":"main","variable":"sent","total":0,"perSecond":0}
{"timestamp":1398694754494,"source":"main","variable":"timeElapsed","count":1,"average":445,"min":445,"max":445,"percentile90th":445}
{"timestamp":1398694754504,"source":"main","variable":"responseSize","count":1,"average":0,"min":0,"max":0,"percentile90th":0}
{"timestamp":1398694755047,"resource":"http://win-srvmontest.sthlm.smartbear.local","source":"main","variable":"timeElapsed","count":2,"average":42,"min":5,"max":80,"percentile90th":72}
{"timestamp":1398694755055,"resource":"http://win-srvmontest.sthlm.smartbear.local","source":"main","variable":"responseSize","count":2,"average":689,"min":689,"max":689,"percentile90th":689}
{