Skip to content

Instantly share code, notes, and snippets.

@mrabbitt
mrabbitt / Switch_to_https.bookmarklet.js
Last active September 9, 2017 19:42
Switch to https §
// javascript:(function%20(window)%20{if%20(window.location.protocol%20===%20%27https:%27)%20{window.alert(%27The%20current%20URL%20is%20already%20https:%20<%27%20+%20window.location.href%20+%20%27>%27);}%20else%20{window.location.protocol%20=%20%27https:%27;}})(window);
(function (window) {
if (window.location.protocol === 'https:') {
window.alert('The current URL is already https: <' + window.location.href + '>');
} else {
window.location.protocol = 'https:';
}
})(window);
'''
In response to this meme on Facebook:
https://www.facebook.com/msaeachubaetsmemes/photos/a.1162336560450433.1073741829.1157905574226865/1168097136541042/?type=3
'''
from __future__ import print_function, division, unicode_literals
import requests
from bs4 import BeautifulSoup
url = 'http://www.sec.state.ma.us/ele/eleclk/clkidx.htm'
soup = BeautifulSoup(requests.get(url).text)
@mrabbitt
mrabbitt / Delete_all_cookies.bookmarklet.js
Created May 31, 2014 22:12
Delete all cookies bookmarklet
/**
* Delete all cookies for current site, using all possible domains.
*/
(function()
{
var domains = [document.location.hostname];
var hostParts = document.location.hostname.split('.');
while (hostParts.length > 2)
{
hostParts.shift();
@mrabbitt
mrabbitt / Pinboard_add.bookmarklet.js
Last active August 29, 2015 14:00
Tweaked version of Pinboard "popup with tags" bookmarklet.
/**
* Tweaked version of Pinboard "popup with tags" bookmarklet from
* https://pinboard.in/howto/
*
* - Explicitly focuses on new window to workaround window opening in the
* background on iPhone.
*/
(function() {
var url = location.href;
var description;
@mrabbitt
mrabbitt / pre-commit
Last active December 23, 2015 17:09
Git pre-commit hook to prevent commits which change lines with a specific substring.
#!/bin/sh
# Released as public domain by Michael Rabbitt (github.com/mrabbitt)
#
# Suppress commits with a specific substring in changed connect.
#
# Example (to suppress commits of lines with string DONTCOMMIT):
#
# git config hooks.dontcommit DONTCOMMIT
#
@mrabbitt
mrabbitt / gist.py
Created September 16, 2013 02:19 — forked from brianhsu/gist.py
class GitHubGist(Directive):
""" Embed GitHub Gist.
Usage:
.. gist:: GIST_ID
"""
required_arguments = 1
optional_arguments = 1
@mrabbitt
mrabbitt / mdx_gist.py
Last active December 14, 2015 11:38
Extension to Python Markdown for Embedded Gists
# -*- coding: utf-8 -*-
#
# Copyright (c) 2013 Michael Rabbitt.
#
# 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
import this
(function() {
function addSectionNumber (elem, sectionNumber, parentSection, level) {
var sectionNumberStr = '';
var sectionSpan;
if (level > 1) {
sectionNumberStr = parentSection + '.' + sectionNumber;
} else if (level > 0) {
sectionNumberStr = sectionNumber.toString();
}