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
    Responsive Images: The Ultimate Guide

    Chances are that any Web designers using our Ghostlab browser testing app, which allows seamless testing across all devices simultaneously, will have worked with responsive design in some shape or form. And as today's websites and devices become ever more varied, a plethora of responsive images...

  • By
    Convert XML to JSON with JavaScript

    If you follow me on Twitter, you know that I've been working on a super top secret mobile application using Appcelerator Titanium.  The experience has been great:  using JavaScript to create easy to write, easy to test, native mobile apps has been fun.  My...

Incredible Demos

  • By
    MooTools CountDown Plugin

    There are numerous websites around the internet, RapidShare for example, that make you wait an allotted amount of time before presenting you with your reward. Using MooTools, I've created a CountDown plugin that allows you to easily implement a similar system. The MooTools JavaScript The CountDown class...

  • By
    MooTools HTML Police: dwMarkupMarine

    We've all inherited rubbish websites from webmasters that couldn't master valid HTML. You know the horrid markup: paragraph tags with align attributes and body tags with background attributes. It's almost a sin what they do. That's where dwMarkupMarine comes in.

Discussion

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