Skip to content

Instantly share code, notes, and snippets.

View vitorio's full-sized avatar

Vitorio Miliano vitorio

View GitHub Profile
@vitorio
vitorio / trynumber.py
Created September 20, 2016 18:06
Manually search for matching local and toll-free Twilio numbers
import twilio
twilio_account_sid = ""
twilio_auth_token = ""
client = twilio.rest.TwilioRestClient(twilio_account_sid, twilio_auth_token)
## By default, Twilio will give you a selection of 30 numbers,
## so you want to search through a variety of patterns to find more
def trynumber(n):
numbers = client.phone_numbers.search(area_code="###", country="US", contains=n)
@vitorio
vitorio / osx-libmagic-homedir.md
Last active February 14, 2019 21:19
Compiling libmagic and libmagic python bindings natively on OS X within your home directory

These instructions compile a native OS X version of libmagic and the libmagic python binding, which use the system magic database, that live in your home directory, and which cannot be moved around, but which should always be discoverable by applications.

Assumes OS X with Xcode or Xcode command-line tools, not macports or homebrew

To install Xcode command-line tools in recent versions of OS X, open Terminal, type xcode-select --install and click "Install"

Older versions of OS X may need to manually download disk images of older versions of Xcode and/or the Xcode command-line tools, as various certificates may have expired (e.g. 10.7.4 requires a manual install from the Xcode 4.6.2 command-line tools image)

Download Apple's latest modified file 5.04 (used in 10.7+) from http://opensource.apple.com/tarballs/file/file-47.tar.gz

@vitorio
vitorio / osx-libmagic-movable.md
Last active August 28, 2016 17:01
Compiling libmagic and libmagic python bindings natively on OS X for use in any directory

These instructions compile a native OS X version of libmagic and the libmagic python binding which use the system magic database, and adjust their internal paths to allow you to use them from any arbitrary working directory, which is normally restricted in versions of OS X with System Integrity Protection.

Assumes OS X with Xcode or Xcode command-line tools, not macports or homebrew

To install Xcode command-line tools in recent versions of OS X, open Terminal, type xcode-select --install and click "Install"

Older versions of OS X may need to manually download disk images of older versions of Xcode and/or the Xcode command-line tools, as various certificates may have expired (e.g. 10.7.4 requires a manual install from the Xcode 4.6.2 command-line tools image)

Download Apple's latest modified file 5.04 (used in 10.7+) from http://opensource.apple.com/tarballs/file/file-47.tar.gz

@vitorio
vitorio / osx-libnfc-homedir.md
Last active August 28, 2016 00:30
Compiling libnfc natively on OS X within your home directory

These instructions compile a native OS X version of libnfc that lives in your home directory, and which cannot be moved around, but should always be discoverable by applications.

Assumes OS X with Xcode or Xcode command-line tools, not macports or homebrew

To install Xcode command-line tools in recent versions of OS X, open Terminal, type xcode-select --install and click "Install"

Older versions of OS X may need to manually download disk images of older versions of Xcode and/or the Xcode command-line tools, as various certificates may have expired (e.g. 10.7.4 requires a manual install from the Xcode 4.6.2 command-line tools image)

Download latest pkg-config (tested with 0.29.1) from https://pkg-config.freedesktop.org/releases/?C=M;O=D

@vitorio
vitorio / osx-libnfc-movable.md
Last active January 16, 2021 08:26
Compiling libnfc natively on OS X for use in any working directory

These instructions compile a native OS X version of libnfc, and adjust its internal paths and those of its dependencies to allow you to use it from any arbitrary working directory, which is normally restricted in versions of OS X with System Integrity Protection.

Assumes OS X with Xcode or Xcode command-line tools, not macports or homebrew

To install Xcode command-line tools in recent versions of OS X, open Terminal, type xcode-select --install and click "Install"

Older versions of OS X may need to manually download disk images of older versions of Xcode and/or the Xcode command-line tools, as various certificates may have expired (e.g. 10.7.4 requires a manual install from the Xcode 4.6.2 command-line tools image)

Download latest pkg-config (tested with 0.29.1) from https://pkg-config.freedesktop.org/releases/?C=M;O=D

@vitorio
vitorio / 01.py
Created February 1, 2016 04:59
(2011) wget + moz-headless-screenshot to take screenshots of archived URLs
# Assumptions:
# moz-headless-screenshot in ./bin
# wget 1.12 in system path
# Ubuntu 10.10 defaults to Python 2.6.6 so we provide 2.7's subprocess module ourselves
# I guess we could also install 2.7
import optparse, urlparse, tempfile, subprocess271 as subprocess, os.path
parser = optparse.OptionParser()
options, args = parser.parse_args()
@vitorio
vitorio / findexifdates.py
Created December 11, 2015 21:56
Flickr API: find and fix "taken on" dates
#CC0 public domain dedication
#Find all the EXIF fields with the letters "date" and output them and their content
import flickrapi
api_key = u''
api_secret = u''
my_photoset = u''
my_user_id = u''
@vitorio
vitorio / testmess.js
Created November 23, 2015 00:12
PhantomJS 2 testing
var page = require('webpage').create(),
system = require('system'),
t, address;
page.onConsoleMessage = function(msg) {
console.log(msg);
};
if (system.args.length === 1) {
console.log('Usage: testmess.js <some URL>');
@vitorio
vitorio / mbox-unique-email-addresses.py
Created March 30, 2015 01:17
So, let's say you have an mbox full of mail and you want to get all the To: addresses out of it. And let's say you've seen a bunch of intimidating complicated examples like http://stackoverflow.com/questions/7166922/extracting-the-body-of-an-email-from-mbox-file-decoding-it-to-plain-text-regard or http://nbviewer.ipython.org/github/furukama/Mini…
# via http://stackoverflow.com/questions/14903664/determine-unique-from-email-addresses-in-maildir-folder
import mailbox
import email
mbox = mailbox.mbox('DADEOL/AOL Mail sorted/Saved.DADEOL Sent.mbox')
uniq_emails = set(email.utils.parseaddr(msg['to'])[1].lower() for msg in mbox)
for a in uniq_emails:
@vitorio
vitorio / microsoft-store.lua
Last active August 29, 2015 14:12 — forked from mbmccormick/microsoft-store.lua
One-time check for Microsoft Store stock
local sku = '309986300'
local zipcode = '10001'
local response = http.request {
url = 'https://rtgliveservices.cloudapp.net/Location/LocationService.svc/NearestSites?zipcode=' .. zipcode .. '&maxRadius=100'
}
local data = json.parse(response.content)
local sites = {}