Skip to content

Instantly share code, notes, and snippets.

View asilachev's full-sized avatar
🤖

Alex Silachev asilachev

🤖
View GitHub Profile
@asilachev
asilachev / gist:3529026
Created August 30, 2012 13:55
Facebook access token service usage example
import urllib2
import urllib
FACEBOOK_ID = None
ENCODED_ACCESS_TOKEN = None
ACCESS_TOKEN_MD5 = None
GET_URL = 'http://127.0.0.1:8000/api/facebook/access_token/%s/get'

Keybase proof

I hereby claim:

  • I am asilachev on github.
  • I am asilachev (https://keybase.io/asilachev) on keybase.
  • I have a public key whose fingerprint is 08F6 2EC4 8618 2E5C 19FC 2D21 B8DE F173 CA46 1E05

To claim this, I am signing this object:

Sub Main()
Dim i, f, path, lastCol
f = FreeFile
path = "output.txt"
Open path For Output As #f
lastCol = ActiveSheet.UsedRange.Columns(ActiveSheet.UsedRange.Columns.Count).Column
For i = 1 To lastCol
Print #f, Cells(1, i).Width
Next
@asilachev
asilachev / excel_vb_tools.vb
Last active November 4, 2016 07:27
Excel VB tools
Sub UnhideAllSheets()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
ws.Visible = xlSheetVisible
Next ws
End Sub
Sub HideAllSheets()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
@asilachev
asilachev / gist:92ab4bd698d258939ee6d7ee01b34217
Created September 13, 2016 11:31 — 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

@asilachev
asilachev / get-social-shares
Created September 13, 2016 11:31 — 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%%
@asilachev
asilachev / openpyxl_investigation.py
Last active September 12, 2016 07:06
OpenPyXl investigation
from openpyxl import Workbook
from openpyxl.compat import range
from openpyxl.utils import get_column_letter
wb = Workbook()
dest_filename = 'empty_book.xlsx'
ws1 = wb.active
ws1.title = "range names"
from django.conf import settings
# Defining alphabet of custom base as [a-z] + [A-Z] + [0-9]
alphabet = map(chr, range(97, 123) + range(65, 91)) + map(str, range(0, 10))
base = len(alphabet)
def encode(str):
reversed_str = str[::-1]
pow_num = 0
/usr/bin/plutil -convert xml1 -o - ~/Library/Safari/Bookmarks.plist | grep -E -o '<string>http[s]{0,1}://.*</string>' | grep -v icloud | sed -E 's/<\/{0,1}string>//g'
#! /usr/bin/env python
import json
import os
import re
import urlparse
import configparser
import requests