Skip to content

Instantly share code, notes, and snippets.

@jlewin
jlewin / findManifestsWithResourceDefs.cs
Created October 17, 2013 08:04
Find .manifest files containing resource definitions
foreach(string file in File.ReadAllLines(@"E:\src-ext\moz\mozilla-central\manifestFiles.txt")) {
string contents = File.ReadAllText(file);
if ( contents.IndexOf("resource ") != -1 ) {
Console.WriteLine(file);
}
}
@jlewin
jlewin / parseThreeJSHelpPage.js
Created October 22, 2013 21:47
Early attempts at parsing three.js help docs to JSON for tooling
var breadCrumb = document.body.firstChild;
var context = document.body.firstElementChild;
var info = {};
var state = 'loading';
var current = '';
var container;
while(context) {
switch (context.nodeName) {
@jlewin
jlewin / validateThreeJSHelpDoc.js
Last active December 26, 2015 06:38
Early attempts at validating three.js help docs from extracted JSON
var helpDocs = {};
helpDocs['MeshBasicMaterial'] = info;
var types = {
'number': 'number',
'Integer': 'number',
'Float': 'number',
@jlewin
jlewin / findThreeNS.js
Created October 24, 2013 21:13
Find all Three.js references in a given file
var re = /(\.call|\.prototype|\.apply)/g;
var mx = {};
// Match THREE.xxx * [^ \s or ( or $]
document.body.innerHTML.match(/THREE\.[^\s\($]*/g).forEach(function(s){
// Drop proto, call, apply, etc
mx[s.replace(re, '')] = null;
});
@jlewin
jlewin / node_indexThree.js
Created October 25, 2013 14:01
Index Three.js source mapping type usage to files
var find = require('findit');
var path = require('path');
var fs = require('fs')
var timerName = 'Elapsed Time';
// Start timer
console.time(timerName);
// Add some spacing after command line
$('.wikitable tr').each(function(x){
if(this.cells[1].innerText != 'US') {
$(this).hide();
}
}); '' // Do not output results;
@jlewin
jlewin / AsyncWrite.cs
Created March 21, 2014 17:37
A set of Xunit tests to expose an issue in Biggy
using System;
using System.IO;
using System.Net;
using Xunit;
namespace Tests.JSON
{
/// <summary>
/// The current use of WriteAsync results in failed writes to disk and hopefully these examples depict that behavior
/// </summary>
@jlewin
jlewin / AsyncAwaitWrite.cs
Created March 21, 2014 19:35
Using await to resolve concurrency issues in Biggy
using System;
using System.IO;
using System.Net;
using System.Threading.Tasks;
using Xunit;
namespace Tests.JSON
{
/// <summary>
/// The current use of WriteAsync results in failed writes to disk and hopefully these examples depict that behavior
@jlewin
jlewin / json.gen
Created March 27, 2014 19:31
JSON generation template for http://www.json-generator.com/
[
'{{repeat(12000)}}',
{
id: '{{index}}',
guid: '{{guid}}',
age: '{{numeric(20,40)}}',
name: '{{firstName}} {{surname}}',
gender: '{{gender}}',
company: '{{company}}',
email: '{{email}}',