Tweet For Code #4

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!

ES6 Array Initialization

Here are a few clever ways to initialize an array with ES6:

Short syntax for dynamic result!

Remove Wrapping HTML with inner/outerHTML

This neat little trick allows you to remove a wrapping element and re-parent the child in one operation.

Of course you would brick your event connections but this is a neat trick.

3D Body Elements

Want a 3D look at a page's elements?  Check out this sweet JavaScript snippet:

This is a really neat optical effect, though not the most practical of snippets.

YOLO!

Since `sudo` gives you the ultimate of powers, why not give it a YOLO alias?

Hilarious!

Thank you to everyone who participated, and keep your tiny snippets for the next Tweet for Code!

Recent Features

  • By
    CSS Animations Between Media Queries

    CSS animations are right up there with sliced bread. CSS animations are efficient because they can be hardware accelerated, they require no JavaScript overhead, and they are composed of very little CSS code. Quite often we add CSS transforms to elements via CSS during...

  • By
    Create Namespaced Classes with MooTools

    MooTools has always gotten a bit of grief for not inherently using and standardizing namespaced-based JavaScript classes like the Dojo Toolkit does.  Many developers create their classes as globals which is generally frowned up.  I mostly disagree with that stance, but each to their own.  In any event...

Incredible Demos

  • By
    Fx.Rotate:  Animated Element Rotation with MooTools

    I was recently perusing the MooTools Forge and I saw a neat little plugin that allows for static element rotation: Fx.Rotate. Fx.Rotate is an extension of MooTools' native Fx class and rotates the element via CSS within each A-grade browser it...

  • By
    Vertically Centering with Flexbox

    Vertically centering sibling child contents is a task we've long needed on the web but has always seemed way more difficult than it should be.  We initially used tables to accomplish the task, then moved on to CSS and JavaScript tricks because table layout was horribly...

Discussion

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