Skip to content

Instantly share code, notes, and snippets.

Avatar

Renato Athaydes renatoathaydes

View GitHub Profile
@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 / Dockerfile
Created Jul 6, 2019
Minimalistic Docker image from a simple Dart application - includes only the AOT-compiled app and dartaotruntime.
View Dockerfile
FROM google/dart AS dartc
WORKDIR /app
ADD pubspec.* /app/
RUN pub get
ADD bin/ /app/bin/
ADD lib/ /app/lib/
RUN pub get --offline
RUN dart2aot /app/bin/main.dart /app/main.aot
@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)
@renatoathaydes
renatoathaydes / dart-null-safe-final-field-fail.dart
Created Nov 6, 2020
This fails to compile on line 18, but it should work because the field is final so the null check ensures the field can't be null
View dart-null-safe-final-field-fail.dart
// Welcome to the null safety version of DartPad!
// This site has a dev channel release of the
// Dart SDK with null safety enabled. You can
// play around with code of your own, or pick a
// learning exercise from the snippets menu at
// the top-right of this page.
void main() {
}
@renatoathaydes
renatoathaydes / Client.java
Last active May 17, 2020
Taking Project Loom for a spin
View Client.java
package loom;
import rawhttp.core.RawHttp;
import rawhttp.core.RawHttpRequest;
import rawhttp.core.RawHttpResponse;
import rawhttp.core.client.TcpRawHttpClient;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.CountDownLatch;
@renatoathaydes
renatoathaydes / JavaComparison.java
Last active May 4, 2020
Calculating a number from its constituent parts (encoded as ASCII bytes)
View JavaComparison.java
import java.nio.charset.StandardCharsets;
class JavaComparison
{
public static void main(String[] args)
{
System.out.println("CUSTOM");
for (int i = 0; i < 100; i++)
{
custom();
@renatoathaydes
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:
// http://learnyouahaskell.com/starting-out#ready-set-go
// 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.
/* HASKELL */
[ x*y | x <- [2,5,10], y <- [8,10,11]]
View main.dart
abstract class _State {
T use<T>(
T Function(_ChooseProviderState) useChooseProviderState,
T Function(_LoadingState) useLoadingState,
T Function(_ChooseAccountsState) useChooseAccountState,
T Function(_ImportingState) useImportingState) {
if (this is _ChooseProviderState) {
return useChooseProviderState(this);
}
if (this is _LoadingState) {
@renatoathaydes
renatoathaydes / index.html
Created Apr 18, 2019
CheerpJ index.html file
View index.html
<!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>