Skip to content

Instantly share code, notes, and snippets.

View stellaraccident's full-sized avatar

Stella Laurenzo stellaraccident

  • Amd
  • Seattle Washington, US
View GitHub Profile
@stellaraccident
stellaraccident / armor.js
Created January 23, 2011 16:36
Illustrate exception handling with a simple proxy middleware
/**
* Pattern for performing error handling given standard node
* callback patterns (ie. error passed as first argument).
*/
function Armorer(nextCallback) {
this.nextCallback=nextCallback;
this.cleanupCallbacks=[];
}
Armorer.prototype={
onCleanup: function(callback) {
@stellaraccident
stellaraccident / rcutil.ecmabackport.js
Created January 25, 2011 22:39
Some boilerplate JavaScript bits from otherwise not published sources
/**
* rcutil.ecmabackport.js
* Backport various new ecmascript functions to older runtime
* environments.
*/
(function() {
var _Object=Object, _FunctionPrototype=Function.prototype,
_Array=Array, _ArrayPrototype=_Array.prototype;
// Take advantage of old ecmascript defaults of the global
diff --git a/lib/http.js b/lib/http.js
index 9506a8c..73b507e 100644
--- a/lib/http.js
+++ b/lib/http.js
@@ -884,8 +884,18 @@ function httpSocketSetup(socket) {
}
-function Server(requestListener) {
- if (!(this instanceof Server)) return new Server(requestListener);
@stellaraccident
stellaraccident / proxy.js
Created February 15, 2011 20:31
connect style middleware to proxy requests to another server
/**
* Simple proxy intended to be used as middleware to direct parts
* of an HTTP namespace to other servers.
*
* Copyright (c) 2011, Stella Laurenzo
*/
var util=require('util'),
url=require('url'),
http=require('http'),
armor=require('./armor');
@stellaraccident
stellaraccident / armor.js
Created February 15, 2011 20:31
connect style middleware to proxy requests to another server
/**
* Pattern for performing error handling given standard node
* callback patterns (ie. error passed as first argument).
*/
function Armorer(nextCallback) {
this.nextCallback=nextCallback;
this.cleanupCallbacks=[];
}
Armorer.prototype={
onCleanup: function(callback) {
/**
* Implements the http protocol bindings for the session client api.
* All of the guts are actually passed down to a handler object that
* is passed in at construction time.
*/
var connect=require('connect');
function ClientApiHttp(handler) {
var pageRouter=connect.router(function(app) {
app.post('/registerUserAgent', handleRegisterUserAgent);
@stellaraccident
stellaraccident / control-block-http-example1.js
Created March 21, 2011 20:05
Bulletproof node coding snippets
request: function(options) {
var future=new Future();
var req=http.request(options, function(res) {
var text='';
res.setEncoding('utf8');
res.on('data', function(chunk) {
text+=chunk;
});
res.on('end', Block.guard(function() {
@stellaraccident
stellaraccident / runtests.js
Created March 22, 2011 00:22
My testrunner stub
#!/usr/bin/env node
require.paths.unshift(__dirname + '/local/lib');
process.chdir(__dirname);
var files=process.argv.slice(2).map(function(v) {
return v;
});
if (files.length===0) {
// Just run the whole directory
@stellaraccident
stellaraccident / full multi-layer-perceptron.mlir
Created January 27, 2020 19:43
examples of hlo granularity
module attributes {tf.versions = {bad_consumers = [], min_consumer = 12 : i32, producer = 293 : i32}} {
flow.variable @h1_bias mutable dense<[1.51671076, -1.03060472, 0.786281049, -0.111620337, 1.81119263, -0.489863962, -1.35557854, 1.12750614, -2.68010569, -1.31835032, 1.32360709, -0.169878066, -2.02759194, -1.08895075, 0.00321231596, -0.31182602]> : tensor<16xf32>
flow.variable @h1_weights mutable dense<[[-1.32382154, -0.549432516, 0.367527097, 0.727583051, -0.200104922, 0.803734958, 0.12167716, 1.32091141, -0.532794356, -0.784785628, -0.228998855, 0.517136097, -0.699431359, -0.73973155, 0.743836284, -0.946993887], [0.179826155, -0.49125874, -1.25974214, 1.15823603, -0.431264639, 0.251312494, -0.443345934, -2.01710749, 1.14093256, 0.719460964, -0.530746937, -2.79470325, -1.53676498, -1.249620e+00, 0.0132142669, -0.21497789], [1.0148958, -0.07205116, 0.406493574, -1.13559055, 0.363096684, 0.349495828, -1.05846632, 0.435198575, -0.0271317028, -0.122605741, -0.127589807, -0.243348598, -2.24777889, 0.65326
module attributes {tf.versions = {bad_consumers = [], min_consumer = 12 : i32, producer = 293 : i32}} {
flow.variable @h1_bias mutable dense<1.51671076> : tensor<16xf32>
flow.variable @h1_weights mutable dense<-1.32382154> : tensor<16x16xf32>
flow.variable @h2_bias mutable dense<-0.967021465> : tensor<16xf32>
flow.variable @h2_weights mutable dense<-2.13222814> : tensor<16x16xf32>
flow.variable @out_bias mutable dense<0.437576413> : tensor<10xf32>
flow.variable @out_weights mutable dense<-0.216886863> : tensor<16x10xf32>
func @predict(%arg0: tensor<?x16xf32>) -> tensor<?x10xf32> attributes {iree.module.export, iree.reflection = {abi = "sip", abiv = 1 : i32, sip = "I8!S5!k0_0R3!_0"}, tf._input_shapes = ["tfshape$dim { size: -1 } dim { size: 16 }", "tfshape$unknown_rank: true", "tfshape$unknown_rank: true", "tfshape$unknown_rank: true", "tfshape$unknown_rank: true", "tfshape$unknown_rank: true", "tfshape$unknown_rank: true"], tf.signature.is_stateful} {
%0 = xla_hlo.constant dense<0xFF800000>