<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>Snipplr</title>
    <description>Recent snippets posted on Snipplr.com</description>
    <link>https://snipplr.com/</link>
    <lastBuildDate>Tue, 09 Jun 2026 10:06:02 +0000</lastBuildDate>
    <item>
      <title>(JavaScript) Multiline Strings [JS 1.6] - Sephr</title>
      <link>https://snipplr.com/view/13805/multiline-strings-js-16</link>
      <description>&lt;p&gt;*Requires JavaScript 1.6 or higher*&#13;
&#13;
Syntax: `mutilineString(_&lt;?string?&gt; processing instruction_)`&#13;
&#13;
**Note**: The string processing instruction cannot include ?&gt; in the string and does not support escaped characters (ie. \u0000)&#13;
&#13;
Example:&#13;
&#13;
    var string =&#13;
    LEFT-ANGLE-BRACKET?string foo&#13;
    bar&#13;
    baz?RIGHT-ANGLE-BRACKET;&#13;
    mutilineString(string) == "foo\nbar\nbaz"&#13;
&#13;
Due to a problem with Snipplr, I can't put processing instructions in the comments. Replace LEFT-ANGLE-BRACKET with &lt; and replace RIGHT-ANGLE-BRACKET with &gt;&lt;/p&gt;</description>
      <pubDate>Sun, 05 Apr 2009 22:15:28 UTC</pubDate>
      <guid>https://snipplr.com/view/13805/multiline-strings-js-16</guid>
    </item>
    <item>
      <title>(Regular Expression) Get HTML5 origin - Sephr</title>
      <link>https://snipplr.com/view/13557/get-html5-origin</link>
      <description>&lt;p&gt;Use this to extract an HTML5 origin from a URI. $1 is the origin.&#13;
&#13;
The square brackets are there to support IPv6 addresses.&#13;
&#13;
Example:&#13;
&#13;
    var html5OriginRegex = /^([\w-]+:\/*\[?[\w\.:-]+\]?(?::\d+)?).*/;&#13;
    "http://www.google.com:42/foo/bar/baz.html".replace(html5OriginRegex, "$1")&#13;
    == "http://www.google.com:42"&lt;/p&gt;</description>
      <pubDate>Sun, 29 Mar 2009 17:27:41 UTC</pubDate>
      <guid>https://snipplr.com/view/13557/get-html5-origin</guid>
    </item>
    <item>
      <title>(JavaScript) ErrorConstructor - Sephr</title>
      <link>https://snipplr.com/view/13546/errorconstructor</link>
      <description>&lt;p&gt;ErrorConstructor produces error constructors that behave the same way as the seven native error constructors.&#13;
&#13;
Usage: `ErrorConstructor([constructorName])`&#13;
&#13;
*If no constructorName is specified, the default of `Error.prototype.name` is used*&#13;
&#13;
Usage for generated error constructor: `errorConstructor([message[, location[, lineNumber]])`&#13;
&#13;
Examples:&#13;
&#13;
    var SecurityError = ErrorConstructor("Security Error"),&#13;
    MarkupError = ErrorConstructor("(X)HTML Markup Error");&#13;
    //these will both throw a SecurityError starting with "Security Error on line 83:"&#13;
    var xss_error = "Possible XSS Vector\n\&#13;
     JSON XHR response parsed with eval()\n\&#13;
     Recommended fix: Parse JSON with JSON.parse";&#13;
    throw new SecurityError(xss_error, "/js/searchResultsJSONloader.js", 83);&#13;
    throw SecurityError(xss_error, "/js/searchResultsJSONloader.js", 83);&#13;
    //these will both throw the following MarkupError:&#13;
    //"(X)HTML Markup Error on line 1: Invalid DOCTYPE"&#13;
    throw new MarkupError("Invalid DOCTYPE");&#13;
    throw MarkupError("Invalid DOCTYPE");&lt;/p&gt;</description>
      <pubDate>Sun, 29 Mar 2009 00:27:52 UTC</pubDate>
      <guid>https://snipplr.com/view/13546/errorconstructor</guid>
    </item>
    <item>
      <title>(JavaScript) Cross-browser Getters/Setters (including IE) - Sephr</title>
      <link>https://snipplr.com/view/13071/crossbrowser-getterssetters-including-ie</link>
      <description>&lt;p&gt;Xccessors is a JavaScript shim that implements the legacy methods for defining and looking up object accessors (getters and setters) of objects in JavaScript using ECMAScript 3.1â€™s accessors standard. This is aimed at adding support for the legacy method in IE8 RC1.&#13;
&#13;
The code is made to have as small of a footprint as possible. YUI minified, the code is 556 bytes. Here is the minified version:&#13;
&#13;
    (function(b,d,c){function a(f,g,e){if(f in d&amp;&amp;!(g in {})){d[c][g]=Element[c][g]=Window[c][g]=HTMLDocument[c][g]=e}}a(b[0],b[2],function(f,e){d[b[0]](this,f,{get:e})});a(b[0],b[3],function(f,e){d[b[0]](this,f,{set:e})});a(b[1],b[4],function(e){return d[b[1]](this,e).get||d[b[1]](this.constructor.prototype,e).get});a(b[1],b[5],function(e){return d[b[1]](this,e).set||d[b[1]](this.constructor.prototype,e).set})})(["defineProperty","getOwnPropertyDescriptor","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"],Object,"prototype");&lt;/p&gt;</description>
      <pubDate>Thu, 12 Mar 2009 20:33:41 UTC</pubDate>
      <guid>https://snipplr.com/view/13071/crossbrowser-getterssetters-including-ie</guid>
    </item>
    <item>
      <title>(JavaScript) string.toCharCodes &amp; String.fromCharCodes [JS 1.8] - Sephr</title>
      <link>https://snipplr.com/view/13069/stringtocharcodes--stringfromcharcodes-js-18</link>
      <description>&lt;p&gt;*Requires JavaScript 1.8 or higher*&#13;
&#13;
Syntax:&#13;
&#13;
`Array string.toCharCodes()` returns an array containing every one of `string`'s character codes, in order.&#13;
&#13;
`String String.fromCharCodes(charCodes)` returns a string created from every character code in the array, `charCodes`.&lt;/p&gt;</description>
      <pubDate>Thu, 12 Mar 2009 19:58:56 UTC</pubDate>
      <guid>https://snipplr.com/view/13069/stringtocharcodes--stringfromcharcodes-js-18</guid>
    </item>
    <item>
      <title>(JavaScript) string.toCharCodes &amp; String.fromCharCodes [JS 1.6] - Sephr</title>
      <link>https://snipplr.com/view/13068/stringtocharcodes--stringfromcharcodes-js-16</link>
      <description>&lt;p&gt;*Requires JavaScript 1.6 or higher*&#13;
&#13;
Syntax:&#13;
&#13;
`Array string.toCharCodes()` returns an array containing every one of `string`'s character codes, in order.&#13;
&#13;
`String String.fromCharCodes(charCodes)` returns a string created from every character code in the array, `charCodes`.&lt;/p&gt;</description>
      <pubDate>Thu, 12 Mar 2009 19:58:52 UTC</pubDate>
      <guid>https://snipplr.com/view/13068/stringtocharcodes--stringfromcharcodes-js-16</guid>
    </item>
    <item>
      <title>(JavaScript) fn.call and fn.apply - Sephr</title>
      <link>https://snipplr.com/view/12899/fncall-and-fnapply</link>
      <description>&lt;p&gt;fn.call and fn.apply are alternative methods to access function.call and function.apply and I don't see fn.call and fn.apply having any use but I made them for the heck of it.&#13;
&#13;
Syntax:&#13;
&#13;
`fn.call(function, [thisObject, [argument1, ..., argumentN]])` is equivalent to `function.call(thisObject, argument1, ..., argumentN)`&#13;
&#13;
`fn.apply(function, [thisObject, [argumentsArray]])` is equivalent to `function.apply(thisObject, argumentsArray)`&#13;
&#13;
Examples:&#13;
&#13;
    function foo(a, b) { return (this*a)-b }&#13;
    fn.call(foo, 5, 6, 7) == 23&#13;
    foo.call(5, 6, 7) == 23&#13;
    fn.apply(foo, 5, [6, 7]) == 23&#13;
    foo.apply(5, [6, 7]) == 23&lt;/p&gt;</description>
      <pubDate>Sat, 07 Mar 2009 13:15:30 UTC</pubDate>
      <guid>https://snipplr.com/view/12899/fncall-and-fnapply</guid>
    </item>
    <item>
      <title>(JavaScript) fn.call and fn.apply [JS 1.8] - Sephr</title>
      <link>https://snipplr.com/view/12898/fncall-and-fnapply-js-18</link>
      <description>&lt;p&gt;*Requires JavaScript 1.8*&#13;
&#13;
fn.call and fn.apply are alternative methods to access function.call and function.apply and I don't see fn.call and fn.apply having any use but I made them for the heck of it.&#13;
&#13;
Syntax:&#13;
&#13;
`fn.call(function, [thisObject, [argument1, ..., argumentN]])` is equivalent to `function.call(thisObject, argument1, ..., argumentN)`&#13;
&#13;
`fn.apply(function, [thisObject, [argumentsArray]])` is equivalent to `function.apply(thisObject, argumentsArray)`&#13;
&#13;
Examples:&#13;
&#13;
    function foo(a, b) (this*a)-b;&#13;
    fn.call(foo, 5, 6, 7) == 23&#13;
    foo.call(5, 6, 7) == 23&#13;
    fn.apply(foo, 5, [6, 7]) == 23&#13;
    foo.apply(5, [6, 7]) == 23&lt;/p&gt;</description>
      <pubDate>Sat, 07 Mar 2009 13:15:22 UTC</pubDate>
      <guid>https://snipplr.com/view/12898/fncall-and-fnapply-js-18</guid>
    </item>
    <item>
      <title>(JavaScript) Get Accessor (Getter/Setter) - Sephr</title>
      <link>https://snipplr.com/view/12836/get-accessor-gettersetter</link>
      <description>&lt;p&gt;`$[gs]etter(obj, property)` returns `function() { return obj.__lookup[GS]etter__(property).apply(obj, Array.prototype.slice.call(arguments)) }`&#13;
&#13;
`object.get[GS]etter(property)` returns `$[gs]etter(this, property)`&#13;
&#13;
Useful for getting the getters and setters of objects like `location`, so you can do stuff like location.getSetter("hash") to get the native hash-changing function.&#13;
&#13;
Example:&#13;
&#13;
    var foo = {a: 5}&#13;
    foo.__defineSetter__("bar", function(x) { return x/this.a })&#13;
    var fooBarSetter = foo.getSetter("bar") // $setter(foo, "bar") also works&#13;
    fooBarSetter(40) == 8&#13;
    &#13;
    var changeHash = location.getSetter("hash")&#13;
    changeHash("test")&#13;
    var getHash = location.getGetter("hash")&#13;
    getHash() == location.hash&#13;
    getHash() == "#test"&#13;
    &#13;
    function changeInnerHTML(el, html) { return el.getSetter("innerHTML")(html) }&#13;
    changeInnerHTML(document.body, "test")&#13;
    document.getSetter("title")("Test")&lt;/p&gt;</description>
      <pubDate>Thu, 05 Mar 2009 16:30:19 UTC</pubDate>
      <guid>https://snipplr.com/view/12836/get-accessor-gettersetter</guid>
    </item>
    <item>
      <title>(JavaScript) Get Accessor (Getter/Setter) [JS 1.8] - Sephr</title>
      <link>https://snipplr.com/view/12835/get-accessor-gettersetter-js-18</link>
      <description>&lt;p&gt;*Requires JavaScript 1.8*&#13;
&#13;
`$[gs]etter(obj, property)` returns `function() obj.__lookup[GS]etter__(property).apply(obj, Array.prototype.slice.call(arguments))`&#13;
&#13;
`object.get[GS]etter(property)` returns `$[gs]etter(this, property)`&#13;
&#13;
Useful for getting the getters and setters of objects like `location`, so you can do stuff like location.getSetter("hash") to get the native hash-changing function.&#13;
&#13;
Example:&#13;
&#13;
    var foo = {a: 5}&#13;
    foo.__defineSetter__("bar", function(x) x/this.a)&#13;
    var fooBarSetter = foo.getSetter("bar") // $setter(foo, "bar") also works&#13;
    fooBarSetter(40) == 8&#13;
    &#13;
    var changeHash = location.getSetter("hash")&#13;
    changeHash("test")&#13;
    var getHash = location.getGetter("hash")&#13;
    getHash() == location.hash&#13;
    getHash() == "#test"&#13;
    &#13;
    function changeInnerHTML(el, html) el.getSetter("innerHTML")(html)&#13;
    changeInnerHTML(document.body, "test")&#13;
    document.getSetter("title")("Test")&lt;/p&gt;</description>
      <pubDate>Thu, 05 Mar 2009 16:26:59 UTC</pubDate>
      <guid>https://snipplr.com/view/12835/get-accessor-gettersetter-js-18</guid>
    </item>
    <item>
      <title>(JavaScript) DOMStorage removeKey - Sephr</title>
      <link>https://snipplr.com/view/12834/domstorage-removekey</link>
      <description>&lt;p&gt;DOMStorage removeKey&#13;
===============&#13;
Syntax: `void domstorage_object.removeKey(key:int)`&#13;
&#13;
This will do the following:&#13;
&#13;
    domstorage_object.removeItem( domstorage_object.key(key) )&lt;/p&gt;</description>
      <pubDate>Thu, 05 Mar 2009 16:16:59 UTC</pubDate>
      <guid>https://snipplr.com/view/12834/domstorage-removekey</guid>
    </item>
    <item>
      <title>(JavaScript) APNG Feature Detection - Sephr</title>
      <link>https://snipplr.com/view/12833/apng-feature-detection</link>
      <description>&lt;p&gt;APNG Feature Detection&#13;
================&#13;
This code will set the variable, `apng_supported` to true if APNG and `&lt;canvas&gt;` are supported.&#13;
&#13;
This script requires the following APNG image (157 bytes): http://code.eligrey.com/apng-detect/apng-test.png&lt;/p&gt;</description>
      <pubDate>Thu, 05 Mar 2009 16:13:59 UTC</pubDate>
      <guid>https://snipplr.com/view/12833/apng-feature-detection</guid>
    </item>
    <item>
      <title>(JavaScript) base36 Encode/Decode [JS 1.8] - Sephr</title>
      <link>https://snipplr.com/view/12653/base36-encodedecode-js-18</link>
      <description>&lt;p&gt;base36 Encode/Decode Strings&#13;
====================&#13;
&#13;
*Requires JavaScript 1.8 or higher*&#13;
&#13;
Syntax:&#13;
&#13;
`base36[.ascii].encode(str[, separator]):String`&#13;
&#13;
`base36[.ascii].decode(str[, separator]):String`&#13;
&#13;
Default character separator is ZERO WIDTH SPACE U+200B&#13;
&#13;
Examples:&#13;
&#13;
    base36.encode("foobar", "-") == "2u-33-33-2q-2p-36"&#13;
    base36.decode("2u-33-33-2q-2p-36", "-") == "foobar"&lt;/p&gt;</description>
      <pubDate>Fri, 27 Feb 2009 22:33:58 UTC</pubDate>
      <guid>https://snipplr.com/view/12653/base36-encodedecode-js-18</guid>
    </item>
    <item>
      <title>(JavaScript) konamiCodeListener - Sephr</title>
      <link>https://snipplr.com/view/12619/konamicodelistener</link>
      <description>&lt;p&gt;Adds the `konamiCodeListener` function.&#13;
Syntax: `void konamiCodeListener(function)`&#13;
&#13;
Every time the Konami Code (up,up,down,down,left,right,left,right,b,a) is entered, the function passed to konamiCodeListener will be called.&lt;/p&gt;</description>
      <pubDate>Thu, 26 Feb 2009 20:33:22 UTC</pubDate>
      <guid>https://snipplr.com/view/12619/konamicodelistener</guid>
    </item>
    <item>
      <title>(JavaScript) object.forEach [JS 1.8] - Sephr</title>
      <link>https://snipplr.com/view/12494/objectforeach-js-18</link>
      <description>&lt;p&gt;object.forEach&#13;
=========&#13;
*Requires JavaScript 1.8*&#13;
&#13;
`void object.forEach(function callback(item, value)[, thisObject])`&lt;/p&gt;</description>
      <pubDate>Mon, 23 Feb 2009 00:59:57 UTC</pubDate>
      <guid>https://snipplr.com/view/12494/objectforeach-js-18</guid>
    </item>
    <item>
      <title>(JavaScript) Get Function Name - Sephr</title>
      <link>https://snipplr.com/view/12491/get-function-name</link>
      <description>&lt;p&gt;Get Function Name&#13;
============&#13;
&#13;
This will only return (a string) if the object passed to getFunctionName is a function or an "object" function from IE.&#13;
The function does not rely on function.name if present as it can't always be trusted.&#13;
&#13;
Examples:&#13;
&#13;
    getFunctionName(function Foo(){}) == "Foo"&#13;
    getFunctionName(function(){}) == ""&lt;/p&gt;</description>
      <pubDate>Mon, 23 Feb 2009 00:39:00 UTC</pubDate>
      <guid>https://snipplr.com/view/12491/get-function-name</guid>
    </item>
    <item>
      <title>(JavaScript) Easy Namespacing - Sephr</title>
      <link>https://snipplr.com/view/12490/easy-namespacing</link>
      <description>&lt;p&gt;Easy Namespacing&#13;
================&#13;
This version doesn't require JavaScript 1.8&#13;
&#13;
Examples:&#13;
&#13;
`"foo.bar.baz".namespace()` makes `foo.bar.baz`&#13;
&#13;
`"foo::bar::baz".namespace("::")` makes `foo.bar.baz`&#13;
&#13;
`namespace.call(obj, ns[, separator])` extends `ns` (split by separator or ".") onto `obj`&lt;/p&gt;</description>
      <pubDate>Mon, 23 Feb 2009 00:21:46 UTC</pubDate>
      <guid>https://snipplr.com/view/12490/easy-namespacing</guid>
    </item>
    <item>
      <title>(JavaScript) Easy Namespacing (JS 1.8) - Sephr</title>
      <link>https://snipplr.com/view/12489/easy-namespacing-js-18</link>
      <description>&lt;p&gt;Easy Namespacing&#13;
================&#13;
*Requires JavaScript 1.8*&#13;
&#13;
Examples:&#13;
&#13;
`"foo.bar.baz".namespace()` makes `foo.bar.baz`&#13;
&#13;
`"foo::bar::baz".namespace("::")` makes `foo.bar.baz`&#13;
&#13;
`namespace.call(obj, ns[, separator])` extends `ns` (split by separator or ".") onto `obj`&lt;/p&gt;</description>
      <pubDate>Mon, 23 Feb 2009 00:20:21 UTC</pubDate>
      <guid>https://snipplr.com/view/12489/easy-namespacing-js-18</guid>
    </item>
  </channel>
</rss>
