Skip to content

Instantly share code, notes, and snippets.

Phil Freo philfreo

Block or report user

Report or block philfreo

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
set -e
CONTENTS=$(tesseract -c language_model_penalty_non_dict_word=0.8 --tessdata-dir /usr/local/share/ "$1" stdout -l eng | xml esc)
hex=$((cat <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">
philfreo / png.js
Created May 30, 2017
PhantomJS program to generate a PNG based on stdin (e.g. SVG image)
View png.js
// PhantomJS program to generate a PNG based on stdin (e.g. SVG image)
// Example: curl | phantomjs png.js > test.png && open test.png
From Flask/Python:
import os
from subprocess import Popen, PIPE, STDOUT
p = Popen(['phantomjs', '%s/png.js' % os.path.dirname(os.path.realpath(__file__))], stdout=PIPE, stdin=PIPE, stderr=STDOUT)
out = p.communicate(input=svg.encode('utf-8'))[0]
strIO = StringIO.StringIO()
philfreo /
Last active Jun 30, 2019
Three ways to make a PDF from HTML in Python (preferred is weasyprint or phantomjs)
def render_pdf_weasyprint(html):
from weasyprint import HTML
pdf = HTML(string=html.encode('utf-8'))
return pdf.write_pdf()
def render_pdf_xhtml2pdf(html):
"""mimerender helper to render a PDF from HTML using xhtml2pdf.
philfreo / Dockerfile
Last active Sep 18, 2018
test dockerfile syntax highlighting
View Dockerfile
FROM ubuntu:14.04.5
#Install newer version of Python 2.7
RUN DEBIAN_FRONTEND=noninteractive && apt-get update && apt-get install -y software-properties-common \
&& add-apt-repository -y ppa:fkrull/deadsnakes-python2.7 && apt-get update \
&& apt-get install -y python2.7=2.7.12-1~trusty1 && rm -rf /var/lib/apt/lists/*
philfreo /
Last active Apr 8, 2018
Make Dash button play iTunes to AirPlay speakers

Uses a (basically free) Amazon Dash Button to play/pause your iTunes music over AirPlay speakers.

Requires OS X and an AirPlay compatible speaker (e.g. Apple TV or any speaker hooked up to AirPort Express).

  1. Install node-dash-button and follow the instructions to get your Dash Button's MAC address.
  2. Install node-applescript
  3. Tweak code as desired, filling in your button's MAC address, name of your AirPlay speakers, etc.
  4. Run via Terminal: node dash_buttons.js
philfreo /
Last active Jul 31, 2018
AWS User script to bootstrap any instance
#!/bin/bash -x
# User script to bootstrap any instance.
# This will set up, array, and format every instance storage
# drive present in the instance (if any)
# The disk format/layout is read from an EC2 tag "DiskLayout"
# (defined in the cloudformation templates) and it defaults to
# "raid0". Possible values are:
# * raidN: grabs all available instance storage drives, creates a
philfreo / filevalidator.js
Created Mar 5, 2016
Detect if a File is a certain type based on its file signature in JavaScript
View filevalidator.js
function(_) {
'use strict';
var fileSignatures = {
'mp3': [
philfreo /
Last active Oct 17, 2015
Python/Flask+Rollbar as logger handler + structlog support
class StructlogRollbarHandler(RollbarHandler):
def __init__(self, prefix, *args, **kwargs):
self.prefix = prefix
super(StructlogRollbarHandler, self).__init__(*args, **kwargs)
def format_title(self, data):
# Keys used to construct the title and for grouping purposes.
KEYS = ['event', 'func', 'exception_name', 'queue']
def format_field(field, value):
philfreo /
Created Aug 31, 2015
See what local processes are listening on any IP address
netstat -na | grep LISTEN | grep -v | grep -v ::1
philfreo /
Created Aug 4, 2015 API Getting Started Guide

Getting Started with the API

The API allows you to connect your app or service directly to your data in to search your existing leads, add new leads, and much more. In this guide, we're going to look at a couple of examples of how to accomplish some basic tasks using the API so that you can get started integrating into your current apps and workflows.

General API Information

Base URL
You can’t perform that action at this time.