Skip to content

Instantly share code, notes, and snippets.

View monsur's full-sized avatar

Monsur Hossain monsur

View GitHub Profile
@monsur
monsur / gist:3211294
Created July 30, 2012 22:42
Generate a table comparing the differences between the escape, encodeURI, and encodeURIComponent functions
function createRow(c, tr) {
var td = document.createElement('td');
td.align = 'center';
td.innerHTML = c;
if (c[0] !== '%') {
td.style.backgroundColor = '#ffc';
}
tr.appendChild(td);
}
@monsur
monsur / gist:997408
Created May 29, 2011 02:32
Bookmarklet to create a new Google Doc
// Bookmarklet to create a new Google Doc.
// This updates the bookmarklet from http://noscope.com/journal/2009/04/new-google-doc-favelet
// with the new URL for creating a doc.
javascript:(function(){ window.open('https://docs.google.com/document/create?hl=en_US'); })();
@monsur
monsur / gist:706839
Created November 19, 2010 17:37
Parses the response from XmlHttpRequest.getAllResponseHeaders() into a key/value pair.
/**
* XmlHttpRequest's getAllResponseHeaders() method returns a string of response
* headers according to the format described here:
* http://www.w3.org/TR/XMLHttpRequest/#the-getallresponseheaders-method
* This method parses that string into a user-friendly key/value pair object.
*/
function parseResponseHeaders(headerStr) {
var headers = {};
if (!headerStr) {
return headers;