Skip to content

Instantly share code, notes, and snippets.

View renatoathaydes's full-sized avatar

Renato Athaydes renatoathaydes

View GitHub Profile
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 / create_github_pages_branch.sh
Created October 29, 2018 20:12
Use git worktree to maintain GitHub Pages branch
# Initialize a gh-pages branch... GitHub expects this branch to exist to publish a project website from it.
git checkout --orphan gh-pages
git reset --hard
git commit --allow-empty -m "Initializing gh-pages branch"
git push origin gh-pages
git checkout master
# Define a directory where the static website files will reside
WEBSITE_DIR=target
@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 / 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 / client.groovy
Last active June 16, 2021 12:18
HTTP Server / Client in 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 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 / nBody.ceylon
Last active August 29, 2015 14:19
Ceylon Solution for the n-body problem
/* The Computer Language Benchmarks Game
http://benchmarksgame.alioth.debian.org/
contributed by Renato Athaydes
*/
import ceylon.math.decimal {
decimalNumber,
@renatoathaydes
renatoathaydes / world.ceylon
Created April 1, 2015 22:46
The world modelled in 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() {}
@renatoathaydes
renatoathaydes / mortgage.groovy
Created February 16, 2015 20:07
Mortage calculator
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"