Skip to content

Instantly share code, notes, and snippets.

@gom
gom / gist:1126857
Created August 5, 2011 03:23
Unicode escape / unescape on javascript via http://d.hatena.ne.jp/sawat/20070309/1173459459
var unicode = {
escape: function(s) {
return s.replace(/^[-~]|\\/g, function(m) {
var code = m.charCodeAt(0);
return '\\u' + ((code < 0x10) ? '000' : ((code < 0x100) ? '00' : ((code < 0x1000) ? '0' : ''))) + code.toString(16);
});
},
unescape : function (s) {
return s.replace(/\\u([a-fA-F0-9]{4})/g, function(matched, g1) {
return String.fromCharCode(parseInt(g1, 16))
@benvinegar
benvinegar / breakpoint.js
Created August 8, 2010 23:16
Set JavaScript debugger breakpoints from the console
/**
* Utility lib for setting/unsetting JavaScript breakpoints
*
* Usage:
* breakpoint.set('globalMethodName');
* breakpoint.unset('globalMethodName');
*
* breakpoint.set('namespacedMethodName', namespaceObject);
* breakpoint.unset('namespacedMethodName', namespaceObject);
*/