Skip to content

Instantly share code, notes, and snippets.

View knagode's full-sized avatar

Klemen Nagode knagode

View GitHub Profile
@hcarver
hcarver / redis-migrate.rb
Created October 6, 2016 20:08
For migrating between Redis databases on Heroku, when the source database doesn't support the sync Redis command
# For migrating between Redis databases on Heroku, when the source database doesn't support sync
# This is useful for migrating away from Redis Cloud, for example.
require "redis"
# You need to have created a new database first, with
# heroku addons:create heroku-redis:hobby-dev -a $APP
# OR
# heroku addons:create heroku-redis:premium-0 -a $APP
@mattsoldo
mattsoldo / pg_index_cache_hit_rate.sql
Last active March 15, 2022 18:26
Postgres Index Hit Rate and Cache Hit Rate
-- Index hit rate
WITH idx_hit_rate as (
SELECT
relname as table_name,
n_live_tup,
round(100.0 * idx_scan / (seq_scan + idx_scan),2) as idx_hit_rate
FROM pg_stat_user_tables
ORDER BY n_live_tup DESC
),
@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