Skip to content

Instantly share code, notes, and snippets.

View v1shwa's full-sized avatar
:octocat:
⚡️

Vishwa v1shwa

:octocat:
⚡️
View GitHub Profile
@v1shwa
v1shwa / foo.log
Created February 12, 2016 16:15 — forked from ibeex/foo.log
Flask logging example
A warning occurred (42 apples)
An error occurred
@v1shwa
v1shwa / gist:f7bbdc234bdc5df0ed0c8eadb9e19d48
Created April 3, 2016 05:19 — 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

@v1shwa
v1shwa / ISO 3166-1 alpha-2 code
Last active April 13, 2016 05:52
Country Codes ISO 3166-1 alpha-2 code
[
{
"Name": "Afghanistan",
"Code": "AF"
},
{
"Name": "Åland Islands",
"Code": "AX"
},
{
@v1shwa
v1shwa / get-social-shares
Created April 14, 2016 06:12 — forked from ihorvorotnov/get-social-shares
Get number of shares from social platforms
Facebook*:
https://api.facebook.com/method/links.getStats?urls=%%URL%%&format=json
+ works, returns shares, likes, comments and total
Twitter:
http://urls.api.twitter.com/1/urls/count.json?url=%%URL%%&callback=twttr.receiveCount
+ v1 API but still works
Reddit:
http://buttons.reddit.com/button_info.json?url=%%URL%%
@v1shwa
v1shwa / keybase.md
Created May 23, 2016 19:31
keybase.md

Keybase proof

I hereby claim:

  • I am v1shwa on github.
  • I am v1shwa (https://keybase.io/v1shwa) on keybase.
  • I have a public key whose fingerprint is 8EB4 0D20 3DBB A582 FD59 6269 5603 1371 358A 520A

To claim this, I am signing this object:

@v1shwa
v1shwa / access-modifier.md
Created June 22, 2016 08:50
Access Modifiers in Java
Access modifier  Class  Package  Subclass  Any Class
private            Y       N         N         N 
[no specifier]     Y       Y         N         N 
protected          Y       Y         Y         N 
public             Y       Y         Y         Y 
# Copyright (c) 2013 Georgios Gousios
# MIT-licensed
# Edited to handle two new tables: postLinks and tags that are present in the 2014 dataset
create database stackoverflow DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
use stackoverflow;
create table badges (
Id INT NOT NULL PRIMARY KEY,
@v1shwa
v1shwa / swap.sh
Created December 19, 2016 08:09
Quick temporary swap
#!/bin/bash
sudo fallocate -l 4G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
# Verification
sudo swapon -s
@v1shwa
v1shwa / matplotlib-issue.md
Created January 5, 2017 06:17
Matplotlib font cache issue
  • Remove the lib cache rm -rf ~/.cache/matplotlib
  • Done!