Skip to content

Instantly share code, notes, and snippets.

View scottshane's full-sized avatar

Scott Hoffman scottshane

View GitHub Profile

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

svn st | grep '^?' | awk '{print $2}' | xargs rm -rf
#!/usr/bin/perl
# svn-clean - Wipes out unversioned files from SVN working copy.
# Copyright (C) 2004, 2005, 2006 Simon Perreault
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
@scottshane
scottshane / xhr.js
Last active January 26, 2017 03:51
tiny xhr constructor
const xhr = new window['XMLHttpRequest' || 'ActiveXObject']('MSXML2.XMLHTTP.3.0');
let res;
xhr.open('GET', 'some/api/endpoint');
xhr.responseType = 'json';
xhr.onreadystatechange = function () {
if (this.status === 200 && this.readyState === 4) {
resp = this.response;
}
}
@scottshane
scottshane / proxy-reflect.js
Last active January 28, 2018 12:11
Proxy / Reflect Experiment
var targetObject = {
sayHi(){ return `returning show: ${p.show}` },
show: 'family guy',
characters: {
dad: 'peter',
mom: 'lois',
daughter: 'meg',
son: 'chris',
baby: 'stewie',
dog: 'brian'
@scottshane
scottshane / numeric-palindrome.js
Created January 26, 2017 04:28
next smallest numeric palindrome
function processNum(num) {
var _num = num + "";
var _left;
var _right;
var _palin;
if (_num.length % 2 === 0) {
_left = (~~(_num.substr(0, _num.length/2))+1).toString().split('');
_palin = (~~_left.concat(_left.slice(0).reverse()).join(''));
@scottshane
scottshane / install-sleepwatcher-bluetooth-fix.sh
Created October 24, 2017 19:57 — forked from timgws/install-sleepwatcher-bluetooth-fix.sh
Install sleepwatcher to restart bluetooth & friends
#!/bin/sh
brew install sleepwatcher
# https://gist.github.com/jagtesh/de81fa1c6b45fad0ff8e
sudo cp /usr/local/Cellar/sleepwatcher/2.2/de.bernhard-baehr.sleepwatcher-20compatibility.plist /Library/LaunchAgents/
sudo cp /usr/local/Cellar/sleepwatcher/2.2/etc/sleepwatcher/rc.* /etc/
# Add bluetooth script to /etc/rc.wakeup (the script requires root)
sudo tee -a /etc/rc.wakeup <<EOF
@scottshane
scottshane / disable.sh
Created July 18, 2019 00:34
Disable bunch of #$!@ in Sierra (Version 2.1)
#!/bin/bash
# IMPORTANT: You will need to disable SIP aka Rootless in order to fully execute this script, you can reenable it after.
# WARNING: It might disable things that you may not like. Please double check the services in the TODISABLE vars.
# Get active services: launchctl list | grep -v "\-\t0"
# Find a service: grep -lR [service] /System/Library/Launch* /Library/Launch* ~/Library/LaunchAgents
# Agents to disable
TODISABLE=('com.apple.security.keychainsyncingoveridsproxy' 'com.apple.personad' 'com.apple.passd' 'com.apple.screensharing.MessagesAgent' 'com.apple.CommCenter-osx' 'com.apple.Maps.mapspushd' 'com.apple.Maps.pushdaemon' 'com.apple.photoanalysisd' 'com.apple.telephonyutilities.callservicesd' 'com.apple.AirPlayUIAgent' 'com.apple.AirPortBaseStationAgent' 'com.apple.CalendarAgent' 'com.apple.DictationIM' 'com.apple.iCloudUserNotifications' 'com.apple.familycircled' 'com.apple.familycontrols.useragent' 'com.apple.familynotificationd' 'com.apple.gamed' 'com.apple.icloud.findmydeviced.findmydevi
# define command which will be used when "nvim" is set as a merge tool
[mergetool "nvim"]
cmd = nvim -f -c \"Gdiffsplit!\" \"$MERGED\"
# set "nvim" as tool for merging
[merge]
tool = nvim
# automatically launch merge tool without displaying a prompt
[mergetool]
prompt = false