Skip to content

Instantly share code, notes, and snippets.

View seanmcn's full-sized avatar
🐝

Seán McNamara seanmcn

🐝
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

(function(global) {
var silpUrl = '//s3-eu-west-1.amazonaws.com/silp.shootitlive.com/js/silp.min.js';
// Globals
if(!global.Silp) { global.Silp = {}; };
var Silp = global.Silp;
// To keep track of which embeds we have already processed
if(!Silp.foundEls) Silp.foundEls = [];
@seanmcn
seanmcn / gist:62a021a765ad4f8e593b
Last active February 21, 2024 11:57
The Perfect Web Server - Nginx, Ajenti, Ubuntu
#Insall Ajenti
apt-get update
wget http://repo.ajenti.org/debian/key -O- | apt-key add -
echo "deb http://repo.ajenti.org/ng/debian main main ubuntu" >> /etc/apt/sources.list
apt-get update
apt-get install ajenti
service ajenti restart
# Uninstall Apache2
sudo apt-get autoremove && sudo apt-get remove apache2*
@seanmcn
seanmcn / citeprocjs.js
Created March 12, 2015 05:29
CitationsJS
define(['jquery','citeproc'],function(require){
var cite = {};
var citations = {};
cite.renderCitations = function(){
var cslScheme = $("#id-from-csl-scheme-dropdown").val();
renderBib(cslScheme);
}
// Get the citations that we are supposed to render, in the CSL-json format, I switched async to false here for my setup, btu true is probably fine
@seanmcn
seanmcn / dspace_file_whereami.sql
Last active March 30, 2017 08:22
[Dspace] Get assetstore file path of bitstream using database
/*
Replace :asset_store_path, :handle and :sequence_id
*/
select
':asset_store_path' ||
substring(bit.internal_id, 1, 2) || '/' ||
substring(bit.internal_id, 3, 2) || '/' ||
substring(bit.internal_id, 5, 2) || '/' ||
bit.internal_id
from bitstream bit