Skip to content

Instantly share code, notes, and snippets.

View zoka123's full-sized avatar

Zoran Antolović zoka123

View GitHub Profile
@zoka123
zoka123 / Quick uninstall JetBrains settings
Created February 12, 2015 16:05 — forked from denji/README.md
Quick uninstall JetBrains settings
Quick uninstall JetBrains settings:
curl -sL https://gist.github.com/denji/9731967/raw/jetbrains-uninstall.sh | bash -s
mount -t vboxsf share /var/www/html/ -o uid=www-data,gid=www-data
sudo lsof -i -n | egrep '\<ssh\>'
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%%
@zoka123
zoka123 / gist:602a4c175202cdee779a
Created April 12, 2015 14:37
convert subtitles on Ubuntu
enconv -L croatian filename.srt -x utf-8
@zoka123
zoka123 / Multiple shell commands with nohup
Created May 9, 2015 11:47
Multiple shell commands with nohup
nohup sh -c 'wget "$0" && wget "$1"' "$url1" "$url2" > /dev/null &
@zoka123
zoka123 / Twitter URL count API
Created June 16, 2015 11:05
Twitter URL stats count
https://cdn.api.twitter.com/1/urls/count.json?url=www.stackoverflow.com

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

@zoka123
zoka123 / Movie subtitle renamer
Created July 17, 2015 13:59
Rename .srt files to match .avi filenames
<?php
$files = scandir(__DIR__);
$pairs = array();
foreach($files as $file){
$type = null;
if (strpos($file,'.srt') !== false) {
@zoka123
zoka123 / gist:7b5650d8953d9d3e18f4
Created August 12, 2015 08:22
Remove docker images and containers
#!/bin/bash
# Delete all containers
docker rm $(docker ps -a -q)
# Delete all images
docker rmi $(docker images -q)