Skip to content

Instantly share code, notes, and snippets.

function vrtest()
camera = null_surface(1, 1);
camtag_model(camera, 0.1, 100.0, 45.0, 1.33, 1, 1);
forward3d_model(camera, -10.0);
local cp = target_alloc("vrtest", function(source, status)
if (status.kind == "preroll") then
target_displayhint(source, 1024, 1024);
end
end);
@Happy-Ferret
Happy-Ferret / curses.js
Created December 31, 2017 22:31 — forked from adamnew123456/curses.js
A Small Javascript Library For Emulating Curses
/**
* An implementation of an API similar to ncurses, but which instead runs on
* HTMl5 canvas.
*
* Specifically, this is designed to duplicate the following elements of ncurses:
*
* - Basic text printing
* - Colors
* - Handling window hierarchies, which respect their parents bounds (so that
* drawing doesn't occur outside of a window's boundaries). They have their own
@Happy-Ferret
Happy-Ferret / Rust2018_post.md
Created January 7, 2018 10:49 — forked from cessen/Rust2018_post.md
#Rust2018 blog post

#Rust2018

This is my contribution to the call for Rust blog posts.

I've been using Rust for various personal projects for quite a while now, and I confess that I have a lot to say about it! In fact, I've already said quite a bit about it before.

My experience with Rust has been overwhelmingly positive, and most of the things I still want (e.g. NLL, const functions, const generic parameters, SIMD intrinsics, etc.) are already well known and being worked on, so it seems silly to repeat them. Therefore, in this post I'm just going to highlight three small-ish things that have been mildly frustrating to me over the last year, but which I haven't seen mentioned recently.

BidirectionalIterator trait

@Happy-Ferret
Happy-Ferret / webkitmediasource-is-type-supported.html
Created January 22, 2018 12:13 — forked from granoeste/webkitmediasource-is-type-supported.html
[JavaScript][HTML5][MediaSource] MediaSource.isTypeSupported
<!DOCTYPE html>
<html>
<head>
<script>
window.MediaSource = window.MediaSource || window.WebKitMediaSource;
function testTypes(types) {
for (var i = 0; i < types.length; ++i)
console.log("MediaSource.isTypeSupported(" + types[i] + ") : " + MediaSource.isTypeSupported(types[i]));
}
/**
* @constructs Printer
*/
function Printer(){};
Printer.prototype = {};
/**
* Returns if printer is local or network
* @returns {boolean}
*/
Printer.prototype.isLocal = function(){return true;};
// Have some complicated non-React widgets that manipulate DOM?
// Do they manage a list of DOM elements? Here's how to wrap it
// into a React component so you can "constantly rerender" it.
// A dumb non-react widget that manually manage some DOM node that
// represent a list of items
function NonReactWidget(node) {
this.node = node;
}
const React = require('react');
// Have some complicated non-React widgets that manipulate DOM?
// Do they manage a list of DOM elements? Here's how to wrap it
// into a React component so you can "constantly rerender" it.
// A dumb non-react widget that manually manage some DOM node that
// represent a list of items
function NonReactWidget(node) {
this.node = node;
@Happy-Ferret
Happy-Ferret / foo.js
Created February 16, 2018 07:21 — forked from jaredhirsch/foo.js
trying to shutdown + restart embedded webextensions without a restart
// 1. This seems to work. Is it safe to use?
const { EmbeddedExtensionManager } = Cu.import("resource://gre/modules/LegacyExtensionsUtils.jsm");
const webext = EmbeddedExtensionManager.getEmbeddedExtensionFor({id: '[email protected]'});
webext.shutdown();
webext.started = false;
webext.startup(); // throws no errors, toolbar button reappears, messaging works
// 2. This doesn't work:
const webext = EmbeddedExtensionManager.getEmbeddedExtensionFor({id: '[email protected]'});
webext.shutdown();
@Happy-Ferret
Happy-Ferret / implementing WebIDL in js.markdown
Created March 1, 2018 12:51 — forked from marcoscaceres/implementing WebIDL in js.markdown
Implementing a JS-based WebIDL binding in Gecko

Implementing a JS-based WebIDL binding in Gecko

This provides a gentle introduction to implementing a WebIDL interface in JavaScript. Once you are done, you can refer to the MDN Wiki, to add more advanced things.

Before you start

We would encourage you to first build a simple prototype version of your API in JS. Going through the process of creating a WebIDL is fairly straight forward, but if you screw it up you will need to recreate a whole bunch of files, etc. As such, it's much easier to make sure you have your API in a good state before attempting the steps below.

We know you will probably just skip ahead, but you'll soon find yourself here with us telling you, "I told ya so!" :)

Part 1 - Write the WebIDL

@Happy-Ferret
Happy-Ferret / README.md
Created March 9, 2018 17:01 — forked from dherman/README.md
How the ES6 Realm API makes it possible to create robust JS dialects

JS dialects with ES6 Realms

This essay explains how the ES6 Realm API makes it possible to create robust language abstractions that allow hooking into the behavior of eval, and how this can be used to implement different dialects of JavaScript.

Example scenario: Crock's "default operator"

Imagine we want to add Doug Crockford's ?? operator, which acts like a short-circuiting logical OR operator, except instead of checking truthiness, it returns the first argument's value if the first argument is any value other than undefined.

Since it makes everything simpler and cleaner, I'm going to assume I can use do-expressions for the implementation. (They're looking good for ES7!) So with that said, when we "crockpile" EXPR1 ?? EXPR2 we