Skip to content

Instantly share code, notes, and snippets.

@korya
korya / gist:b56653d786f1e3abdec2
Created October 24, 2015 01:23 — forked from jonathanmoore/gist:2640302
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

@korya
korya / Login shell vs Subshell.md
Last active May 15, 2023 22:36
.bashrc vs .bash_profile

.profile, .bash_profile, .bashrc. The Long Story.

Traditionally, when you log into a Unix system, the system would start one program for you. That program is a shell, i.e., a program designed to start other programs. It's a command line shell: you start another program by typing its name. The default shell, a Bourne shell, reads commands from ~/.profile when it is invoked as the login shell.

Bash is a Bourne-like shell. It reads commands from ~/.bash_profile when it is invoked as the login shell, and if that file doesn't exist¹, it tries reading ~/.profile instead.

@korya
korya / _cassandra-best-practices.md
Last active October 16, 2015 21:40
Cassnadra Best Practices

Cassandra Best Practices

@korya
korya / postal-codes.json
Last active August 26, 2015 15:59 — forked from matthewbednarski/postal-codes.json
Global postal codes regex formats
[{ "Note": "The first two digits (ranging from 10–43) correspond to the province, while the last two digits correspond either to the city/delivery zone (range 01–50) or to the district/delivery zone (range 51–99). Afghanistan Postal code lookup", "Country": "Afghanistan", "ISO": "AF", "Format": "NNNN", "Regex": "^\\d{4}$" }, { "Note": "With Finland, first two numbers are 22.", "Country": "Åland Islands", "ISO": "AX", "Format": "NNNNN", "Regex": "^\\d{5}$" }, { "Note": "Introduced in 2006, gradually implemented throughout 2007.", "Country": "Albania", "ISO": "AL", "Format": "NNNN", "Regex": "^\\d{4}$" }, { "Note": "First two as in ISO 3166-2:DZ", "Country": "Algeria", "ISO": "DZ", "Format": "NNNNN", "Regex": "^\\d{5}$" }, { "Note": "U.S. ZIP codes (range 96799)", "Country": "American Samoa", "ISO": "AS", "Format": "NNNNN (optionally NNNNN-NNNN or NNNNN-NNNNNN)", "Regex": "^\\d{5}(-{1}\\d{4,6})$" }, { "Note":

WAL-E needs to be installed on all machines, masters and slaves.

How to install WAL-E

Only one machine, the master, writes WAL segments via continuous archiving. The configuration for the master postgresql.conf is:

archive_mode = on
archive_command = 'envdir /etc/wal-e.d/env wal-e wal-push %p'
archive_timeout = 60
@korya
korya / Merge a git repo as a subdir.md
Last active August 29, 2015 14:15
Merge a git repo as a subdir

In one of my previous gists, there are instructions for converting a repo subdir to a separate repo. In this git we'll go in opposite direction. Suppose we have 2 git repositories A and B.

Problem

Merge B repo into A as dir b/.

Solution

# Clone A
git clone https://github.com/korya/A
@korya
korya / howto.md
Created January 20, 2015 01:59
Debugging Redis Lua scripts
-- http://www.redisgreen.net/library/ratelimit.html
-- Return Value: 1 if rate limit exceeded, otherwise 0
-- Keys: 1
-- 1. A key to use as an expiring counter, e.g. "ratelimit:ip:127.0.0.1"
-- Args: 2
-- 1. Maximum number of calls
-- 2. Amount of time in ms
local cnt = redis.call('INCR', KEYS[1])
@korya
korya / boot2docker.md
Last active August 29, 2015 14:07
A way to run parrallels/boot2docker

A way to run parrallels/boot2docker suggested by @YungSang suggests in Parallels/vagrant-parallels#115:

Init

$ cd ~/dev/boot2docker
$ vagrant plugin install vagrant-parallels
$ vagrant init parallels/boot2docker
$ vagrant up --provider parallels
$ export DOCKER_HOST="tcp://`vagrant ssh-config | sed -n "s/[ ]*HostName[ ]*//gp"`:2375"