AS2 / AS3 Game Score Formatter

Published in: ActionScript, ActionScript 3Posted by Jeremy on 09/11/08

Often when developing games I have the need to add zeros in front of my score depending on how many digits are to be shown. For instance, even though I may have a score of 5, I still need to display 00005 on the screen.

To do this I wrote this useful little function for just that purpose.

trace(formatScore(555, 6)); // 000555 trace(formatScore(-555, 6)); // -000555

function formatScore( value:Number, digits):String {

var scoreStr:String = ''; var tempScore:String = '';

var scoreLen:Number = value.toString().length; var indexOfNeg:Number = value.toString().indexOf('-');

if (value.toString().charAt(0) == '-') {

tempScore = String(value.toString().substring(indexOfNeg+1, scoreLen)); scoreLen--; } for (var i:Number = 0; i<(digits-scoreLen); i++) {

scoreStr += '0'; } var posAnswer:String = String(scoreStr+value.toString()); var negAnswer:String = '-'+String(scoreStr+tempScore.toString()); var answer:String = (indexOfNeg == -1) ? posAnswer : negAnswer;

return answer; }

Jeremy Sykes is a Flash Game Programmer & Developer

CSS Rounded Corner Roundup

Published in: CSSPosted by Jon Henshaw on 07/27/08

The past several years have introduced many different solutions for creating rounded corners using CSS. Some of the solutions use images, while others don’t – while others require assistance from JavaScript. The great thing about Snipplr is that we capture all of these rounded corner techniques on one page. Below is a highlight of some of the best rounded corner techniques.

100% CSS ROUNDED CORNERS !! No IE sorry!

As is common with techniques that use Web standards, when implemented, they don’t work with Internet Explorer (IE). This is one simple technique that uses very simple CSS that adjusts the border radius, but alas, croaks in IE.

Rounded Corners Without Images Or JavaScript

We move onto the next solution that theoretically does work in IE and also doesn’t require images or JavaScript (JS). Unfortunately, it does utilize a lot of CSS code.

Rounded Corners With Images

Failing to be impressed with a lack of images, one can opt for images with this technique. The CSS gets a little shorter and slightly more elegant — now we’re getting somewhere reasonable.

Anti-Aliased Curvy Corners

But if you like to live on the edge and you crave more code that you can shake a stick at, then Curvy Corners is for you. It’s all JS, all the time. It will create on-the-fly rounded corners for any HTML DIV element, that (supposedly) looks as good as any graphically created corners.

If none of the above solutions peak your interest, then feel free to peruse the full list of rounded corner solutions.

Snipplr Ruby Gem, Bringing Snipplr Into the Command Line

Published in: Bash, RubyPosted by narkisr on 07/16/08

Command Line Interface (CLI) has long been my favorite interface when handling code, it makes it easy to edit, search and traverse your code base with tools like vim, find and grep.

Common CLI usage includes the copy and pasting of code snippets. However, keeping track of all those snippets isn’t easy , Snipplr makes the storage and retrieval of snippets easy as pie but requires a Web browser. The Snipplr Ruby Gem is intended to bridge the gap with a simple unified interface. Let’s take for example a scenario on which we would want to get a specific snippet that contains Spring in its title and add it to a file:

Read the rest of this entry »

When a Snippet isn’t a Snippet

Published in: New Features, NewsPosted by Jon Henshaw on 04/09/08

We’ve been getting a lot of snippet entries that are really just spam. Thanks to users like Frank B., we’ve been able to react to it as quickly as possible. However, a better solution for handling this spam is to give our users the ability to flag these snippets themselves.

We’ve implemented a new “Report this Snippet” link that’s located beneath each code snippet box. Clicking on this link will notify us if you think the snippet is spam. There’s also a built in threshold to take the snippet offline if enough unique users click the link.

We’ll see how this system works and will adjust it accordingly. As always, thank you for using Snipplr!

What’s New With Snipplr

Published in: Design, Development, NewsPosted by Jason Tan on 01/17/08

I wanted to write a quick post to update you all on what’s been going on with Snipplr.

First, thank you for your feedback on the new design, both positive and negative. It’s hard to be all things to all people, but we’re going to give it our best shot. Trey is busy working on an alternate style that is more minimalistic, smaller, and has more room to view code. We’d love to give you more control over your preferred interface. In the meantime, I’ve made some small changes to the interface – like making the code editing block more suitable for code on both the new and edit snippet pages.

Aside from the design, I’ve been working to make some system changes:

  • Search. Searching now works more like how you would expect. I’ve also added an advanced search, which allows you to search source code and filter by language.
  • Languages. I added some new languages that were requested and also upgraded GeSHI (for syntax highlighting) to the latest version.
  • Spam. I replaced the math captcha for new user registration with reCAPTCHA and haven’t seen any spam bots try to create an account since.
  • Details. There are lots more minor changes and fixes around the site on both the front and back end. As always, please contact us with any bugs or suggestions you have.

We have lots of more ideas and things in the works, so keep checking back here for the latest news.

Snipplr Launches New Design

Published in: Design, NewsPosted by Jon Henshaw on 01/11/08

We’re proud to announce the launch of the new Snipplr website. The website was redesigned by Shelly Dennison and Scott Holdren, Jason Tan and Trey Piepmeier had a hand in transitioning the website to the new design.

The website has come a long way since Tyler Hall first built it. In the beginning, Snipplr was called Caffeine and it looked like a bare bones Web application from 37 Signals.


Since then, it’s come a long way. The new website has several new features, including the ability to expand the code view. The search has also been completely overhauled and works much better than the last version of the website.

We have some very big features that we’re planning to introduce later this year. Subscribe to our blog and also our Twitter account to keep up with the latest Snipplr news, including beta announcements.

Thanks to everyone who has contributed code snippets to Snipplr over the years. You are what makes Snipplr so great.

Gnome Gedit Plugin For Snipplr

Published in: PluginsPosted by Tyler on 10/31/07

Francisco Jiménez has created a new plugin for Gedit that lets you access your Snipplr snippets from within the editor and post new snippets as well. The plugin uses SnipplrPy – a Python wrapper around the Snipplr API.

Read more about (and download!) the Gedit plugin here.

Many thanks to Francisco and all the other plugin developers!

Snipplr has moved!

Published in: Development, NewsPosted by admin on 10/12/07

In case you hadn’t noticed, Snipplr moved to a new hosting provider, Pair is by far the most reliable and best performing shared hosting environment we have ever worked with. Snipplr will now be faster than ever!

Now that the move is behind us, we’ll be focused on a new development. We expect to launch our new design in the next few weeks, and after that we’ll be focused on some cool new features for Snipplr.

DreamHost Disabled Snipplr Without Warning

Published in: NewsPosted by Tyler on 07/24/07

Snipplr has grown a lot faster than I expected when I created the site a year ago. This month alone we’ve had over 40,000 unique visitors sharing their code with one another. And that’s exactly how many of you were left out in the cold earlier today when Snipplr went down.

I received an email from DreamHost Support notifying me that they had disabled the Snipplr database because they had identified some slow queries running on it. Instead of contacting me directly to resolve the issue they simply turned off the database. No warning, no email, no phone call, nothing. Snipplr simply went down.

I’m working as fast as I can to get Snipplr moved to a new web host who won’t go to such extreme measures without giving advance warning. What DreamHost did is reprehensible, lazy, and the sure sign of a shitty web host.

In the meantime, I’ve gotten Snipplr back up and running until I can move it. Will the site go down again if DreamHost decides to disable it? Probably. So please bear with us as we work past this latest hurdle. I hope you never have to deal with a situation like this on your own website.


PS – The site may go down, but none of your snippets will be lost.

Snipplr Plugin for Eclipse

Published in: API, PluginsPosted by Tyler on 06/06/07

Oliver Nautsch has created snipplr4e – a Snipplr plugin for the Eclipse IDE. The plugin features

  • Preference page to insert and validate your Snipplr API-Key
  • Post a snippet from the eclipse editor to
  • Search your snippets and favorites at
  • Open your snippets and favorites
  • Drag and Drop a snippet from the search result
  • Ctrl+C to copy a snippet from the search result into the clipboard
  • Deleting a snippet at snipplr

Thanks to Oliver for his great work. You can download snipplr4e here.