Winter is clinging on this year
The blueberries which showed up in the mail will have to wait a few days in the greenhouse.
1186 Articles
[mejsvideo mp4=”http://ben.akrin.com/videos/rorschach_stream.mov.mp4″ ogg=”http://ben.akrin.com/videos/rorschach_stream.mov.ogv” webm=”http://ben.akrin.com/videos/rorschach_stream.mov.webm” poster=”http://ben.akrin.com/videos/rorschach_stream.mov.jpg” width=”640″ height=”360″]
[mejsvideo mp4=”http://ben.akrin.com/videos/the_power_of_one_pen_stroke_03.mov.mp4″ ogg=”http://ben.akrin.com/videos/the_power_of_one_pen_stroke_03.mov.ogv” webm=”http://ben.akrin.com/videos/the_power_of_one_pen_stroke_03.mov.webm” poster=”http://ben.akrin.com/videos/the_power_of_one_pen_stroke_03.mov.jpg” width=”640″ height=”360″]
We’ve had no wood reserves for 2½ months, what little left we had was consumed by the unexpected or trying to make starting fires quicker. It’s ok though we’ll be warm, fuel literally grows on trees. All it takes to harvest is a bit of exercise, a beautiful day doesn’t hurt.
Ash trees have a special place in our hearts given how many times they saved our bacon. It’s a shame they are getting ravaged by the emerald ash bore, what will the future ill-prepared homesteader do when their wood reserves don’t meet the tribute demanded by Winter?
Working my way up to the canopy
I was taught to not waste a branch, I moved the canopy elsewhere for later processing, for now I need the quick yield of the trunk
A fair amount for the time spent.
The subject matter of this post is controversial as it discusses extracting computing resources from the visitors of a website. There are a lot of discussions at the moment centered around web-browser based crypto currency mining. Most paint a deplorable picture of the practice; please keep in mind that there are very desirable paths alongside which these practices can develop. I am not elaborating on these arguments here, I am only describing a method to harness the resources.
Web browsers are becoming quite powerful for code execution. Between Javascript’s increase in capability, WebAssembly, access to GPU & threading, a web browser today is almost as desirable for computing as the machine it’s running on. Ever since the rise of web-based crypto currency miners, I’ve been thinking of harnessing all that computing power as a single entity: a super computer made of your visitor’s web browsers.
Just like a regular computer cluster, the nodes all participate in a coordinated fashion to solving a single problem. Unlike a regular computer cluster, the nodes are very ephemeral (as website visitors come and go) and can’t talk to each other (no cross site requests).
Here’s a demo of what I came up with:
Right: the super computer control server
Left: one of the web clients contributing to the super computer simply by being connected to a website (& CPU metrics)
[mejsvideo mp4=”http://ben.akrin.com/videos/transient_node_javascript_supercomputer.mov.mp4″ ogg=”http://ben.akrin.com/videos/transient_node_javascript_supercomputer.mov.ogv” webm=”http://ben.akrin.com/videos/transient_node_javascript_supercomputer.mov.webm” poster=”http://ben.akrin.com/videos/transient_node_javascript_supercomputer.mov.jpg” width=”640″ height=”360″]
The problem being solved here is the hashing of 380,204,032 string permutations to find the reverse of a given hash. Problem parameters were chosen to make heavy processing quick for the clients.
At the core of the idea is the websocket technology. It creates a persistent connection between a server and all of the nodes (the visitors of your website). This connection can be used to orchestrate actions between the nodes so that they can act as a concerted entity. From delivering the code to passing messages for coordination, websockets are what make everything possible.
Having a websocket connection to clients dramatically changes what you can do with web clients. They are fully addressable for the duration of their visit. They may show up on a website and be served some pre-established javascript; but with websockets, any javascript can materialize at any time.
Right: the super computer control server
Left: a web client being given an instruction on the fly
Slightly tangential but still worth considering, using a web view app, Javascript can pass execution to the app itself. This means code showing up on the websocket can escape the webview bubble and go into app land.
Right: the super computer control server
Left: a web app being given an instruction which percolates to the app layer
Now this is nothing new in a lot of ways; apps can be made to get instructions from C&Cs, and websites can get Javascript after the initial page load from dynamic sources. The websocket technique though is as dynamic as it gets (no Ajax pull), it is portable to many browsers and many devices, it is hard to catch looking at a web inspector; lastly, it executes with full access to the context it materialized in.
So we’ve established that websockets can be used to dynamically deliver code to be ran by the nodes. It can also be used for message passing and the overall orchestration of distributing the problem to be solved.
6 years ago I wrote a ditributed OpenMPI based password cracker: crackzor. Password cracking is a good distributed problem to solve because it’s a fairly simple problem: run through all the character permutations. The fact that it exhausts a known space also means benchmarking is easy. So to put the idea of a transient node javascript super computer in practice, I rewrote crackzor in JS instead of C, and for websockets instead of OpenMPI.
Every distributed problem is different and crackzor itself isn’t a magic way to distribute any problem to be solved. The magic of crackzor is its ability, given a space of character permutations, to divide it up in chunks which can be processed by the nodes. Given the problem, a start iteration and end iteration, a node can get to work without having to be provided the permutations themselves, thus removing the bandwidth bottleneck.
Javascript runs single threaded by default, so when the websocket sends code to be ran by a client, by default, the code running as fast as it can will only be able to fill one core of the CPU. A large majority of machines today have many more cores available. So we have to figure out how to use them or our super computer is going to loose a large portion of its processing power right off the bat.
Web workers to the rescue. With HTML5, it’s easy as pie to thread code. The one trick with the code we want to thread is that it can’t be gotten from a file as the web worker documentation suggests. That’s because our code doesn’t come from a static javascript file remember? It shows up out the the blue on the websocket, so it came from the network and is now in memory somewhere => not a file we can refer to.
The solution is to wrap it in a blob as such
[code language=”js”]var worker_code = ‘alert( "this code is threaded on the nodes" );’
window.URL = window.URL || window.webkitURL;
var blob;
try {
blob = new Blob([worker_code], {type: ‘application/javascript’});
} catch (e) {
window.BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder;
blob = new BlobBuilder();
blob.append(worker_code);
blob = blob.getBlob();
}
workers.push( new Worker(URL.createObjectURL(blob)) ) ;[/code]
Here you’ll notice we have our first layer of encapsulation. The code relevant to the problem we are solving is in the variable worker_code, the rest of the javascript only threads it.
Having distributed amongst a node’s cores, we now look at
This work is obviously up to the websocket server along with subsequent coordination. Without going into too much details, the websocket server keeps track of all the nodes as they come and go, it also keeps track of which ones are working or not, allocates new chunks of the problem to nodes as they become available.
A trick of the websocket server is that it is running at all times to handle node connections. Super computer problems however may change from one day to the next. To address that, I give it a function which reads a file and evals its code; the function is summoned by a process signal. As such:
[code lang=”js”]function eval_code_from_file() {
if( !file_exists("/tmp/code") ) {
console.log( "error: file /tmp/code does not exist" ) ;
} else {
var code = read_file( "/tmp/code" ) ;
code = code.toString() ;
eval( code ) ;
}
}
process.on(‘SIGUSR1’, eval_code_from_file.bind() );[/code]
With this puppy in place, the next time I “kill -USR1 websocket_server_PID”, it will be imbued with new code that did not exist when it started. Does this sound familiar? Yup, javascript is super interesting in the ability it gives you to run arbitrary code at any time with full access to the established context.
Thus arrive the 2nd and 3rd layers of encapsulation, the code which will be distributed to the nodes is in a file which is to be evaled on the websocket server side and sent over the websocket to the clients.
The actual distribution to the nodes is simple, have them connect with a callback to eval code. Something like that:
Client:
[code lang=”js”]var websocket_client=io.connect("http://websocket_server.domain.com") ;
websocket_client.on( "eval_callback",function(data){data=atob(data),eval(data)}.bind() ) ;[/code]
Server:
[code land=”js”]client_socket.emit( "eval_callback", new Buffer("alert(‘this code will run on the client’);").toString("base64") ) ;[/code]
So…
all the pieces you need to make a super computer from your web traffic. I’m choosing not to publish the full code of my implementation for reasons of readability, security and complexity but I can go into more details if asked.
The same way that peer-to-peer protocols made any data available anywhere any time, could this do the same for computing power? Mind=blown, and your CPU along with it.
Very intense 2 months coding marathon to bring into the world the new version of Mandalagaba.


I completely rewrote the symmetry engine to be universal. When I coded the first version, I only wanted to scratch a specific radial symmetry itch and had to expand on narrowly conceived code to accommodate for features that came up from the tool’s success. With this new version, I instead gave myself a broad framework built for expansion, I can translate any penstroke at any angle in any location. Beyond mandalas, it makes possible tessellations and even the 2 combined.

I used the opportunity to add many features which were lacking: zooming, forking, lines, color picker, et cetera. With many more to come. The interface was rethought to be more accessible. Doing so took much more time than building the core engine.
There is an obscene amount of math that goes behind every pen stroke you draw in the tool. It was kind of fun to go through it again in my life, 20 years later. Even though I had forgotten about it all, it came back nicely. It’s amazing to have the internet as a tool to look up methods, to be able to describe the problem in plain English and have potential solutions thrown at you. It used to be that you needed to know what you needed precisely to find it in a book.


I love that Robin copies what I do no matter the understanding level, we’ve had lots of talks about what is going on.

It’s not just the math but also algorithms, languages & infrastructure. Not to toot my own horn but in my 30s, I’ve never felt so intimate with every aspect of an idea’s implementation. It’s extremely enabling to know exactly where to go to achieve X. Honestly though I’m a little burnt out at the moment, something that was supposed to take 10 days took more than 2 months of coding every single night.
My hope is that the new tool becomes a reference online for this type of work. And it’s all 100% free; well… we’ll talk about that in the next post.
Lower tech fun found in a thrift shop
I always wondered why the solar array never produced more than 30A, especially after I added 3 more panels to it. Well, I got my answer yesterday when the array took an unexpected dive.

I had forgotten that the amperage sensors I got back in 2015 are only rated for 30 Amps, way overkill at the time :). So it’s entirely possible the array was producing more and I simply wasn’t able to “see” it. Also, the extra panels pushed the sensor over the edge and fried it.

I put in the order for new sensors rated for 100A, it will be interesting to see what the graphs look like. Their design also makes it so if they fail, the production won’t be impacted because they aren’t part of the circuit.
It’s surprisingly difficult to find such sensors rated for high amperage. Phidgets are expensive but they pretty much have the only industrial IOT sensors. In my experience they are robust and easy to deploy thanks to great documentation & code samples.
We’ve been dealing with a brutal cold stretch which is most definitely testing our limits. The timing isn’t great, after a Summer of construction and an addition to the family in October, our wood reserves aren’t exactly plentyful.
A few days ago, I came to the realization that at the pace we are burning wood, we only had 10 days of reserves left.
I thus decided we would not use this pile any more, keeping it available for the unexpected; we will instead produce wood as we burn it. I had 2 ash trees picked out since the Summer, they didn’t look too good, and they’re close to the house, they’d be perfect to finish the Winter. I didn’t realize they’d only help us start it. And so I went after them in the best temperatures this cold stretch had to offer, which were still quite low and made for some very tough work. I also grabbed a couple of dead poples while I was out there but they don’t burn as good as ash when green.
The morning routine now consists of splitting 2 sleds worth of wood, which covers 24 about hours.
We folded back into the tiny house to make heating easier, it’s not too chaotic but we do miss the extra room.
The green house is incredible and turns a little bit of sunlight into non-freezing temperatures.
Building it around the well’s pitcher pump was an incredibly smart move.
The snow and the wind also take jabs at us, really it’s been one thing after another. Equipment is reaching its limit. I suspected that the tractor’s battery would be dead at some point, and so I thought I’d jump it with the ATV. What I wasn’t counting on was that the wind would push the snow back on the paths I had plowed, making it very difficult to get close to the tractor to do so. I had the unexpected planned for, not the doubly unexpected.
The cars also make funny noises and smells with such temperatures, anything mechanical is taking a beating. So is my body which does not get a single day without unforgiving chores outside.
The solar array batteries barely function as they are frozen, we’ll want them in a milder environment later on.
The porcupine is undeterred by the cold and still sets out every night for its routine. It picked a different tree this season and seems to like some of the paths I made.
A friend gave us an aloe plant a while back, and I never paid much attention to it. Today though, we opened it up and rubbed some of the magical goo on our hands. It felt amazing and it’s nice to feel something other than biting cold, logs and hot stoves every once in a while.
We reached the lowest temperature since we moved to the land on January 2nd.
So here we are, one tough stretch reaching extremes and pushing all our limits. It’s ok though, I enjoy getting tested by the elements, this is what drives me outside during a storm. Still, we’ll be very relieved in a few days when we get to catch our breaths. We’ve learned a few good lessons along the way.