Skip to content

Instantly share code, notes, and snippets.

View philpoore's full-sized avatar
🏠
Working from home

Phil Poore philpoore

🏠
Working from home
View GitHub Profile
@philpoore
philpoore / a.js
Last active March 18, 2016 09:37 — forked from anonymous/a.js
function Animal(name, numLegs) {
this.name = name;
this.numLegs = numLegs;
};
Animal.prototype.sayName = function() {
console.log('Hi my name is ' + this.name);
};
var penguin = new Animal("Captain Cook", 2);
@philpoore
philpoore / 123.js
Last active March 5, 2016 22:06 — forked from anonymous/123.js
function list() {
contacts.map(printPerson);
};
list();
Inside of the loop, add code to call printPerson, passing in the element of the array that the loop is currently at.
At the very bottom of the file, call the list function. The list function should then loop through every member of the contacts array and print its information.
@philpoore
philpoore / index.js
Created December 7, 2015 09:06 — forked from chrisbuttery/index.js
Control the flow of asynchronous calls with ES6 generator functions
/**
* get - XHR Request
*/
let get = function (url) {
return function (callback) {
let xhr = new XMLHttpRequest();
xhr.open('GET', url);
xhr.onreadystatechange = function() {
let response = xhr.responseText;
@philpoore
philpoore / .bowerrc
Last active August 29, 2015 14:13 — forked from leon/.bowerrc
{
"directory": "bower_components",
"json": "bower.json"
}

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