Free JavaScript book.
I have too many JavaScript books, and I just bought a new one, so I want to get rid of some old books.
The first one on offer is the Sitepoint book “The Art and Science of Javascript“. This is a great book, and the chapter on Meta-programing rocks.
So how do you get your hands on this free book?
I only have one copy, so I have to find some way of choosing who to give it to. And I want to make if fun. So how about a little competition?
Send me a JavaScript file, and the one I like the best, wins! I’ll even pay the postage.
How will I judge? Err.. I like fun things. If it makes me smile, you’re in with a chance.
I’ll run the code in this page to test it, and just in case you were wondering, there are no frameworks to leverage off. Your code must be completely self contained. And I’ll test with Firefox 3
What’s the catch?
Of course there is one. The catch is that you have to send me your JavaScript via Twitter. That’s right, it has to fit inside the Twitter 140 character limit, and I guess that includes addressing it. My Twitter handle is @nedlud. But to save a little space, I think I’ll allow a #JS tag. Include #JS in your code (*instead* of address it to @nedlud) and I should be able to find it on Twitter. The #JS tag seems to get a fair bit us use, so I’ll look for things that look like pure JavaScript code only. I’ll DM the winner so I can get a mailing address from them.
Use @nedlud if you want to be sure I get it.
Use #JS if you need to save those extra 4 characters.
Since it’s Twitter, and everything is so *now*, I’m only going to leave this little competition open for one week. Today is Saturday 13 June, so I’ll take submissions only up to Saturday 20 June.
Good luck.
grrrr.
Currently at 217 chars for something that looks interesting.
My biggest problem is by the time I get the element, and loop over content, I’m already at 143 chars.
This is what I posted on twitter as an example… e=this.document.getElementsByTagName(‘p’)[0].firstChild;e.data=e.data.replace(/m/gi,’#JS’);
It weight in at only 96 characters, *and* it already contains the #JS tag so it can be found. As to whether it’s “interesting”…
So here was my first attempt that I’ve given up on:
s=v().innerHTML.split(” “);r=”";for(i=0;i<s.length;i++){r+=’<a style=”color: #’+((s[i].length<’+s[i]+’ ‘}v().innerHTML=r;function v(){return document.getElementsByTagName(‘p’)[0];}
At first the colours were randomly chosen, but I tried to shorten it.
The next attempt:
v().position=’relative’;t=0;l=0;function m(){v().top=t+a()+’px’;v().left=l+a()+’px’;setTimeout(‘m()’, 200);}function a(){return Math.floor(Math.random()*3)-2;}m();function v(){return document.getElementsByTagName(‘p’)[0].style;}
We have three entrants so far
All worthy. Two were sent via Twitter, and the 3rd via Facebook, but it met the criteria of *being able* to be sent via Twitter, so I accepted it (and since it was from a good friend
)
4 days to go. How many more scripts?
If there is not too many, I’ll post them al online once it’s done.
[...] challenge is much like the first one, but this time I have made jQuery available. I’ve also changed the structure of the target [...]