Skip to content

Instantly share code, notes, and snippets.

View bgrins's full-sized avatar

Brian Grinstead bgrins

View GitHub Profile
/*
jQuery outerHTML plugin with ownerDocument fix
See: http://www.briangrinstead.com/blog/jquery-outerhtml-snippet
Based off of: http://brandonaaron.net/blog/2007/06/17/jquery-snippets-outerhtml/
*/
$.fn.outerHTML = function() {
var doc = this[0] ? this[0].ownerDocument : document;
return $('<div>', doc).append(this.eq(0).clone()).html();
};
/*
http://lanitdev.wordpress.com/2009/06/08/extending-jquery-to-select-asp-controls/
Enables $(":asp(id)") selector in jQuery for dealing with ASP Server IDs in JavaScript
Example: $(":asp(txtPhoneNumber)")
*/
jQuery.expr[':'].asp = function(elem, i, match) {
return (elem.id && elem.id.match(match[3] + "$"));
};
@bgrins
bgrins / migrate-mq
Created September 21, 2015 18:48
Migrate MQ patch post bug 912121
# npm install -g replace
# back up the patch
cp .hg/patches/PATCHNAME ~/Desktop/PATCHNAME.patch
replace 'browser/devtools/' 'devtools/client/' .hg/patches/PATCHNAME
replace 'toolkit/devtools/server/' 'devtools/server/' .hg/patches/PATCHNAME
replace 'toolkit/devtools/' 'devtools/shared/' .hg/patches/PATCHNAME
replace 'browser/themes/shared/devtools/' 'devtools/client/themes/' .hg/patches/PATCHNAME
/*
An implementation of: http://javascriptweblog.wordpress.com/2010/11/29/json-and-jsonp/
that handles multiple connections at once (don't want to replace the global callback if second
request is sent after the first, but returns before.
*/
(function(global) {
var callbackCounter = 0;
var evalJSONP = function(callback) {
<html>
<head>
<style>
html,body {height:100%;margin:0;padding:0;}
#app {
height:100%;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-box-align:stretch;
@bgrins
bgrins / gist:2713746
Created May 16, 2012 20:37
CoMORichWeb Slides
https://docs.google.com/presentation/d/1Eyns40c5J6n2ep7NUMid7ipSuR-jATF1pdWQNuuwp-4/edit
@bgrins
bgrins / gist:4141504
Last active October 13, 2015 04:47
JS function to copy notes from essays into the title attributes of their links. Can run this straight from the console or add it as a devtools snippet.
// For instance: http://paulgraham.com/growth.html
// Copy the following into devtools console, then you should see note contents when hovering the link
[].forEach.call(document.querySelectorAll("a[href*='#f']"), function(l) {
var to = document.querySelector('[name=' + l.href.split('#')[1] + ']');
var text = '';
while ((to = to.nextSibling) && to.tagName !== "A") {
text+= to.textContent.replace(/\n/g, ' ') + '\n';
}
text = text.replace(/^\s*\]\s*/, '').replace(/\s*\[\s*/, '').replace(/\n{2,}/g, '\n\n');
@bgrins
bgrins / gist:4148366
Created November 26, 2012 14:04
Create a sizzle expression in jQuery 1.8 and older
// Create a sizzle expression using jQuery 1.8 style and older style.
// This one returns elements which have an ID that ends with a string passed in.
// <div id="prefix_test"></div>
// $(":asp(test)")
if ($.expr.createPseudo) {
jQuery.expr[':'].asp = $.expr.createPseudo(function( id ) {
return function(elem) {
return elem.id && elem.id.match(id + "$")
data:text/html,<meta charset='UTF-8'>
<iframe src="data:text/html,<meta charset='UTF-8'><button id='button1'>button1</button>" id="frame-1"></iframe>
<iframe src="data:text/html,<meta charset='UTF-8'><button id='button2'>button2</button>" id="frame-2"></iframe>
<script>
var frame1 = document.querySelectorAll("iframe")[0];
var frame2 = document.querySelectorAll("iframe")[1];
var frame1Button = null;
var frame2Button = null;
hg bookmark -r 98920f7f8a71 bug-xxx-fix
hg update bug-xxx-fix
hg pull mozilla-inbound
hg rebase -b . -d mozilla-inbound
# make sure you're pushing the correct patch :)
hg out -r . mozilla-inbound
hg push -r . mozilla-inbound