OU blog

Personal Blogs

neil

remiss

Visible to anyone in the world

I have been remiss, remiss I tells ya. Remiss in that I haven't been blogging. I haven't been keeping you posted about my doings, regaling you with my thoughts, bothering you with my bothers.

I have been doing stuff: playing games (chess, poker, netrunner), doing OU stuff (TU100), coding stuff (the chessplaying thingee, my new site) but I haven't been keeping you, the world, informed. I don't know why. Laziness probably. That and maybe I don't know what to say.

Everything I'm doing feels a wee bit up-in-the-air at the moment, a work in progress, an incomplete thing. Take the chess playing thingee...

It's at that annoying stage where it works, but not completely; the code has become messy and needs to be fixed; it does almost everything that it needs to, but not quite. Unfinished, nearly finished, a start has been made? I'm not really sure.

My new site? yes, I'm finally going to register a domain and do a proper site. Which poses the tricky problem: what's is it going to be about? Where does the web have a neil-shaped hole? Well that's one thing that's at least been decided: JavaScript. TU100 has been a good course for me in that regard. I've re-discovered the joy of coding and the joy of coding JavaScript in particular. And if I'm being honest JavaScript is really the only thing that I'm any good at.

But it's all very well saying that I'm going to write about javaScript, that's a fine ambition, but what does it mean? Again not sure.

Then there's the degree. That's in the air too. I've decided that I'll do web/mobile/cloud technologies come October. To give me something to do and some time to think.

Still at least my plans for the weekend are fixed: I have a multi-media horror to produce for TU100. I'm off to download some un-plangent sounds to assault my tutor's ears as she view a montage of discordant images... 

Permalink
Share post
neil

i'm getting better at creating proofs

Visible to anyone in the world

At least, those that centre around me being an idiot.

Today, if I did anything at all, I should have done maths. Although, I suppose that I did do a wee bit of maths.

Here's the story: I got interested in x-nomials [for reasons which my M336 course-mates will understand.] So I started writing a JavaScript script to do it for me.

I noted three things:

  1. My JavaScript skills have withered to crap
  2. I miss a proper IDE—NetBeans has spoiled me
  3. I can do this

It will take me a couple of days, days which I will spend. Why? [given that  moaning about being behind].

Because writing such scripts is why I do all this maths/programming OU stuff—if I don't do them I won't be me. In which case I shouldn't bother.

Losing the Joy is worse than failure.

Permalink Add your comment
Share post
neil

as i thought

Visible to anyone in the world

[See my previous post]

Creating the XML wasn't difficult, I knew that it wouldn't be. Parsing the thing back will be a bugger.

There's a big bit of me asking why this is should be so. It's not as if XML isn't a standard. Someone should have made this easy. But..

If I bump into a bod on the street and start talking Topology [not there yet, but will be sometime soon wink], I'm seen as a benign idiot; I start talking XML and I'm a signed-up-member-of [insert your favourite hate group here].

True, the thing was, and is, used wrongly, but we can say this about any data format, can't we? Morons used it when they shouldn't, it's still better than anything else we have. Or do you fancy openDoc?

Who knows. But it is, funny? One of the major techs that drives the web is named after XML, which it doesn't use. AJAX [Asynchronous Javascipt and XML].

Only a moron loads XML, because you have to fork IE and normal browsers' javascript... [I've tried, if you want the almost working code drop me an email.]

Jings! I've just realized that I need to care not one iota about how others are going to use my stuff. I'm off the leash for once.

So it's going to be XML. Plus.

 

Permalink 2 comments (latest comment by Neil Anderson, Thursday, 12 Jan 2012, 21:17)
Share post
neil

the mind

Visible to anyone in the world

Has it's ways.

After a week lying in bed for most of the day, reading Harry Potter books and trying not to think about anything, I'm now beginning to think again.

[I've never read any of the Potter books before, sort of a personal block; I remember JK sitting on the school-stairs writing into her notebook, one of the books that I've just read mayhaps? She was waiting for Jess; Jess who should have been playing chess! wink]

So it's back to my JavaScript Integrated Development Environment. The sodding nuisance of the thing is that I can see that it's possible. Not for me maybe, but it is for a team of programmers, there we are talking doddle.

Actually that's a two-way lie: I can do it and I think that a team of programmers would mess the thing up. So what to do?

Realistically I can't do the whole thing myself, I can pretend that I can... or can I? I could probably decide upon an architecture and then throw it open to the wolves. Should I?

That's the trouble with Open Source: your vision will be stolen from you. Which might be right, but feels wrong for you personally; they've robbed your soul. So, this one's mine, if I have to spend thirty years doing it and if it's only, or not even, useful to me...

I'll get started with the text editor stuff shall I? [Out with the big sheets of paper.]

 

 

Permalink 2 comments (latest comment by Neil Anderson, Monday, 31 Oct 2011, 22:14)
Share post
neil

JavaScript

Visible to anyone in the world

After my sad and dreadful crap-out on Saturday I've lain low for a few days. I'd like to say that I've rested but alas my work commitments haven't allowed me much rest. So I did the next best thing—made myself much rice & beans, read a few Jeaves and Wooster novels, tried to get my work life into some type of order and started coding JS again.

We'll deal with said JS stuff here.

I've been working on my testing stuff, progress has been a wee bit glacial, but I think that I've got something done.

The main problem is that JS has a lot of functions that aren't strictly functional, they are the equivalent of IO. How do you run unit-tests on an addEvent function. Or a whole series of these functions interacting?

I think that I can see a way to do this [fireEvent() figures prominently I'm afraid], but I'm going to have to think about this. The main thing that I'm going to have to think about is: do I want to make this for just me, or to be potentially useful to others?

This is a somewhat theological thing—I wanted to take [my?] JS in the direction of Java or C++, where we test things at compile time rather than using reflection at runtime. But I haven't got clue one about the right mix yet.

[Strangely I intensively dislike reflection in Java but I'm more than happy to pseudo-overload etc. in JS.]

There are hard choices to be made here, and whatever choices I make will be wrong for some people. Still it's nice to be faced with them.

Permalink 8 comments (latest comment by Neil Anderson, Friday, 21 Oct 2011, 19:03)
Share post
neil

A little

Visible to anyone in the world

pencil and paper work suggests that my stupidity is do-able. [See my last post.] Even if I can't do it.

But I need to make a big decision: O-O or prototypal inheritance for the JS? I think that a mix might be the best idea.

I worry. It's not as if I'm in an null terminated string crux here, I'm not going to make a mistake that will change the world, still I think that I should worry.

Permalink Add your comment
Share post
neil

Getting in touch with my inner idiot

Visible to anyone in the world

I opened up NetBeans last night, stared at it blankly for about an hour and then closed it. I couldn't think of anything that I wanted to do. The recent projects were just an accusing glut of failure. I need a new project to mess up.

When I got up this morning I began to think about something—something stupid. As the day wore on it began to look sensible. Naw, sensible isn't the right word, still stupid, but something that I might have fun doing. So here's what I plan to create...

  1. A light weight JavaScript library [yeh, that's what the world needs, another bloody JavaScript library!]
  2. A JavaScript test suite [rather like JUnit]
  3. A Java documentation creator [rather like JavaDoc]
  4. A Java compiler for JavaScript
  5. A Java IDE for JavaScript
  6. A web site to peddle the above

Madness of course, but fun madness. It won't happen, but sometimes stupid is good for the soul.

I have four months before my next course, it's time I went back to where I started to see where I am.

Permalink 2 comments (latest comment by Joyce Rae, Friday, 14 Oct 2011, 19:38)
Share post
neil

Got it I think

Visible to anyone in the world
Edited by Neil Anderson, Wednesday, 10 Aug 2011, 15:20

It's a mess, needs optimized, I need to pseudo-overload it and tidy up my messes, but hey, I have a function that composes permutations!

<html>
<head>
<title>Permutation</title>
</head>
<body>
<script type="text/javascript">
/*
Signature:
Array [Array int || int] X int -->boolean
post:
true if the int is in the permutation
*/

function contains(arr, val){
var found = false, over = false, ret = false
var ix = 0;
while(!found && !over){
if(typeof arr[ix] == 'object'){    //a cycle
var subArr = contains(arr[ix], val);
ret = subArr;
found = subArr;
ix++;
}
else{   
if(arr[ix] == val){
ret = true;
found = true;
}
else if(ix++ >= arr.length){
over = true;
}
}
}
return ret;
}


/*
Signature:
Array int X int --> int
Post:
the int after val
the first int in the array if val is the last member of the array
val if the array doesn't contain int
*/

function findNextInCycle(arr, val){
var len = arr.length;
for(var i = 0; i < len; i++){
if(arr[i] == val){ //we have the value
if(i == len - 1){ //end of the permutation return the first
return arr[0];
}
else{ //return the next value
return arr[i + 1];
}
}
}
return val; //val didn't exist in the permutation
}

/*
Signature:
Array [Array int || int] X int --> boolean
Pre:
Either an array of int representing a single cycle
or an array of array(int) with any fixed points excluded
ie [1,2,3] or [[1,3], [2,4]] but not [[1,2], 3, 4]
the last should be [1,2]
Post:
the int after val
the first int in the array if val is the last member of the array
val if the array doesn't contain int
*/

//uses findNextInCycle
function findNextInPerm(arr, val){
if(contains(arr, val)){
for(var i = 0; i < arr.length; i++){
if(typeof arr[i] == 'object'){ //an array hand it off to findNextInCycle
if(contains(arr[i], val)){
return findNextInCycle(arr[i], val);
} //otherwise we carry on through the cycles
}
else{ //hand the whole thing off to findNextInCycle
return findNextInCycle(arr, val);   
}
}
}
else{
return val;
}
}


/*
Signature:
Array [Array int] --> Array int || Array [Array int]
Post:
If the argument contains only a single array it will return that
Otherwise it will return an array with all single length cycles removed
*/

function fixCycles(arr){
if(arr.length == 1){
return arr[0];
}
else{
var ret = [];
for (cycle in arr){
if(arr[cycle].length > 1){
ret.push(arr[cycle]);
}
}
return ret;
}
}



/*
Signature:
Array [Array int || int] X Array [Array int || int] --> Array Array int
Pre:
The arrays must be either of int representing single cycles
or arrays of array(int) with any fixed points excluded
ie for either array [1,2,3] or [[1,3], [2,4]] but not [[1,2], 3, 4]
the last should be [1,2]
Post:
a composition of permutations
Use the fixCycles function to change this into a single permutaion

Note:
We need len because we may not have all numbers may appear in the perms
*/

function composePerms(first, second, len){
var ret = [], cache = [];
for(var i = 1; i <= len; i++){
if(!contains(ret, i)){
var at = i;
while(!contains(cache, at)){
cache.push(at);
at = findNextInPerm(first, findNextInPerm(second, at));
}   
ret.push(cache);
cache = []; //reset
}
}
return ret;       
}

var x = fixCycles(composePerms([1,2,4,3,5], [1,2,3,5,4], 5));
for(i in x){
document.writeln(x[i]);
} //1 4 2 5 3

// -->
</script>
</body>
</html>

Now I need to write the unit tests, and a test suite.

Permalink 2 comments (latest comment by Neil Anderson, Wednesday, 10 Aug 2011, 20:09)
Share post
neil

failure

Visible to anyone in the world
Edited by Neil Anderson, Tuesday, 9 Aug 2011, 19:27

Today I tried to write some Javascript that would allow me to compose permutations; I got an idea that I wanted to bulk test.

[I should be working on analysis but my mind and fingers itch for groups.]

It was surprisingly hard—because I tackled it stupidly, I didn't write a specification and I've lost my test harness somewhere along the road.

The beast is still in the myth stage.

I will manage this, but my uselessness, after all this study, annoys me hugely. And why do I rely on code [that I can't write] to confirm something that I should be able to prove

Permalink Add your comment
Share post
neil

Maths/Computing

Visible to anyone in the world

The ultimate chocolate sundae. And oh, the guilt.

[Warning! JavaScript and prime Numbers.]

Permalink 10 comments (latest comment by Marcin Tolysz, Monday, 13 Jun 2011, 01:19)
Share post

This blog might contain posts that are only visible to logged-in users, or where only logged-in users can comment. If you have an account on the system, please log in for full access.

Total visits to this blog: 252529