2013

Finally!

I'm getting around to getting my blogging system working. It's only taken a few hours work and I can show basic posts, and tags. I've been "getting around to it" for years, though it wasn't really causing me enough anxiety to be called procrastination.

I have been wanting a place to post things; results of technical experiments, rants when "someone is wrong on the internet", musings, whatever. I think I'm a bit old-fashioned; my main place for writing is in my daybook, which no-one ever sees but me. If anything I can write might help someone else, then so much the better.

Details

The site is running node.js, so the blog is just an extension to the node server, which loads some markdown files representing the posts into memory, and runs them through a markdown processor for display. The posts can be created in my usual text file daybook, tagged "blog" then I can call a function to turn that into a file. Tags can be put anywhere in the post, but will probably go at the bottom.

Next up will be to get chronological navigation working, and get the posts returned 5 or so at a time, rather than singly. And rss.

The tags are on a line above this one. There can even be multiple tag lines in a document. Not sure why that would be useful.

Tags: musings, system, testing

Date created: 2013-01-12

Mixed Letters

I've added a new little app called Mixed Letters to the Lab.

It's simple, but it does what it's supposed to.

The program was a good exercise in learning about iPad touch events and css animations and transforms. It was also good practice for event listeners. And I'm eschewing jquery for a change -- great library, but I'm not doing anything that needs it.

My confusion about function references

For some reason, I thought that in yada.addEventListener("event",function) if you wanted to pass arguments you had to do it through an anonymous function So I was doing:

obj.addEventListener("click",function(e){realfunction(e);});

Now I'm doing:

obj.addEventListener("click",realfunction});

where realfunction is defined to take arguments

function realfunction(e)...

I was conflating the reference to a function with its definition (like c++'s function signatures and prototypes iirc). Of course, in javascript, you don't have to define the arguments in the function definition at all, you can use the arguments array within the function.

A better way of thinking about it, which separates the reference/name and the definition with arguments might be (ignoring differences between statements and function expressions):

var realfunction = function(e)...

And I may as well note that the following is completely fine in javascript-- the external reference can be distinct from how the function knows itself; which may be handy if I ever need a 2nd order function to pass back a recursive function:

var realfunction = function anothername(e)...

Event binding in revealing module

Also, I tend to favour the revealing module pattern:

var app=(function(){
    ...
return {
    fn:fn,
    fn2:fn2
    };
}());

I've sometimes had issues in that some page initialisation done inside the function needs access to the functions that are hidden, so I have to expose them in the return object. Turns out event listeners don't need that, I can within app just addEventListener(event,fn) rather than addEventListener(event,app.fn) I don't fully understand how scope works, and when closure kicks in.

Function references

I've been writing sniffy code like

switch(fn){
    case 'move': 
        obj.move(x);
        break;
    case 'turn':
        obj.turn(x);
        break;

because I'd sort of forgotten that an object can be addressed like an array:

obj[fn](x);

I much prefer being able to say what I mean directly. Conditionals are code smells.

Drag and drop on iPad

Apple's Safari documents are good; they've made it easy to find out how to adjust the viewport, hide the safari elements, and what to do to disable page scrolling and resizing (which is a nuisance when trying to implement drag and drop).

The touch events work much better than the simulated mouse events; the page is much more responsive with them. This means that it doesn't work in a normal browser of course, so I should probably do some sniffing and fix that.

When I was trying to determine the target of my drops, I was stymied until I found (thank you Google)

document.getElementFromPoint(x,y)

This does the trick.

And yet again. I'm trying to use the cache manifest.

Tags: apps, javascript

Date created: 2013-03-06

Viz

I'm working on a new little web app called viz. It's a javascript version of the Turtle Graphics from Seymour Papert's Logo.

The idea is that there's basic blocks which can have inputs and can be dragged around the screen-- probably like Etoys or Scratch, though I haven't spent time with those. They will start off being 2 types -- move and turn. Clicking a go button will run them as a program.

I'm building this for a few reasons:

The really wonderful thing about it is how it scaffolds basic concepts in math and in programming. The basic move and turn are good for solidifying ideas about number, and giving a notation for angles. Sequencing them is basic programming. Putting them into a repeat block is another important concept. At some point using variables rather than constants will be useful. Putting blocks into a howto block is abstraction, and is the important concept; because it's easy to abstract the abstractions.

New functions come about very naturally. Starting off with move, turn, penup,pendown I quickly need a way of changing color, of coming back to where I started, of clearing the screen.

Tags: computing

Date created: 2013-03-10

RIP Google Reader

So the sun's going down on Google Reader.

After reading lots of different takes on this, I'm in general agreement with:

I'd like to make my own. In the meantime I've gone with Fever a self-hosted php/mysql thing with a decent front end, including on IOS where I actually read feeds the most, what looks like some good extensibility (and if not, hey, php/mysql!), and the well respected Reeder app on IOS supports it.

Initial install of Fever was totally painless, as was import of my OPML file from Google Reader. Reeder on iPhone looks ok.

Initial thoughts

Reeder for IOS grabs the stuff ok. The interface is alright, gesture friendly, but I'd like some way to send to launch pro, so I can do fun things with adding tags to pinboard. just bookmarking isn't enough.

I was really used to the google reader views, nice and compact.

Tags: computing

Date created: 2013-03-15

Alan Kay interviewed

So Alan Kay has given an interview to David Greelish, published in Time, and excerpted by Forbes.

Alan Kay is always worth my time. He does say the same things a lot, but they're good things, and people clearly haven't listened well, so that's fair enough. Some of them:

He probably subscribes to Sturgeon's Law (90% of everything is crap). He certainly comes across as curmudgeonly, though I think he tries not to. I find his thinking immensely refreshing, the fresh air of sanity, blowing away the foetid miasma of "what everyone knows".

I have a google alert feed for mentions of Alan Kay (along with Ted Nelson, and Doug Englebart). With that one interview, there's been about 20 different excerpts, showing either this image

dynabook

or this one

Alan Kay

and repeating the same few lines from the interview (which to be fair, isn't all that long).

Most seem to have the tone of "Here's this guy, who seems to be important, though we're not sure why, saying the iPad is crappy, and that Jobs, maybe even corporate America, is not all that great. How odd".

Sigh.

Tags: computing

Date created: 2013-04-05

Indyweb (draft)

There's been a recent flurry of activity around the Indyweb (Indieweb?)

Since the announcement of Google Reader's impending demise, there's been quite a lot of internetention to Indyweb ideas.

Here's some that I found useful or nicely put.

Douglas Rushkoff is quitting facebook

Marco Arment,speaking about email says

You must own any data that's irreplaceable to you.

and in Own Your Identity he says

But there will always be the open web for the geeks, the misfits, the eccentrics, the control freaks, and any other term we can think of to proudly express our healthy skepticism of giving up too much control over what really should be ours.

He was a co-founder of Tumblr, which offered custom domain support free from its inception.

If you're not paying, you're the product Own Your Words Dave Winer Jon Udell

Use majors for syndication

Tantek talks about On Silos vs an Open Social Web looking at why the silos are far more attractive to people.

expressed the POSSE philosophy -- Publish Own Site, Syndicate Everywhere

this is much smarter than my facebook approach of avoiding it as much as possible.

celik? Anil? Steps/Degrees blog; tumblog indiwebcamp.org

Use services that will liberate your data google so far wordpress/blogger -- can move entire blogs flickr

IndieWebCamp has some good resources to get started.

Tags: internet

Date created: 2013-04-07

My O/S boots instantly

...but it just turns an LED on.

I've spent a few hours this afternoon on Baking Pi excercise OK1 for the Raspberry Pi.

The OK1 exercise results in an SD card with your own 'operating system' on it. In this case, it just turns on the OK LED on the rpi board, then goes into a busy loop.

The program is tiny (ignoring all the lines preceded by semicolons, they're just my comments):

.section .init
.globl _start
_start:

ldr r0,=0x20200000 
;loads r0 with base address for GPIO
;GPIO has 52 pins only a few are avaialbe to us
;each pin gets 3 bits to determine what its doing
;so each group of 10 needs 30bits, or 4 bytes
;GPIO register is 6*4-24bytes total

mov r1,#1
lsl r1,#18
;load r1 with 1<<18, 
;the address for the function select for pin 16
;(bits 18-20 of this bank of 10)
;the data here is 001, which sets the pin for output
;(000 is input, other values mean other things)
;unclear to me if loading this value affects the other pins?
;are we setting all other pins in this bank to input?

str r1,[r0,#4]  
;put r1 into address r0+4,
;addressing the 2nd group of 10 GPIO pins 
;pin 16 now ready for output

mov r1,#1       
lsl r1,#16
;indicate which pin we're addressing, pin 16
;so this is a bitfield? can control many pins at once?

str r1,[r0,#40] 
;r0+40 is address for turn pin (the data given) off,

loop$:
b loop$   ;loop forever

His instructions are clear; setting up the mac with the gnu toolchain was quick, and using his template file to create the assembler main.s was straightforward. All that could be done in about 15mins; the other hours I've spent are in trying to understand what's happening, flipping over the reference manual, following up on Wikipedia.

Most of that time was spent trying to work out what's going on with the GPIO register; the base address, the offset to target the relevant pin (the one wired to the OK led), the data that gets put into the offset to set it to output mode, then sending the index of the pin to the address for setting pins off (thereby turning the LED on).

There's a bit of jumping around between decimal and hex and binary, which is confusing. And because we're dealing with the CPU, the distinction between address and data is not completely clear. That is, the data in this register is the address for that operation, and populating that address with this data actually does something-- changes a pin state, lights an LED.

It's so easy to learn things as needed now -- when I was first learning about computers in the 70s, it was pretty impossible.

Some interesting things:

I remember reading about the MITS Altair and the IMSAI 8080 in Popular Electronics in the mid 70s.

imsai 8080 from wikipedia

They were the first hobbyist computers, programmed by flicking switches on the front panel. No long term storage, tiny memory, and I/O limited to buttons and LEDs. From this limited start people would interface with keyboards and screens, write drivers for paper tape or cassette storage, and the basic assemblers and editors to increase capability enough to do the next round of pulling themselves up by their bootstraps.

The rpi is a completely different beast of course, with built in USB, HDMI, Ethernet-- many layers of complexity on top of the core CPU; none of which I have a clue how to access. Yet.

Now to make the LED blink.

Tags: raspberrypi

Date created: 2013-04-20

Building Keykit on Raspberry Pi

[KeyKit](http://nonsuch.com/keykit/] is an interesting programming environment for midi music, combining graphical and programmatic control. The interface is extensible. Best of all, it was written before 2000, so it doesn't require a beasty machine.

There was no pre-built package for the raspberry pi, so I thought I'd have a go myself. I haven't done much compiling from sources since my early days using Linux.

I'm running the standard Raspbian distro.

Registering at the download site allows downloading the source. I was just interested in the alsa version-- haven't tried the raw midi version at all.

Extracting the zip creates a keykit77b folder, but running make installlinuxalsa fails with different errors. There is a useful readme_linux.txt file, but it didn't solve my immediate problems. Here's what I did to get it working:

It then compiles successfully-- though it doesn't create files in /usr/local/bin like the documentation says, the files are created in key77b/bin. The program runs under x, so startx if it's not running already.

The key77b/doc file has tutorials, as well as other documentation-- the multiport one was useful.

Initially I the program was seg faulting whenever i tried to get some sound. This turns out to have been an issue with my midi port setup. This is probably properly handled by creating a keylocal.k file but I haven't got that far yet. Adding the Port Enabler tool to the window, and using it to enable midi input and output prevented further segmentation faults.

To actually get midi doing something required I use the alsa tools to map keykit's ports to the system's midi ports.

I had an old Edirol UM-1 USB-midi cable which I plugged into the usb hub connected to the pi. With keykit running and the midi ports enabled, from a console command line

aconnect -i 

lists the midi inputs

aconnect -o 

lists the midi outputs

Both the UM-1 and keykit showed up, with a major/minor number.

aconnect 128:1 20:0

connects the midi in on keykit to the midi out of the UM-1. At this point I could connect my iphone (through yet another midi interface) and run Midi Monitor and see events generated by keykit's Mouse Matrix tool. Running BS-16i on the iphone let me hear stuff. BS-16i has a General Midi soundfont; very handy.

Using aplay midifile from the console was very handy getting this working.

aplaymidi -p20:0 filename

Once that was working, I connected the midi cable from the UM-1's output to my MeeBlip synthesiser, switched it to receive on channel 1, and spent a fun few hours playing with keykit.

Keykit's documents say it only works for external midi; but I imagine since they were written, the state of soft synths has advanced considerably; since the connection is handled by alsa, I don't see why it won't work.

Resources

Tags: raspberrypi, synth

Date created: 2013-04-28

what is the internet in the absence of Google?

Finding things through stuff you've already found.

Contributing in smaller communities.

Finding stuff by following up references, to references, to references.

Twitter immensely more important.

PLN (Personal Learning Network) very significant. Personal reccommendations.

Is this what we're moving too? Because the surplus of information availble from Google is so overwhelming, people just rely on friend's reccommendatiionss, Facebook streams for stuff that's mildly interesting?

Tags: internet

Date created: 2013-07-06

Imagine a book

Imagine a book that was interesting and always new stuff is being added. That's my phone or the net.

It's more interesting than being present. Not very substantial though.

Tags: internet

Date created: 2013-07-30

Raspberry Pi as iPad host

I could use a raspberry pi as a server, to do web development on iPad.

I could jailbreak the iPad, but it's too much trouble.

The rpi is good, but I don't want to carry a keyboard and screen around.

So I can setup the rpi with TinyCore and openSSL, and ssh to it from iPad using Diet Codea.

TinyCore is minimal and should run fast.

rpi can host an ad-hoc network, though I'd also want to connect to the internet to look stuff up.

Tags: rpi

Date created: 2013-08-13

A first patch

2 modules, cross patched

From the video it looks like pulse and sin feeding filter, and saw is feeding the filter cv, but then the 2nd output is FMing the osc.

Tags: synth

Date created: 2013-12-05