Wow, I'm happy to say we have our first new contribution to whichElement.com. Adam Tuttle fired off a pull request to me this morning to fix some grammatical and spelling issues. I was happy to bring his changes in.
This is a great example of how you contribute to Open Source projects you like without necessarily spending a tremendous amount of time or writing a crap ton of code. Adam noticed some spelling and grammar issues, probably because I have the spelling ability of a Russian Sex Spammer. Awesome. He fixed it. He contributed it back.
I'm pleased to unveil a little project I've been working on for a few weeks now: whichElement.com. WhichElement.com is a reference site for answering the question "Which elements should I use to mark up this HTML semantically?" I've been joined in this effort by my coworker, Ray Camden. We're pleased to put this out there, and eager to see what you can do with it.
The Story Behind It
I was (and still am) incredibly impressed by HTML5 Please. I think it's a fantastically on-target site. It showcases its technology and hits on a specific need and fills it brilliantly. I wanted to do something in the same vein without just copying it. Around the time that I was feeling this, I got into an argument on semantics with someone. Specifically they were asking questions about when they should use article versus
div. Basically I explained what I knew of the spec for article. I gave some analysis, and made a recommendation.
When I was done with the argument I had an idea for a site: A reference that would help people choose for themselves which tags to use semantically without being authoritarian. I also wanted to set the tone that there isn't one right answer to these things - that "semantically correct" isn't a binary thing, but a position on a continuum.
The Technology Behind It
Another important thing for us in doing this was choice of technology. We placed a couple of constraints on the project:
We wanted to be open to other people contributing and offer a few channels for that.
No content management or wiki software
All code and content would be in HTML/JavaScript/CSS; no server-side technology
To achieve this we made a few choices. To go open and collaborative without having a wiki, we went with github. Not the usual answer for a content site, but I think we can make it work. The choice of no server-side tech (other than a vanilla web server) came about so as to not discourage contributions from anyone. PHP, Ruby, ColdFusion, some JVM language, Python - whatever your back end, you have to know HTML/JavaScript/CSS. So let's not skew one way, when most of the contributions can be made very simply with the front-end stack.
Working in those constraints wasn't always easy. Ray got tired of copying and pasting template code around despite my incredibly stupid protestations that "No, it will be okay; we can work that way." So he came up with a cool way to handle that with some JavaScript and .htaccess magic. I had to come up with a way to provide search without having any sort of server-side tech. We're not sure if other people will be cool contributing under these constraints, but obviously I hope so.
Get Involved
We're open to contributions. We do all of the publishing through an automated build process that looks at the github repository for the project. So git is the path to getting on production. We're open to forks and pull requests. We're also open to contributions through email. Basically if you want to contribute, drop us a line, we'll figure out how to work with you to get you in.
This is pretty simple, but I couldn't find it via searching, so I thought a little write up was in order.
I'm fooling around with Rhino, which is a JavaScript engine written in Java. It allows you to do a lot, but in my case I am using it to write JavaScript helper scripts for ANT. I'm working on a project for which I want to only write in HMTL/JavaScript/CSS. I have to write some ANT scripts, but anything that I can't accomplish with ANT, which means I need a scripting language to do, I decided to do in JavaScript. Rhino allows me to accomplish that.
I'll post more about what I'm trying to do when I release more about the project. For this step, I needed to get a list of all of my files in my project so I could manipulate them in JavaScript. I looked for a directoryList function, but only found this post on Directory Traversal. So I whipped up my own script for DirectoryList in JavaScript using Java on Rhino:
A friend and mentor of mine, Avish Parashar has a new book out named Say Yes, And! Avish has a ton of great advice to give you, and I highly recommend the book. Go forth and pick it up from Amazon.
Still here? Okay, let me tell you why I think this is a great book.
Improv Comedy
Avish's philosophy has it's roots in improv comedy. Improv comedy imparts a great deal of skills that can be useful in the work world:
Creative Thinking
Effective Collaboration
Public Speaking
One of the core concepts of improv comedy is the offer. An offer is an attempt to create or develop a scene it is vital to creative thinking and collaboration. For example a group of improv players get the location of a bathroom from the audience. Player 1 steps out, mimes slapping a wet mop down on the floor, and announces in a terrible Scottish accent that "Accckkk the lavatory has been invaded by the filth again!"
That's an offer, he's created a reality: he is a Scottish janitor in a filthy bathroom and it's his job to clean it up.
Now Player 2 has the ability to do three things:
Block
Accept
Build
Blocking is bad.
Player 2 steps out and says, "What do you mean filth, this bathroom is a monument to cleanliness".
See what he did there? He completely invalidated what Player 1 said. It completely derails the scene, the two of them have to start building from scratch. It doesn't bode well for the scene.
Accepting is better
Player 2 steps out and says, "Well if you cleaned them more often, they would't get this bad."
This is better, he accepted the reality that player 1 offered and didn't just bring the scene to a halt. The two of them can go on from there. But Player 2 didn't make it any better. Nothing was added.
Building is best
Player 2 steps out and says, "Yes, and I need to get home fast today. I noticed that there is an emergency fire hose in the hallway. I bet it would blast the grime away."
That is the beginning of a scene where something happens. Something dumb and disastrous, but that's comedy.
Yes, And! is the name of an exercise that teaches you to build instead of blocking or merely accepting. Basically someone says something and you have to start your response with "Yes and." It forces you to accept and add, which is building.
Back to work
How many times have you been brainstorming trying to solve issues or come up with something new and confronted by people blocking you:
Offer: Let's build a full featured version of PhotoShop for tablets!
Block: But even the most powerful tablets are still not powerful enough to run desktop PhotoShop.
Accept: Okay, what would that look like?
Build: Yes, and we could use the camera to pull photos directly into the app, something that doesn't make sense on desktops.
One response stymies progress, one doesn't help it, and the last advances it. Our goal should be to get to a place where the building response is our first instinct. It doesn't make the statement put forth in the block any less true, but most of the facts that get put forth to block ideas are obstacles to overcome, not reasons to prematurely abandon ideas. (PhotoShop Touch is doing very well thank you. )
Say Yes, And! by Avish Parashar is a book that will give you the tools and training to get yourself to think of building instead of just accepting or even blocking in the business world. Avish is a great teacher, and you can get a lot out of it. Go get it!
There's a great video on YouTube detailing an Easter Egg in the score for the movie Inception. Basically Inception is about dreams and the slowing down of time. Likewise the score is based on the slowing down of music that is played inside the plot of the movie. Pretty cool. Feel free to check out the video before continuing.
I wanted to use this concept to show off the Audio capabilities in HTML5. Basically I want to:
Play the Inception Score
Play the Edith Piaf song
Play the Edit Piaf song slowed down
Play the Inception score over the slowed down Edith Piaf song.
But the vanilla tag didn't work for me. The tag does have the ability to be slowed down, but it seems that in Chrome and Safari, I could not get the rate below 50% of the original. On Chrome the sound stopped playing if the rate was below 50%, and on Safari the sound just never got slower even though the rate was below 50%.
I figured I would give the Web Audio API a try and see what it could do. So I wrote a function that could play back a sound at a given rate:
Oh before you click on that link - It only works on Chrome. And sometimes it has the tendency to stop working all together. The fix is to empty your browser cache, and restart Chrome. But hey, still a cool proof of concept.
I was working on a little demo showing the manipulation of playback rates of audio clips. The Audio tag failed miserably. On Safari and Chrome (both for Mac) the audio tag couldn't playback the audio any slower than half speed.
For what I was working on, this meant trying out the Web Audio API. I stole some code that allowed for playback, got it working, then tried to manipulate the playbackRate for the clip. But no joy, no Chipmunks singing for me.
I looked up a couple of things, and many of them pointed at this statement from the HTML5Rocks Web Audio API FAQ:
Q: HOW CAN I CHANGE THE PITCH OF A SOUND USING THE WEB AUDIO API? A: Change the playbackRate on the source node.
I tried and I tried for an hour to get this to work using this syntax:
Github has these cool ribbon images that you can use if you want to encourage forking your project on your site. They're great and I wanted to use them on a little project I am working on. However, one of my goals was not to use any images, but rather produce all display elements with CSS.
It was a little bit of trial and error but I got it working. Basically you do the following:
Create a link in a div with an id of "banner"
Force div#banner to be 149px x 149px.
Set overflow to "hidden"
This creates a square display area that won't show things that stretch out past the bounds of the box.
Create an A link
Tilt it using a CSS transform
Use relative positioning to pull the ribbon into place
Use CSS shadows to tweak the text and ribbon shadows
Finally I use a CSS gradient in the background of the ribbon to give it the bands that run along the edge.
Issues:
It's not a pixel perfect representation.
It doesn' work on IE before 9. It doesn't appear at all.
I'm not sure if I'm going to use this. I'll sound judgmental here, but the fact that it doesn't show up on IE less than 9 seems like a good thing. Do I want a developer on my project that isn't using the latest browser? Probably not.
A couple people pointed out that there was a weird doubling of the letters on their browser (Chrome on Windows, and Safari on iPad.) Looks like it was caused by a slight text-shadow I had on the text. The text on the original banner has some anti-aliasing going on, and on some browsers, the text shadow helps it look a little smoother, but on others you get that doubling. So I've removed the text shadow. Display should be a little more consistent.
In the past few months, there has been a number of new tools and new services from Adobe for HTML5. Some of these tools, like PhoneGap Build and jQuery contributions are aimed at developers and some, such as Edge, are more focused on designers. Adobe Evangelist Terry Ryan will give an overview and demos of these and other tools.
The meeting is on Thursday, January 26th at 6:00PM. It will be at the Huntsman Building at 38th and Walnut on Penn's Campus.
A friend of mine alerted me this weekend to just how much I have a weird fascination with Venn diagrams. I decided to roll with it. So yeah, I have an irrational love of Venn diagrams. But that begs the question, can I make a Venn diagram with just CSS?
But I felt like they had a bit too much fluff in the HTML markup. Not that there is anything technically wrong with their implementations. I prefer complexity in my CSS and not in my HTML. It's probably just a subjective thing, but I do.
So how do you do it?
First you create 3 divs. 1 for each Venn circle, and 1 for the overlap section. Each div contains a p with content in it.
Then you go to style each of the circles. Give them matching heights and widths, and a border radius of half of the height. This creates the circle. Then give each one an opacity below 1. This will ensure that when they overlap they will form a new color.
I then created two rules based on the nth child css selector to color each of the circles. I also padded to ensure that there would be a space to write in the overlap section.
Finally I styled the overlap section using relative positioning and pulled it back towards the center.
The real trick is to watch the pixel counts because a couple are directly related.
To create a circle:
width must equal height
border radius must equal 50% of width.
To overlap circles:
Circle 2 must have negative x left margin
(Or Circle 1 must have negative x right margin)
Each circle must have x padding-left or x padding-right to ensure its text doesn't spill over borders
It looks like the example works across modern browsers, including IE 9, but not previous versions.