Skip to content

Instantly share code, notes, and snippets.

View nickpelton's full-sized avatar

Nick Pelton nickpelton

  • Rocketgenius/Gravityforms
  • Minneapolis, MN
View GitHub Profile
@nickpelton
nickpelton / php-rest
Created April 17, 2014 22:28
PHP Quick Rest
<?php
$method = $_SERVER['REQUEST_METHOD'];
$request = explode("/", substr(@$_SERVER['PATH_INFO'], 1));
switch ($method) {
case 'PUT':
rest_put($request);
break;
case 'POST':
rest_post($request);
@nickpelton
nickpelton / gist:8871572
Created February 7, 2014 20:50
JS debounce issue
setTimeout(function(){
$(window).on('scroll',function(){
console.log('Scroll!');
if($(window).scrollTop() + $(window).height() > $(document).height() - 10){
// loadPosts();
_.debounce(loadPosts(),1000);
}
});
@nickpelton
nickpelton / gist:4566877
Created January 18, 2013 18:20 — forked from jonathanmoore/gist:2640302
Share counts from popular Social Apps

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