Skip to content

Instantly share code, notes, and snippets.

View sharpdressedcodes's full-sized avatar

Greg sharpdressedcodes

View GitHub Profile

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter

@sharpdressedcodes
sharpdressedcodes / restore-firefox-session.js
Created March 11, 2015 04:49
Restore a Firefox session after it has crashed and the restore options are disabled in the menu.
/*
Windows:
The session store file is located at
C:\Users\Username\ApPData\Roaming\Firefox\Profiles\YOURPROFILE-NAME\
*/
(function(){
var json = {}; // replace this object with the text from sessionstore.bak
if (typeof json._closedWindows === 'undefined' || json._closedWindows.length === 0)
return;
var tabs = json._closedWindows[0].tabs;
@sharpdressedcodes
sharpdressedcodes / gist:2ec31fb980c230c767c0
Created March 11, 2015 10:36
Fix for "Object library not registered" when trying to load legacy VB6 projects in Win 7.
C:\Windows\SysWOW64\regsvr32 C:\Windows\SysWOW64\MSCOMCTL.OCX
C:\Windows\Microsoft.Net\Framework\v4.0.30319\reglibv12 C:\Windows\SysWOW64\msdatsrc.tlb
@sharpdressedcodes
sharpdressedcodes / detect-browser.js
Last active August 29, 2015 14:16
Detects browser without using User-Agent string.
function detectBrowser(){
return {
isIE: typeof window.MSStream !== 'undefined',
isWebkit: typeof window.webkitAudioContext !== 'undefined',
isFirefox: typeof window.InstallTrigger !== 'undefined',
isSafari: typeof window.beforeLoadEvent !== 'undefined'
};
}
#html_javascript_adder-3 .hjawidget{height:260px;}#html_javascript_adder-3 .hjawidget iframe{height:110%;}
@sharpdressedcodes
sharpdressedcodes / get-domains-from-GTM.js
Created March 16, 2015 21:31
Get domain list from GTM
(function(){
var table = document.querySelector('#ID-containerTable .ID-table .CT_TABLE');
for (var i = 1; i < table.rows.length; i++){
var match = table.rows[i].cells[0].innerHTML.match(/<div(.*?)>(.*?)<\/div>/);
console.log(match[2]);
}
})();
@sharpdressedcodes
sharpdressedcodes / .bashrc-ssh
Last active January 15, 2017 22:37
Automatically load ssh-agent and apply ssh key inside ~/.ssh
SSH_ENV="$HOME/.ssh/environment"
function start_agent {
echo "Initialising new SSH agent..."
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
echo succeeded
chmod 600 "${SSH_ENV}"
. "${SSH_ENV}" > /dev/null
/usr/bin/ssh-add;
}
@sharpdressedcodes
sharpdressedcodes / .logout-ssh
Created January 15, 2017 22:38
Ensure ssh-agent terminates on logout
# Ensure ssh-agent terminates
ssh-add -D
ssh-agent -k
@sharpdressedcodes
sharpdressedcodes / bulletproof-git-workflow.md
Created January 20, 2017 03:15 — forked from db/bulletproof-git-workflow.md
bulletproof git workflow

Bulletproof Git Workflow

start working

git checkout master
git pull
git checkout -b feature/my-work
# edit your files

Bulletproof NPM Workflow

Use the Bulletproof Git Workflow, and before code review:

pre-release package

Publish a pre-release version of the package: