Skip to content

Instantly share code, notes, and snippets.

View dagaa's full-sized avatar

Dag-Arne Alnes dagaa

View GitHub Profile
04615ffe169a5b94aa325b6cd03c424ec895bd1e1022007dd4f0ae26345f3ddb0791dae1fd2bb1138045e95c8acb517d3cd3b5b14196936ca821848952becae798
@dagaa
dagaa / gist:b5b8ae359cc6502a60c6
Last active September 18, 2015 08:11 — forked from jonathanmoore/gist:2640302
Get the share counts from various APIs

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

@dagaa
dagaa / php_stuff
Created September 13, 2013 08:43
Some cool PHP stuff
# Built-in web server since PHP 5.4
In the command line set the path to the document root or where the code lies.
$ cd ~/public_html
$ php -S localhost:8000
-------------------------------------------------------------------------------------------
# Remove duplicate values from the array
@dagaa
dagaa / gist:6256412
Created August 17, 2013 11:07
Inline Character Constants in javascript
<script type="text/javascript">
// Inline Character Constants
var TAB = "\t";
var CR = "\r";
var LF = "\n";
var CRLF = "\r\n";
var FF = "\f";
var DQUOTE = '\"';
var SQUOTE = "\'";
var BACKSLASH = "\\";