Tweet for Code #3

By  on  

You don't need a thousand lines of code to make a big difference in any coding language.  Oftentimes it's quite the opposite:  a few tiny code snippets can do a world of good and accomplish big things.  I asked my Twitter followers to tweet to me their favorite tiny snippets of code -- that's a bit difference to try to pack into 140 characters!  Here are my favorites from this round!

Anagram Check

Anagrams are cool, and I'm gonna let ya finish, but this is the smallest checker code of all time!

Text Display Optimization

Sometimes fonts don't display optimally on all devices, so let the device browser help:

Equal Width Table Cells

We all know that tables are a pain to work with but this snippet ensures cells stay equal in width:

Slide Title Centering

This gem from Ana Tudor vertically centers a slide title when using HTML/CSS/JavaScript slides...which you should be using!  Death to Keynote and Powerpoint!

Floating Point Fix

Floats in JavaScript can be a pain point to those who don't already know about the issue.  Here's the fix to keep in mind:

Closing a Browser Tab

This blog post will now self-destruct...

Until the next Tweet For Code!

Recent Features

Incredible Demos

  • By
    Create Spinning Rays with CSS3 Animations & JavaScript

    Thomas Fuchs, creator of script2 (scriptaculous' second iteration) and Zepto.js (mobile JavaScript framework), creates outstanding animated elements with JavaScript.  He's a legend in his own right, and for good reason:  his work has helped to inspire developers everywhere to drop Flash and opt...

  • By
    pointer Media Query

    As more devices emerge and differences in device interaction are implemented, the more important good CSS code will become.  In order to write good CSS, we need some indicator about device capabilities.  We've used CSS media queries thus far, with checks for max-width and pixel ratios.

Discussion

  1. Anonymous

    The replace() + split() in the anagram checker can be written as match(). In Firefox 30.0:

    function isAnagram(a,b){x=[for(x of[a,b])x.toLowerCase().match(/[a-z]/g).sort().join()];return x[0]==x[1]}
    

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!