Oh hi Slash Art

April 18th, 2012

Inspired (well, pretty much blatantly copied) by a talk I saw yesterday by seb.ly (who I think said that he took it from someone else..?) I made this javascript slash art page: clicky.

I gave it very limited testing so sorry if it looks completely screwy for anyone (and sorry to my girlfriend who said that it nearly broke her pc…), maybe if you leave a comment here I’ll have a look, but it’s very basic, so I make no promises that I can fix it!

It’s actually quite a messy script compared to Seb’s who was showing off computer generated art with just one line of code in a Commodore 64 emulator! From the top of my head the code was something like this:

10 PRINT(205+RANDOM(1)); : GOTO 10

I guess if you know anything about programming for a Commodore 64 then you’ll know how to fix any mistakes I’ve made, but if you don’t then hopefully you get the idea of how it works. If I’m correct then the character code for \ is 205 and / is 206, so it’s just randomly choosing one of those to print and doing it forever.

My code is uglier and has another section just to style it properly. Here’s the javascript:

<script type=”text/javascript”>
(function printLoop() {
setTimeout(function() {
document.getElementById(“console”).innerHTML += String.fromCharCode(47 + (45*(Math.round(Math.random()))));

Here I’ve got a function instead of a go to and the function simply registers another function to be called in 5ms which calls the parent function, causing the loop. The actual printing just appends a character either 47 or 92 for \ and / to a div with id “console” which is defined after the script block as:

<div id=”console” style=”white-space: pre-wrap; word-wrap: break-word;font-size: 40px; line-height: 29px;font-family:courier; letter-spacing: -10px; font-weight: bold;”></div>

The style seems to make it pretty similar to a console output for the few browsers I tried it on. The word wrapping isn’t great outside of Chrome, but I’m sure it’s possible to improve it with effort.

So yeah, that’s how to do slash art that’s one line on a Commodore 64 emulator in nearly a dozen html/javascript lines!


May 31st, 2011

I went to Thinking Digital 2011 this past week. It was the first conference I’ve been too and was certainly very educational even if it wasn’t immediately useful. Being paid for by my boss and all, I was tasked with writing down what I had learnt over the 2 days of the conference and writing out my notes in expanded form really helped hammer home the bits I’d picked up.

The title of this piece is from a talk given by a founder of professional social networking site Viadeo in which he mentioned that they were given a little boost against their major competitors LinkedIn because people with French as their mother-tongue find it hard to pronounce their name. Now I don’t know that many french people and the guy is from a competitor company so he could be embellishing this a bit, but I quite liked that subtle difference. Read on for more thoughts from Thinking Digital.

Read the rest of this entry »

NSScrollView top-left pinning and isFlipped

August 25th, 2010

Working on the settings page of the application I’m developing at work I stumbled across a rather annoying characteristic of NSScrollViews. The NSScrollView allows you to fit a larger custom view into a smaller view which the user then can scroll up/down/left/right to see all the content in the custom view. For our application we need more space to fit all the settings and so I put the controls into an NSScrollView. The problem that occurs is that when you load the page with the NSScrollView it starts at the bottom-left of the custom view inside. This is pretty irritating, every implementation you see of a scroll view starts at the top left – it’s what everyone expects.

So off to google and Stack Overflow I go, apparently this a very frequently brought up question and as such there’s a solution: flip the view. However, this has rather unfortunate consequences for the poor developer (me!) and an awful lot of the mailing lists and posts I’ve read on the subject seem to suggest that we have to man up and get on with it. I find this rather odd, because the solution I’ve come up with is stupidly simple and I cannot be the only one to figure it out. Read on for an example of the problem and my solution.

Read the rest of this entry »

Reactionary Posters

July 7th, 2010

Joe Alterio has designed 3 posters for the Institute of Physics which change their appearance in the presence/absence of light or heat. They will be put up in schools around the UK in efforts to rekindle children’s fascination with science. Of the three posters, one reacts to heat and the other two to the light. There’s a mention of them being made for sale to the public and I’m sure there’s enough demand, personally I’d love one of the Earth/Moon ones.

You can read the full article and see the posters on Joe’s website here: http://joealterio.com/2010/07/get-physical/

This is the Earth/Moon one. The top half is visible when the lights are on, the other half when they’re off.

A Brief Glastonbury Roundup

July 5th, 2010

I returned from Glastonbury 2010 late on monday evening along with the first signs of a crappy cold. 9 hour stuffy coach trips are great incubators… It could have been worse, I did notice a couple of sniffles during the festival itself, but they seemed to stay away long enough! The lovely weather made for a more pleasant experience than last year – shame it’s exceptional. I still struggled with an inability to stay upright for very long. Fuck my life, or posture.

As for the music, I’ve compiled a little spotify playlist from the bands I managed to see albeit short and uncomprehensive. It can be viewed/listened to here: Glasto
Read the rest of this entry »