Skip to content

Instantly share code, notes, and snippets.

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

@nazieb
nazieb / MY_Loader.php
Created August 21, 2013 10:51
Custom loader library for CodeIgniter to autoload database groups other than $default_group
<?php
class MY_Loader extends CI_Loader {
public function database($params = '', $return = FALSE, $active_record = NULL)
{
parent::database($params, $return, $active_record);
if ( ! defined('ENVIRONMENT') OR ! file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/database.php'))
{
if ( ! file_exists($file_path = APPPATH.'config/database.php'))
@nazieb
nazieb / FacebookFacade.php
Last active December 19, 2015 16:59
Facebook Facade in Laravel 4. Using Facade & Service Provider you can create a global "FB" class which you can call statically in Controllers / Routes / Views. For the example: <?php echo FB::getLoginUrl();
<?php namespace Facebook;
// app/libs/facebook/FacebookFacade.php
use Illuminate\Support\Facades\Facade;
class FacebookFacade extends Facade {
protected static function getFacadeAccessor() { return 'facebook'; }
}
@nazieb
nazieb / base_model.php
Last active December 19, 2015 16:39
Base_Model for CodeIgniter. The idea is taken from Laravel's Eloquent ORM
<?php
/**
* Base Model to provide ORM-like CRUD operation wrapper
* Version: 1.1
*/
class Base_Model extends CI_Model {
protected $table = "";
protected $primary = "id";
protected $per_page = 20;
protected $order = "";
@nazieb
nazieb / Laravel-Global-FIlter-Condition-for-Eloquent.php
Last active December 16, 2015 18:29
This code below is the example how to apply a global filter for Eloquent Models in Laravel (tested with LV 3.2.14). This will be useful if you have data that is stored in one table but has some classification defined by a column (in this example the column name is 'type') and you want to treat them differently in different models.
<?php
class Parents extends Eloquent {
const TYPE_A = 1;
const TYPE_B = 2;
static $type = null;
function __construct($type = null)
{