Skip to content

Instantly share code, notes, and snippets.

View renatoathaydes's full-sized avatar

Renato Athaydes renatoathaydes

View GitHub Profile
@renatoathaydes
renatoathaydes / index.html
Created April 18, 2019 18:50
CheerpJ index.html file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>CheerpJ test</title>
<script src="https://cjrtnc.leaningtech.com/1.3/loader.js"></script>
</head>
<body>
</body>
<script>
use col = "collections"
use fmt = "format"
type Error is String
type Result is (F64 | Error)
type MaybeArray is (Array[F64] iso | Error val)
interface ReceiveUV
be receive(m: MaybeArray, a: Array[F64] iso)
@renatoathaydes
renatoathaydes / index.html
Last active February 9, 2019 22:19
Tic Tac Toe Game written in Dart. This is a clone of the game written in the React official tutorial: https://reactjs.org/tutorial/tutorial.html
<div id="errors" style="
background: #c00;
color: #fff;
display: none;
margin: -20px -20px 20px;
padding: 20px;
white-space: pre-wrap;
"></div>
<div id="root"></div>
<script>
@renatoathaydes
renatoathaydes / ScalaVSCeylon.scala
Last active October 17, 2018 08:29
Scala VS Ceylon
// This is a comparison between Scala and Ceylon based on this previous comparison I made between Haskell and Groovy:
// https://gist.github.com/renatoathaydes/5078535
// 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
@renatoathaydes
renatoathaydes / ClassicPostExecutionExample.java
Created January 14, 2018 17:32
HTTPComponents HTTPClient evolution
/*
* HTTPClient usage circa version 5.0-beta.
*/
package org.apache.hc.core5.http.examples;
import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.TimeUnit;
@renatoathaydes
renatoathaydes / HttpAsyncClientCreator.java
Created April 10, 2014 09:08
Creating and configuring a HttpAsyncClient
// more config options at http://hc.apache.org/httpcomponents-asyncclient-4.0.x/httpasyncclient/examples/org/apache/http/examples/nio/client/AsyncClientConfiguration.java
public RequestRunner provideRequestRunner( ComponentContext context, URI pageUri, Iterable<URI> assetUris )
throws IOException
{
try
{
IOReactorConfig ioReactorConfig = IOReactorConfig.custom()
.setIoThreadCount( Runtime.getRuntime().availableProcessors() )
.setConnectTimeout( 30_000 )
@renatoathaydes
renatoathaydes / keybase.md
Created September 27, 2017 16:38
Keybase - Renato Athaydes

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 / fixIntellijProject.groovy
Created June 16, 2016 07:05
Adds src/test/groovy as test sources to all projects under the current directory
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 / ThrownMatcher.java
Last active February 15, 2016 14:01
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
renatoathaydes / Bindables.ceylon
Last active December 30, 2015 07:09
Example of binding properties for 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);
}