Skip to content

Instantly share code, notes, and snippets.

View gausam's full-sized avatar

Sam gausam

View GitHub Profile
@gausam
gausam / gist:2922817
Created June 13, 2012 08:37 — forked from joestump/gist:938824
An example of a python-oauth2 provider
class BaseRequestHandler(tornado.web.RequestHandler):
"""Base class for all SimpleGeo request handlers."""
def _handle_request_exception(self, e):
status_code = getattr(e, 'status_code', 500)
self.set_status(status_code)
error = {
'code' : status_code,
'message' : str(e)
@gausam
gausam / gist:3380115
Created August 17, 2012 15:54 — forked from joestump/gist:938824
An example of a python-oauth2 provider
class BaseRequestHandler(tornado.web.RequestHandler):
"""Base class for all SimpleGeo request handlers."""
def _handle_request_exception(self, e):
status_code = getattr(e, 'status_code', 500)
self.set_status(status_code)
error = {
'code' : status_code,
'message' : str(e)

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

@gausam
gausam / angularAppload.js
Created January 12, 2014 10:37
Very simple file uploading in AngularJS no plugins (dirty, but works)
var myApp = angular.module('AppLoad', []);
myApp.factory('formDataObject', function(){
return function(data, headersGetter){
var fd = new FormData();
angular.forEach(data, function(value, key){
fd.append(key, value);
});
@gausam
gausam / Chiko.php
Last active November 4, 2015 16:11
How to mock Expression Engine global object in PHPUnit Tests when developing EE plugins
<?php
//So this would be our plugin file
Class Chiko {
public $ee;
public function __construct()
{
$this->ee =& get_instance();
}
@gausam
gausam / composer.json
Created February 17, 2016 04:37
How to load local packages on your computer with Composer
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"repositories": [
{
"type":"vcs",
"url":"../pay4app/paymentsreminder"
@gausam
gausam / configure.sh
Created May 13, 2016 06:50
PHP Install that worked for me on Ubuntu 16
./configure --prefix=/webstack/php-5.4.34 \
--without-t1lib \
--disable-short-tags \
--enable-pcntl \
--with-tsrm-pthreads \
--with-mysqli \
--with-mysql \
--with-pdo-mysql \
--with-zlib \
--enable-sysvmsg \
@gausam
gausam / gava.html
Created August 11, 2016 08:45
Creating a new Gava checkout via html form
<form name="gava" action="http://example.com/checkout?redirect_to_checkout">
<input type="hidden" name="reference" value="12" />
<input type="hidden" name="amount" value="1.00" />
<input type="hidden" name="return_url" value="http://example.com/thankyou" />
<input type="hidden" name="cancel_url" value="http://example.com/cart" />
<input type="hidden" name="signature" value="0b4b9b07fa062952d1df68a04382a8d0ce1f5fc23e03e53081a14f86f905f6b6ecd2a1bb2cc60157e4a5492cc382292cc10a0c5809fced9ae11cd6ac35f0bd70" />
<input type="submit" />
</form>
@gausam
gausam / gava.php
Last active August 11, 2016 09:26
Creating a new Gava checkout with PHP
<?php
$orderId = 12; //Doesn't have to be numeric
$amount = 1.00;
$returnUrl = "http://example.com/thankyou";
$cancelUrl = "http://example.com/cart";
$payload = [
'reference' => $orderId,
'amount' => $amount,
@gausam
gausam / gava.php
Created August 11, 2016 09:58
Gava checkout lookup in Wordpress
<?php
//Plugin's full code at https://github.com/ihatehandles/gava-for-woocommerce
class WC_Gava extends WC_Payment_Gateway {
/**
* Fetches checkout with given hash.
* A return of false generally means the checkout is not valid to us
* Will exit with error for the other scenarios