Skip to content

Instantly share code, notes, and snippets.

@tudisco
tudisco / JavascriptUTF8EncodeDecode.js
Created February 20, 2010 03:22
javascript utf8 encode and decode
//+ Jonas Raoni Soares Silva
//@ http://jsfromhell.com/geral/utf-8 [v1.0]
UTF8 = {
encode: function(s){
for(var c, i = -1, l = (s = s.split("")).length, o = String.fromCharCode; ++i < l;
s[i] = (c = s[i].charCodeAt(0)) >= 127 ? o(0xc0 | (c >>> 6)) + o(0x80 | (c & 0x3f)) : s[i]
);
return s.join("");
},
@eligrey
eligrey / object-watch.js
Created April 30, 2010 01:38
object.watch polyfill in ES5
/*
* object.watch polyfill
*
* 2012-04-03
*
* By Eli Grey, http://eligrey.com
* Public Domain.
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*/
@jlsync
jlsync / Javascript MVC for Ruby-on-Rails.txt
Created June 17, 2010 09:09
Javascript MVC patterns and implementations
http://blog.new-bamboo.co.uk/2010/1/26/why-your-javascript-apps-need-more-structure
http://blog.new-bamboo.co.uk/2010/2/4/let-them-eat-state
http://blog.new-bamboo.co.uk/2010/3/7/the-js-model-layer
http://blog.new-bamboo.co.uk/2010/2/8/rendering-views-in-javascript
Controllers:
http://code.quirkey.com/sammy/ - Sammy is a tiny javascript framework built on top of jQuery. It’s RESTful Evented JavaScript.
@paulirish
paulirish / gist:598008
Created September 26, 2010 15:12
Modernizr lite - broken and deprecated. SEE COMMENT
// Modernizr lite, unofficial. ;)
// usage:
//
// testStyle('box-shadow')
//
// a class of `boxshadow` or `no-boxshadow` is added to the <html> element accordingly.
function testStyle(style){
@jamesu
jamesu / Example.hx
Created March 19, 2012 13:43
Javascript Byte IO for haXe using ArrayBuffers
// Example usage
class Example
{
public static function test()
{
var bytes = new JSByteIO(new ArrayBuffer(128));
// Writing and reading a line
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@frsyuki
frsyuki / my_thoughts_on_msgpack.md
Created June 11, 2012 02:36
My thoughts on MessagePack

My thoughts on MessagePack

Hi. My name is Sadayuki "Sada" Furuhashi. I am the author of the MessagePack serialization format as well as its implementation in C/C++/Ruby.

Recently, MessagePack made it to the front page of Hacker News with this blog entry by Olaf, the creator of the Facebook game ZeroPilot. In the comment thread, there were several criticisms for the blog post as well as MessagePack itself, and I thought this was a good opportunity for me to address the questions and share my thoughts.

My high-level response to the comments

To the best of my understanding, roughly speaking, the criticisms fell into the following two categories.

@domenic
domenic / promises.md
Last active March 31, 2024 14:07
You're Missing the Point of Promises

This article has been given a more permanent home on my blog. Also, since it was first written, the development of the Promises/A+ specification has made the original emphasis on Promises/A seem somewhat outdated.

You're Missing the Point of Promises

Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:

getTweetsFor("domenic", function (err, results) {
 // the rest of your code goes here.
@mattmccray
mattmccray / Makefile
Created October 19, 2012 04:15
Simple comparison of several compile-to-javascript languages, including: CoffeeScript, Dart, Haxe, and TypeScript.
.PHONY: compile
time=/usr/bin/time
compile: dart typescript coffeescript haxe jsx
dart:
$(time) dart2js -ooutput/dart.js source/simple.dart
typescript:
@jdonaldson
jdonaldson / Escape.hx
Created October 31, 2012 19:49
Extended Html escape/unescape methods
class Escape{
/**
Escape HTML special characters of the string.
&, <, >, ", ', `, , !, @, $, %, (, ), =, +, {, }, [, and ]
**/
public static function htmlEscape( s : String ) : String {
return s.split("&").join("&amp;")
.split("<").join("&lt;")
.split(">").join("&gt;")
.split('"').join("&quot;")