Skip to content

Instantly share code, notes, and snippets.

View adamdharrington's full-sized avatar
🖍️

Adam Harrington adamdharrington

🖍️
View GitHub Profile
@adamdharrington
adamdharrington / github-love.js
Created December 6, 2017 10:57
Add some love to your Github tooltips by running this snippet
document.querySelectorAll('[aria-label]').forEach((el) => {
el.attributes.getNamedItem('aria-label').value = '❤️ ' + el.attributes.getNamedItem('aria-label').value;
})
@adamdharrington
adamdharrington / share.js
Created February 9, 2016 11:31
Get facebook share url with javascript
// Expects the input from Facebook's embed post
// Returns the share post URL
function encodeFB(code){
var opts, match = code.match(/data-href="(.+?)"/);
if (match.length > 1){
opts = {
begin: 'https://www.facebook.com/v2.3/dialog/roadblock/?app_id=966242223397117&redirect_uri=https%3A%2F%2Fwww.facebook.com%2Fv2.3%2Fdialog%2Fshare%3Fredirect_uri%3Dhttps%253A%252F%252Fwww.facebook.com%252Fdialog%252Freturn%252Fclose%26display%3Dpopup%26href%3D',
end : '%26client_id%3D966242223397117%26ret%3Droadblock&display=popup',
url : encodeURIComponent(encodeURIComponent(match[1]))
@adamdharrington
adamdharrington / class-bootstrap-helpers.php
Created January 6, 2016 13:02
Email in a modal form?
<?php
class BootstrapU {
public static function get_modal(array $opts = array()){
$defaults = array(
'classes' => $opts['classes'] ?: "",
'id' => $opts['id'] ?: null,
'header' => $opts['header'] ?: null,
'body' => $opts['body'] ?: null,
'footer' => $opts['footer'] ?: null
function wikiTableRip(t){
var object = {},
heads = (function(){
var cs = t.tHead.children[0],
rets = [];
for(var i=0;i<cs.childElementCount;i++){
rets.push(cs.children[i].innerText);
}
return rets;
})(),
@adamdharrington
adamdharrington / Markdown_toc.xml
Last active February 27, 2023 11:29
Create a Markdown Table of Contents with Notepad++ macros
<Macro name="Markdown - TOC" Ctrl="yes" Alt="yes" Shift="no" Key="219">
<Action type="0" message="2453" wParam="0" lParam="0" sParam="" />
<Action type="0" message="2315" wParam="0" lParam="0" sParam="" />
<Action type="0" message="2177" wParam="0" lParam="0" sParam="" />
<Action type="1" message="2170" wParam="0" lParam="0" sParam="-" />
<Action type="1" message="2170" wParam="0" lParam="0" sParam=" " />
<Action type="1" message="2170" wParam="0" lParam="0" sParam="[" />
<Action type="0" message="2179" wParam="0" lParam="0" sParam="" />
<Action type="1" message="2170" wParam="0" lParam="0" sParam="]" />
<Action type="1" message="2170" wParam="0" lParam="0" sParam="(" />
@adamdharrington
adamdharrington / reading-stylesheets.js
Last active August 29, 2015 14:02
Reading stylesheets
function allStylesheets(){
var links = document.getElementsByTagName('link'),
sheets = new Array();
for (link in links){
if (links[link].hasOwnProperty("rel") && links[link].rel == "stylesheet"){
sheets.push(links[link])
}
}
return sheets;
};
@adamdharrington
adamdharrington / imageBox.js
Last active August 29, 2015 13:57
A simple module providing a single interface method which accepts an ID as a parameter. It wraps all images within the given ID in divs, extracts image alt-text for use as a caption and embeds a new stylesheet in the head of the document.
var __imageBox = (function () {
var setup = function (target) {
$('#' + target + ' img').each(function (img) {
var alt = $(this).attr("alt").toString(),
width = $(this).css("width");
$(this).wrap(
"<div class='imageBoxDiv' width=" + width + "/>"
).after(
"<div class='imageBoxMask'><p>" + alt + "</p></div>"
);
@adamdharrington
adamdharrington / scrollToTop.js
Last active August 29, 2015 13:57
Scroll to Top jQuery module - A really simple jQuery plugin scroll-to-top self-invoking function with HTML and CSS pre-packed.
(function () {
// Back To Top
var b = $('body');
b.append("<a id='toTopBtn' href='#'>▲</a>");
$('#toTopBtn').css({
display: 'none',
fontSize: '1.8em',
textDecoration : 'none',
position: 'fixed',
right: 30,
@adamdharrington
adamdharrington / textify.js
Last active December 27, 2015 11:39
A nice JavaScript function to spell out the price of a given number in CamelCase
/**
* Created by Adam-antium on 27/02/14.
*/
var textify = function (n) {
var nines = Math.floor( ( n % 1000000000 ) / 100000000),
eights = Math.floor( ( n % 100000000 ) / 10000000),
sevens = Math.floor( ( n % 10000000 ) / 1000000),
sixes = Math.floor( ( n % 1000000 ) / 100000),
fives = Math.floor( ( n % 100000 ) / 10000),
fours = Math.floor( ( n % 10000 ) / 1000),