Skip to content

Instantly share code, notes, and snippets.

Dale Lane dalelane

Block or report user

Report or block dalelane

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@dalelane
dalelane / scratch-coordinate-sums.js
Last active Jul 21, 2019
Converting from Scratch's coordinates to the HTML canvas
View scratch-coordinate-sums.js
// assumptions about the Scratch coordinate system
var SCRATCH_CANVAS_TOP = 180;
var SCRATCH_CANVAS_LEFT = -240;
var SCRATCH_CANVAS_RIGHT = 240;
var SCRATCH_CANVAS_WIDTH = SCRATCH_CANVAS_RIGHT - SCRATCH_CANVAS_LEFT;
// where is the top-left corner of the sprite we're interested in?
var costume = targetSprite.getCurrentCostume();
var scratchX = targetSprite.x - costume.rotationCenterX;
var scratchY = targetSprite.y + costume.rotationCenterY;
View schema14.avsc
{
"type": "record",
"namespace": "co.uk.dalelane",
"name": "Type14",
"fields": [
{
"name": "something",
"type": "string"
}
]
View Example.java
Type13 myThing = new Type13();
myThing.setMyWord("diabolical");
View Example.java
LogicalTypes.register(WordsThatStartWithD.PROPERTY_NAME,
new WordsThatStartWithD.TypeFactory());
View WordsThatStartWithD.java
import org.apache.avro.LogicalType;
import org.apache.avro.LogicalTypes.LogicalTypeFactory;
import org.apache.avro.Schema;
public class WordsThatStartWithD extends LogicalType {
public static final String PROPERTY_NAME = "words-that-start-with-D";
private static final String INVALID_TYPE = "Logical type 'words-that-start-with-D' must be strings";
@dalelane
dalelane / schema13.avsc
Last active Jul 20, 2019
Example of an Avro schema - used in https://dalelane.co.uk/blog/?p=3781
View schema13.avsc
{
"type": "record",
"namespace": "co.uk.dalelane",
"name": "Type13",
"fields": [
{
"name": "myWord",
"type": {
"type": "string",
"name": "WordThatStartsWithD",
View Example.java
Type12 myThing = new Type12();
myThing.setPreciselyWhenItHappened(System.currentTimeMillis());
@dalelane
dalelane / schema12.avsc
Last active Jul 20, 2019
Example of an Avro schema - used in https://dalelane.co.uk/blog/?p=3781
View schema12.avsc
{
"type": "record",
"name": "Type12",
"namespace": "co.uk.dalelane",
"fields": [
{
"name": "preciselyWhenItHappened",
"type": "long",
"logicalType": "time-millis"
}
View Example.java
Type10 myThing = new Type10();
myThing.setWhenItHappened(LocalDate.now().toEpochDay());
@dalelane
dalelane / schema10.avsc
Last active Jul 20, 2019
Example of an Avro schema - used in https://dalelane.co.uk/blog/?p=3781
View schema10.avsc
{
"type": "record",
"name": "Type10",
"namespace": "co.uk.dalelane",
"fields": [
{
"name": "whenItHappened",
"type": "long",
"logicalType": "date"
}
You can’t perform that action at this time.