Skip to content

Instantly share code, notes, and snippets.

@joeldart
joeldart / table-to-md.js
Created September 11, 2015 12:13
html table to markdown bookmarklet
javascript:(function()%7Bvar rows%3Ddocument.querySelectorAll("tr")%3Bvar columnCount%3Drows%5B0%5D.querySelectorAll("td").length%3Bvar headers%3D%5B%5D.map.call(rows%5B0%5D.querySelectorAll("td"),function(e)%7Breturn e.textContent.replace(/%5Cn/gi,"")%3B%7D).join("%7C")%3Bvar seps%3Dnew Array(columnCount).join("---%7C")%2B"---"%3Bvar rowsStr%3D""%3Bfor(var i%3D1%3Bi<rows.length%3Bi%2B%2B)%7BrowsStr%2B%3D%5B%5D.map.call(rows%5Bi%5D.querySelectorAll("td"),function(e)%7Breturn e.textContent.replace(/%5Cn/gi,"")%3B%7D).join("%7C")%2B"%5Cn"%3B%7Dvar finalStr%3Dheaders%2B"%5Cn"%2Bseps%2B"%5Cn"%2BrowsStr%2B"%5Cn"%3Bvar elem%3Ddocument.createElement("PRE")%3Belem.textContent%3DfinalStr%3Bdocument.body.appendChild(elem)%3B%7D)()%3B
@joeldart
joeldart / gist:f7dfa2b191ef2187686d
Last active August 29, 2015 14:25
Bookmarklet to fill in issue-template.md and pullrequest-template.md from project root
<a href='javascript:(function(){$("<div>").load("../edit/master/issue-template.md .commit-create textarea", function () { $("#issue_body").val($(this).find("textarea")[0].textContent)})}())'>
issue-tmpl</a>
<a href='javascript:(function(){$("<div>").load("../edit/master/pullrequest-template.md .commit-create textarea", function () { $("#pull_request_body").val($(this).find("textarea")[0].textContent)})}())'>
pullrequest-tmpl</a>
@joeldart
joeldart / whiteboard_bookmark
Last active December 14, 2015 02:49
Quick and dirty whiteboard in your browser to go with your contenteditable notepad
data:text/html, <html><body><canvas width="1000" height="1000"></canvas><script>var lastPt,canvas,context=(canvas=document.querySelector("canvas")).getContext("2d");function mousedown(e){lastPt ={x:e.pageX,y:e.pageY};}function mousemove(e){if (lastPt){var curr = {x:e.pageX,y:e.pageY};draw(lastPt, curr);lastPt = curr;}}function mouseup(e){mousemove(e);lastPt=null;}function draw(pt1,pt2){ pt2 = pt2 || pt1; context.strokeStyle = "#000000"; context.lineJoin = "round"; context.lineWidth = 5; context.beginPath(); context.moveTo(pt1.x, pt1.y); context.lineTo(pt2.x, pt2.y); context.closePath(); context.stroke(); }canvas.addEventListener("mousedown",mousedown,false);canvas.addEventListener("mousemove",mousemove,false);canvas.addEventListener("mouseup",mouseup,false);</script></body></html>
@joeldart
joeldart / gist:2037810
Created March 14, 2012 16:49
Create child issue
//bookmarklet I whipped up to watch for a new issue to get created, pull out the issue number, and paste it into the comments box
//this bookmarklet only works from the issues page and currently is messy due to some timing issues I was too lazy to fix
javascript:(function(){win=window.open(window.location.href.split("issues")[0]+'issues/new');setTimeout(function(){win.addEventListener("beforeunload",function(){setTimeout(function(){var%20arr=win.location.href.split("/");document.querySelector("[name^=comment]").value="#"+arr[arr.length-1];},2000);},%20false);},2000);}());
@joeldart
joeldart / gist:2037779
Created March 14, 2012 16:43
Hide issues labeled 'nice to have'
//create a bookmark and set the location as below. if you use a different label, you can obviously change it to taste
//bookmarklet only works on the issues page
javascript:(function(){jQuery(".label").filter(function(){return%20$(this).text()=="nice to have";}).closest("tr").hide();}())
@joeldart
joeldart / gist:2037768
Created March 14, 2012 16:41
git pull request shortcut
#depends on currbranch (https://gist.github.com/1483316)
#start is a windows command. for OSX change it to open
git config alias.pullrequest '!curr=$(git currbranch) && git push origin $curr && start https://github.com/<YOUR ORGANIZATION>/<YOUR REPO>/pull/new/$curr'
@joeldart
joeldart / gist:1483316
Created December 15, 2011 22:47
git alias to merge from origin into my feature branch
#obviously could inline, but it's more clear to me written out
git config alias.currbranch 'name-rev --name-only HEAD'
git config alias.updateandthen '!git checkout master && git fetch && git merge origin/master && git checkout'
git config alias.update '!curr=$(git currbranch) && git updateandthen $curr && git merge master || git mergetool'
@joeldart
joeldart / exampleUse.js
Created July 27, 2011 20:27
showDialog deferreds example
$(function () {
$("#deleteAll").click(function () {
$.showDialog("You will lose all your data if you continue.")
.then(function (result) {
if (result) {
$.showDialog("Losing your data is permanent and cannot be restored. Are you sure?", "Loss is permanent", "Yes", "No")
.then(function (result) {
if (result) {
alert("all data lost!");
}
@joeldart
joeldart / gist:1029461
Created June 16, 2011 15:18 — forked from tonydewan/gist:1029399
A terrible attempt at describing our appreciation of ExactTarget's Sponsorship of Indy.js
exactTarget.sponsor(indyJs).then(function (pizza, joy,) {
indyJs.splice(0,0, pizza, joy);
});
/****************jsonpcall.aspx*********************************/
public partial class jsonpcall : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.Write(Request.QueryString["callback"] + "('JSONP SUCCESS')");
Response.End();
}
}
}