Skip to content

Instantly share code, notes, and snippets.

View rob-blackbourn's full-sized avatar
💭
Trying to do a proper "Hello, World!" with wasm

Rob Blackbourn rob-blackbourn

💭
Trying to do a proper "Hello, World!" with wasm
View GitHub Profile
@rob-blackbourn
rob-blackbourn / Documents.py
Last active August 30, 2018 06:37
Create documents from meta classes
class Field:
def __init__(self, name=None, db_name=None, default=None, required=None, unique=None):
self.name = name
self.db_name = db_name
self.default = default
self.required = required
self.unique = unique
def to_mongo(self, value):
@rob-blackbourn
rob-blackbourn / README.md
Created June 10, 2015 15:19
Build ImageData from text art in Javascript

Overview

This code provides a simple example of how to build an ImageData object from text art that can be used in a canvas.

@rob-blackbourn
rob-blackbourn / README.md
Last active August 29, 2015 14:22
JavaScript Property Getters and Setters

JavaScript Property Getters and Setters

The attached code shows how to create getters and setters for a JavaScript object against the object prototype.

The example shows a situation where I want to store the underlying data (an RGBA colour) as an array, but wish to allow access throough getters and setters: i.e. colour.red = 255.

Running the example produces the following result:

@rob-blackbourn
rob-blackbourn / BufferExtension.md
Last active July 4, 2024 00:27
A C# linq extension to buffer an enumerable into an enumerable of enumerable blocks

Bufering in linq

static void Main()
{
    foreach (var block in "The quick brown fox jumped over the lazy dog".Split(' ').Buffer(4))
        Console.WriteLine(string.Join(" ", block));
}

The code takes the sentence "The quick brown fox jumped over the lazy dog", splits it into words, buffers it into blocks of four words, then writes each block of words joined by spaces.