Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View nathan's full-sized avatar

Nathan nathan

View GitHub Profile
@nathan
nathan / earley.js
Last active August 29, 2015 13:56
Earley parser
function T(s) {return {terminal:s}}
function S(n, c, i, k, d) {return {name:n, content:c, index:i, position:k, node:d}}
var productions = {
start: [['stmts']],
stmts: [
['stmts', T(';'), 'stmts'],
['s', 'stmt', 's']],
stmt: [
[T('{'), 'stmts', T('}')],
@nathan
nathan / parse.js
Last active August 29, 2015 13:56
Earley parser
~ function(exp) {
function Rule(name, symbols, postprocess) {
this.name = name;
this.symbols = symbols;
this.postprocess = postprocess || function(a){return a};
}
Rule.prototype.getStartState = function(location) {
return new State(this, 0, location);
}
function State(rule, expect, reference) {
@nathan
nathan / featured.js
Created February 21, 2014 02:19
Get the most recent featured Scratch project with stat
@nathan
nathan / good.sh
Created February 21, 2014 20:29
su
rm -']
r
@nathan
nathan / load.js
Last active August 29, 2015 14:04
CORS does not apply here
var s = document.createElement('script');
s.src = 'http://dl.dropboxusercontent.com/u/10715865/Temp/new.js';
document.head.appendChild(s);
@nathan
nathan / CHANGES.md
Last active August 29, 2015 14:04
Pretty (annoying) v421 changelist
Commit Summary
7e5352c Now reading in the ghost value properly in 3d mode
18ab642 Prevent using special names (e.g., mouse) as sprite names
1441354 Fixing potential null reference exception
c845ce4 Fix picking color from editor background yielding black instead of white
3d274ca Fix costume center for empty costumes
7db32b9 Prevent copying procedure declaration blocks
6495d93 Fix watcher not updating to reflect certain changes
acd1d19 Clarifying update to README
@nathan
nathan / CHANGES.md
Last active August 29, 2015 14:04
Changelogs for each release of the Scratch editor.

v425

Bug fixes

  • Remove "beta" from offline editor
  • Use less memory when parsing paths
  • Subtract tips width from content area

v424

Features

@nathan
nathan / project.xml
Last active August 29, 2015 14:04
Repaired Snap! project
<snapdata><project name="big project" app="Snap! 4.0, http://snap.berkeley.edu" version="1"><notes></notes><thumbnail>data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAAB4CAYAAAB1ovlvAAAIEklEQ%E2%80%A6ac6gAAdKr9WBwAggGnOgAAnWo/FgeAYMCpDgBAp9qPxf8DmNNJ1XYx88YAAAAASUVORK5CYII=</thumbnail><stage name="Stage" width="480" height="360" costume="0" tempo="60" threadsafe="false" lines="round" codify="false" scheduled="false" id="1"><pentrails>data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAeAAAAFoCAYAAACPNyggAAAOhUlEQ%E2%80%A6ABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQIHLFxAWmhEwHPAAAAAElFTkSuQmCC</pentrails><costumes><list id="2"></list></costumes><sounds><list id="3"></list></sounds><variables></variables><blocks></blocks><scripts></scripts><sprites><sprite name="Sprite6" idx="4" x="234.99999999999955" y="50.00000000000006" heading="90" scale="1" rotation="1" draggable="true" costume="0" color="155.54999999999998,65.331,0" pen="tip" id="8"><nest anchor="Sprite2" synch="true"/><costumes><list id="9"></list></costu
@nathan
nathan / export.js
Last active August 29, 2015 14:04
Exporting things
var indent = '';
function mdify(els) {
if (els.length) return [].map.call(els, mdify).join('\n');
if (els.tagName === 'P' || els.tagName === 'LI') return els.textContent;
if (els.tagName === 'UL') {indent += ' '; return '* ' + [].map.call(els.children, mdify).join((indent = indent.slice(4), '\n' + indent + '* '));}
return '';
}
copy([].slice.call(document.querySelectorAll('tr')).reverse().map(function(tr) {
return '# v' + tr.querySelector('td:first-child').textContent.trim() + '\n\n' + mdify(tr.querySelector('td:last-child').children);
}).join('\n\n').replace(/\* \* /g, ' * ').replace(/[“”]/g, '"'));
@nathan
nathan / broken.js
Created July 29, 2014 19:29
Find broken PNG assets in a project.
var all = document.body.innerText.match(/\w{32}\.png/g);
var broken = [];
all.forEach(function(a) {
var xhr = new XMLHttpRequest;
xhr.open('GET', 'http://cdn.scratch.mit.edu/internalapi/asset/'+a+'/get/', false);
xhr.send();
if (/^<svg/.test(xhr.responseText)) {
broken.push(a);
console.log('http://cdn.scratch.mit.edu/internalapi/asset/'+a+'/get/');
}