Skip to content

Instantly share code, notes, and snippets.

@bemasher
bemasher / error.go
Created March 9, 2012 07:30
An error handling package for Golang.
package error
import (
"os"
"fmt"
"runtime"
"path/filepath"
)
// Handle an error for the calling function
@jonathanmoore
jonathanmoore / gist:2640302
Created May 8, 2012 23:17
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

// a very thin convenience wrapper over go's log package
// that also alters the semantics of go log's Error and Fatal:
// none of the functions of this package will ever panic() or
// call os.Exit().
//
// Log levels are prefixed to the user log data for each
// eponymous function i.e. logger.Error(..) will emit a log
// message that begins (after prefix) with ERROR - ..
//
// Package also opts for logger.Lmicroseconds prefix in addition
@NorthIsUp
NorthIsUp / spawn.py
Created July 5, 2012 12:46
gevent spawn helpers
"""
realertime.lib.spawn
~~~~~~~~~~~~~~~~~~~~
:author: Adam Hitchcock
:copyright: (c) 2012 DISQUS.
:license: Apache License 2.0, see LICENSE for more details.
"""
from __future__ import absolute_import
@jedy
jedy / go_scp.go
Last active May 31, 2022 07:20
an example of scp in golang
// https://blogs.oracle.com/janp/entry/how_the_scp_protocol_works
package main
import (
"fmt"
"golang.org/x/crypto/ssh"
)
const privateKey = `content of id_rsa`
@border
border / goauth2-example.go
Created September 1, 2012 16:32
Google goauth2 example
package main
import (
"code.google.com/p/goauth2/oauth"
"crypto/tls"
"io/ioutil"
"log"
"net/http"
"text/template"
)
@rjz
rjz / cs-jq-plugin-template.coffee
Created September 3, 2012 17:01
Coffeescript jQuery Plugin Class Template
# A class-based template for jQuery plugins in Coffeescript
#
# $('.target').myPlugin({ paramA: 'not-foo' });
# $('.target').myPlugin('myMethod', 'Hello, world');
#
# Check out Alan Hogan's original jQuery plugin template:
# https://github.com/alanhogan/Coffeescript-jQuery-Plugin-Template
#
(($, window) ->
@ashchristopher
ashchristopher / coverage_django
Created September 15, 2012 16:44
coverage usage
coverage run manage.py test
coverage report -m
coverage html
@quiver
quiver / new_task.py
Created October 6, 2012 12:15
rabbitmq : dead letter exchange example with python/pika
#!/usr/bin/env python
# http://www.rabbitmq.com/tutorials/tutorial-two-python.html
import pika
import sys
connection = pika.BlockingConnection(pika.ConnectionParameters(
host='localhost'))
channel = connection.channel()
message = ' '.join(sys.argv[1:]) or "Hello World!"