Skip to content

Instantly share code, notes, and snippets.

@mckamey
mckamey / StringUtils.js
Created July 30, 2010 16:00
.NET-style String.Format implementation for JavaScript
/*global JSON */
if ("undefined" === typeof String.format) {
// String.format: populates a format string with an ordered list of values
/*string*/ String.format = function(/*params*/) {
var args = arguments,
num = args.length,
str = args[0];
@mckamey
mckamey / Foo.MyZebraList.jbst
Created August 14, 2010 16:02
Pygments lexer support for JBST syntax
<%@ Control Name="Foo.MyZebraList" Language="JavaScript" %>
<script type="text/javascript">
/* private members ------------------------------------------ */
/*int*/ function digits(/*int*/ n) {
return (n < 10) ? '0' + n : n;
}
@mckamey
mckamey / EcmaScript.NET-debugger.patch
Created August 23, 2010 15:55
Port of Rhino fix for bug 386997
Index: Projects/EcmaScript.NET/Debugging/DebugFrame.cs
===================================================================
--- Projects/EcmaScript.NET/Debugging/DebugFrame.cs (revision 56306)
+++ Projects/EcmaScript.NET/Debugging/DebugFrame.cs (working copy)
@@ -58,5 +58,11 @@
/// exception object if about to throw exception
/// </param>
void OnExit (Context cx, bool byThrow, object resultOrException);
+
+ /// <summary>
{
"issue" : [
{
"@priority" : "1",
"@type" : "Task",
"@state" : "Fixed",
"@subsystem" : "No subsystem",
"@id" : "DCVR-1",
"@fixedVersion" : "",
"@projectShortName" : "DCVR",
@mckamey
mckamey / doctype.js
Created January 10, 2011 16:57
DocType extraction snippet
function getDocType(document) {
var node = document.firstChild;
while (node) {
var nodeType = node.nodeType;
if (nodeType === 10) {
// doctype
var doctype = '<!DOCTYPE '+(document.documentElement.tagName || 'html').toLowerCase();
if (node.publicId) {
doctype += ' PUBLIC "' + node.publicId + '"';
}
@mckamey
mckamey / AcceptFilter.java
Created March 10, 2011 23:58
Servlet Filter for JAX-RS content negotiation which fixes WebKit Accept header and adds extension support
package org.example.www.filters;
import java.io.IOException;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
/**
* Modifies Accept headers and allows URL extensions to improve JAX-RS content negotiation
* Adds "Vary: accept" header to response
@mckamey
mckamey / LICENSE.txt
Created May 18, 2011 22:17 — forked from 140bytes/LICENSE.txt
Fibonacci
Copyright (c) 2011 Stephen M. McKamey, http://mck.me
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
@mckamey
mckamey / LICENSE.txt
Created May 19, 2011 21:51 — forked from 140bytes/LICENSE.txt
Named string formatting
Copyright (c) 2011 Stephen M. McKamey, http://mck.me
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
@mckamey
mckamey / LICENSE.txt
Created May 19, 2011 21:56 — forked from 140bytes/LICENSE.txt
Indexed string formatting
Copyright (c) 2011 Stephen M. McKamey, http://mck.me
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions: