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

  • By
    Write Simple, Elegant and Maintainable Media Queries with Sass

    I spent a few months experimenting with different approaches for writing simple, elegant and maintainable media queries with Sass. Each solution had something that I really liked, but I couldn't find one that covered everything I needed to do, so I ventured into creating my...

  • By
    JavaScript Promise API

    While synchronous code is easier to follow and debug, async is generally better for performance and flexibility. Why "hold up the show" when you can trigger numerous requests at once and then handle them when each is ready?  Promises are becoming a big part of the JavaScript world...

Incredible Demos

  • By
    CSS Columns

    One major gripe that we've always had about CSS is that creating layouts seems to be more difficult than it should be. We have, of course, adapted and mastered the techniques for creating layouts, but there's no shaking the feeling that there should be a...

  • By
    Resize an Image Using Canvas, Drag and Drop and the File API

    Recently I was asked to create a user interface that allows someone to upload an image to a server (among other things) so that it could be used in the various web sites my company provides to its clients. Normally this would be an easy task—create a...

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!