Skip to content

Instantly share code, notes, and snippets.

function extend(parent, child) {
child.prototype = Object.create(parent.prototype);
child.prototype.constructor = child;
child.prototype.super = parent;
return child;
}
@micahrj
micahrj / README.md
Last active August 29, 2015 14:10 — forked from dariusk/README.md

This Twine macro lets you use the Wordnik API to get random nouns and adjectives for your story.

See a demo in action here.

How to set it up

  • IMPORTANT FIRST STEP: you must have a Wordnik API key to use this! If you don't already have one, go here to register for an API key. If you do already have one, move on to the next step!
  • Paste the contents of the WordnikRandomWords.js file below into a new passage. Call the passage whatever you want, and add the tag "script" to it.
  • Modify the first line of the passage you just created so that instead of "var API_KEY = 'xxxxxxx'" you replace the x's with your actual API key you got from Wordnik.
@micahrj
micahrj / README.md
Last active August 29, 2015 14:10 — forked from dariusk/README.md

This Twine macro lets you use the Wordnik API to get random nouns and adjectives for your story.

See a demo in action here.

How to set it up

  • IMPORTANT FIRST STEP: you must have a Wordnik API key to use this! If you don't already have one, go here to register for an API key. If you do already have one, move on to the next step!
  • Paste the contents of the WordnikRandomWords.js file below into a new passage. Call the passage whatever you want, and add the tag "script" to it.
  • Modify the first line of the passage you just created so that instead of "var API_KEY = 'xxxxxxx'" you replace the x's with your actual API key you got from Wordnik.
I'm going to write this with a made-up assembly language just to keep things simple. Suppose we have some registers named a, b, and c. Suppose we have a command "set" that sets a register's contents:
set a, 3
Now a holds the value 3. And we have a command "add" that adds two things together and stores the result in the first one, and "mul", which does the same thing with multiplication:
add a, 2
Now a holds the value 5.
// motion_add(dir, spd):
vx += spd * cos(dir);
vy -= spd * sin(dir);
// setting speed to spd:
var current_speed;
current_speed = sqrt(vx*vx + vy*vy);
vx *= spd / current_speed;
var fs = require("fs");
var katex = require("katex");
function walk(dir) {
fs.readdir(dir, function(err, list) {
if (err) { console.log(err); return; }
list.forEach(function(file) {
var path = dir + "/" + file;
fs.stat(path, function(err, stat) {
use std::mem;
pub struct Arena {
data: Vec<Vec<u8>>,
next_size: usize,
}
impl Arena {
pub fn with_capacity(capacity: usize) -> Arena {
Arena {
@micahrj
micahrj / VkComputeSample.c
Last active May 13, 2019 21:52 — forked from sheredom/VkComputeSample
A simple Vulkan compute sample
// This is free and unencumbered software released into the public domain.
//
// Anyone is free to copy, modify, publish, use, compile, sell, or
// distribute this software, either in source code form or as a compiled
// binary, for any purpose, commercial or non-commercial, and by any
// means.
//
// In jurisdictions that recognize copyright laws, the author or authors
// of this software dedicate any and all copyright interest in the
// software to the public domain. We make this dedication for the benefit
HHH HHT HTH HTT THH THT TTH TTT
HHH 1 1 0 0 0 0 0 0
HHT 0 0 1 1 0 0 0 0
HTH 0 0 0 0 1 1 0 0
HTT 0 0 0 0 0 0 1 1
THH 1 1 0 0 0 0 0 0
THT 0 0 1 1 0 0 0 0
TTH 0 0 0 0 1 1 0 0
TTT 0 0 0 0 0 0 1 1