Skip to content

Instantly share code, notes, and snippets.

View jimblandy's full-sized avatar

Jim Blandy jimblandy

View GitHub Profile

So you want to write an actor

Starting out with primitive types

So you have an idea for a Firefox developer tool. You (obviously) want it to work on Fennec and Firefox OS, so it needs to use the remote debugging protocol. You have a backend:

function SimpleBackend(target) { this.target() }

SimpleBackend.prototype = {

use std::str::FromStr;
use std::fmt::Debug;
use std::io::stdin;
use std::io::stdout;
use std::io::Write;
trait Game : Clone {
type Move : Copy + FromStr;
fn start() -> Self;
fn moves(&self) -> Vec<Self::Move>;
@jimblandy
jimblandy / foo.diff
Last active November 1, 2017 20:48 — forked from jasonLaster/foo.diff
modified src/utils/scopes.js
@@ -70,13 +70,14 @@ function getSourceBindingVariables(
return bound.concat(unused);
}
-export function getSpecialVariables(pauseInfo: Pause, path: string) {
- const thrown = get(pauseInfo, "why.frameFinished.throw", undefined);
-
- const returned = get(pauseInfo, "why.frameFinished.return", undefined);
+export function getFramePopVariables(pauseInfo: Pause, path: string) {
@jimblandy
jimblandy / playground.rs
Created November 27, 2017 00:29 — forked from anonymous/playground.rs
Rust code shared from the playground
#![allow(unused_variables)]
fn show_line(array: [bool; 80]) {
for i in 0..80 {
if array[i] {
print!("+");
} else {
print!(" ");
}
@jimblandy
jimblandy / playground.rs
Created November 27, 2017 00:54 — forked from anonymous/playground.rs
Rust code shared from the playground
#![allow(unused_variables)]
/// Given an array of `true` or `false` values (the type `bool`),
/// return a new array whose `i`'th element is true iff `array[i]`
/// and `array[i+1]` are different.
///
/// Rust numbers array elements starting with zero. Since `array` has 80
/// elements, its first element is `array[0]`, and its last element is
/// `array[79]`. The function's return value is similar.
///
@jimblandy
jimblandy / main.rs
Last active May 28, 2018 19:44 — forked from c0gent/main.rs
Glium - instancing over a vertex buffer slice
//! An example demonstrating that glium has a problem using instancing when
//! the vertex buffer is a slice with a non-zero starting index.
//!
#[macro_use] extern crate glium;
use glium::{glutin, Surface};
// Vertex Shader:
static VERTEX_SHADER_SRC: &'static str = r#"
#version 140