(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| @Grab('org.codehaus.groovyfx:groovyfx:0.3.1') | |
| import static groovyx.javafx.GroovyFX.start | |
| final int ROW_COUNT = 10 | |
| final int COL_COUNT = 10 | |
| final int RADIUS = 20 | |
| final int DIAMETER = 2 * RADIUS | |
| final int MOVE_WAY = 8 * DIAMETER | |
| final int WIDTH = COL_COUNT * DIAMETER + MOVE_WAY | |
| final int HEIGHT = ROW_COUNT * DIAMETER |
| // Current way in Groovy | |
| @Immutable | |
| class Person { | |
| String firstName, lastName | |
| int age | |
| Date dateCreated | |
| } | |
| // But: This would be nice | |
| data class Person(String name, String lastName, int age, Date dateCreated) |
| ; /usr/local/bin/nasm -f macho 32.asm && ld -macosx_version_min 10.7.0 -o 32 32.o && ./32 | |
| global start | |
| section .text | |
| start: | |
| push dword msg.len | |
| push dword msg | |
| push dword 1 | |
| mov eax, 4 |
| /** | |
| * Copyright 2013 Kai Sternad | |
| * Licensed under the Apache License, Version 2.0 (the "License"); | |
| * you may not use this file except in compliance with the License. | |
| * You may obtain a copy of the License at | |
| * | |
| * http://www.apache.org/licenses/LICENSE-2.0 | |
| * | |
| * Unless required by applicable law or agreed to in writing, software | |
| * distributed under the License is distributed on an "AS IS" BASIS, |
| #!/usr/bin/env groovy | |
| /** | |
| * Demonstrates how to use Grape to grab dependencies for | |
| * Groovy scripts. | |
| * | |
| * Grape stands for the Groovy Adaptable (Advanced) Packaging Engine, and it is a part of the Groovy installation. | |
| * Grape helps you download and cache external dependencies from within your script with a set of simple annotations. | |
| * | |
| * If, in your script, you require an external dependency, that you know is available in a public repository as Maven Central Repository, |
| @Grab(group="org.neo4j", module="neo4j-kernel", version="2.0.1") | |
| @Grab(group="org.neo4j", module="neo4j-lucene-index", version="2.0.1") | |
| @Grab(group='org.neo4j', module='neo4j-jmx', version='2.0.1') | |
| import org.neo4j.graphdb.factory.GraphDatabaseFactory | |
| import org.neo4j.jmx.JmxUtils | |
| def db = new GraphDatabaseFactory().newEmbeddedDatabaseBuilder("/tmp/graph.db") | |
| .newGraphDatabase() | |
| println "started embedded graph db" |
| @Grab( 'com.typesafe.akka:akka-actor_2.10:2.3.2' ) | |
| @Grab( 'com.typesafe:config:1.2.0' ) | |
| import groovy.transform.Immutable | |
| import akka.actor.ActorRef | |
| import akka.actor.ActorSystem | |
| import akka.actor.Props | |
| import akka.actor.UntypedActor | |
| import akka.actor.UntypedActorFactory | |
| import akka.routing.RoundRobinRouter | |
| import scala.concurrent.duration.Duration |
| #!/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) |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| import java.security.* | |
| String password = "toto\n" | |
| MessageDigest sha1 = MessageDigest.getInstance("SHA1") | |
| byte[] digest = sha1.digest(password.getBytes()) | |
| System.out.println(new BigInteger(1, digest).toString(16)) |