Skip to content

Instantly share code, notes, and snippets.

@hopsoft
hopsoft / prefetch.js
Last active December 27, 2023 02:45
Turbolinks Prefetching
const hoverTime = 400
const fetchers = {}
const doc = document.implementation.createHTMLDocument('prefetch')
function fetchPage (url, success) {
const xhr = new XMLHttpRequest()
xhr.open('GET', url)
xhr.setRequestHeader('VND.PREFETCH', 'true')
xhr.setRequestHeader('Accept', 'text/html')
xhr.onreadystatechange = () => {
@JacobBennett
JacobBennett / blog.md
Last active November 4, 2022 20:41
The Hows and Whys of Software Development (Writing a SDLC)
@pjkelly
pjkelly / PgError.md
Last active February 8, 2023 04:49
PG gem error after PostgreSQL upgrade.

When upgrading PostgreSQL on your machine, previously installed versions of the pg Rubygem will complain because their native extensions were compiled against an older version of Postgres. The error will look like this:

[daley (qa)]$ be rake db:create
rake aborted!
LoadError: dlopen(/opt/rubies/2.3.1/lib/ruby/gems/2.3.0/gems/pg-0.18.4/lib/pg_ext.bundle, 9): Library not loaded: /opt/boxen/homebrew/lib/libpq.5.5.dylib
  Referenced from: /opt/rubies/2.3.1/lib/ruby/gems/2.3.0/gems/pg-0.18.4/lib/pg_ext.bundle
  Reason: image not found - /opt/rubies/2.3.1/lib/ruby/gems/2.3.0/gems/pg-0.18.4/lib/pg_ext.bundle
/Users/pjkelly/src/daley/config/application.rb:7:in `<top (required)>'
@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