Skip to content

Instantly share code, notes, and snippets.

Avatar

Phil Freo philfreo

View GitHub Profile
@philfreo
philfreo / 1_README.md
Last active May 25, 2021
Segment Integration JS
View 1_README.md

If you're interested in a Close Segment Destination, please email phil@close.com. We're actively working on a Segment integration and are looking for testers in the near future. If you need something immediately you can try writing code in Functions using the code below as a starting point.

@philfreo
philfreo / 1. Segment Google Analytics Issue.md
Last active Sep 29, 2021
Segment workaround due to their incorrect Google Analytics server-side integration
View 1. Segment Google Analytics Issue.md

Overview

Problem

If you use Segment's Google Analytics server-side integrations, even if you follow all of their documentation / recommendation, it is impossible to properly track your visitors/sessions in GA from anonymous through identified.

This means that if you use Segment like this, you cannot do very basic things in GA like understanding attribution of your product's sign ups. In GA, a brand new session is created for the identified users, which is not correct.

This problem applies to using Segment on the web with analytics.js when the Google Analytics Destination is set to Cloud Mode, or when using a true server-side Source such as Python/Ruby/Node.

@philfreo
philfreo / readme.sql
Last active Nov 20, 2020
Stripe Sigma: Year revenue by country
View readme.sql
-- breakdown revenue per country
-- we store billing address only in the Charge object
-- NOTE this is rough and there are 2 different country columns to consider here
with
-- transactions table is what we want since we can sum it all up and that will subtract out refunds
-- however we have to join to each Source separately so we can pull out the charge_id for all types of transactions
-- because the charge is what we need for the address, since it doesn't exist on the Customer, nor on the e.g. refund
View README.md

Pi-Hole setup with Docker on Raspberry Pi and Ubiquiti USG

In Raspberry Pi, create a docker-compose.yml file grabbed from here: https://github.com/pi-hole/docker-pi-hole/#quick-start. Tweak timezone.

Then I went to http://rpi.local and saw a Pi-Hole message.

Then I saw that I could login to rpi.local/admin with the password found from sudo docker-compose logs pihole

In Pi-Hole Admin:

  • Settings > DNS
@philfreo
philfreo / README.md
Created Feb 3, 2020
Lambda@Edge function for setting HSTS header for Cloudfront+S3 sites
View README.md

Set this up as an "Origin Response" Cloudfront Trigger.

@philfreo
philfreo / README.md
Last active Feb 3, 2020
Lambda@Edge Dynamic Redirect Example
View README.md

Server-side Redirects

See redirects.json to define or update redirects.

Redirects format

Example for redirects.json

{
@philfreo
philfreo / _Homebridge Docker Raspberry Pi Setup.md
Last active Dec 28, 2019
Homebridge Docker Raspberry Pi Setup
View _Homebridge Docker Raspberry Pi Setup.md

Overview

Setup Homebridge to run via Docker on a Raspberry Pi.

Assume source of truth for files is on laptop, and you want to "deploy" them to Pi upon changes.

One-time setup

  • In this directory, rename config.tpl.json to config.json for Homebridge (bigger sample here) and change the username and pin to something unique).
  • Add any Homebridge plugins to package.json and config.json
@philfreo
philfreo / wealthfront_accounts.js
Last active Aug 23, 2021
Wealthfront Accounts List
View wealthfront_accounts.js
javascript:
document.querySelectorAll('.dashboard-path-global-graph-component,header,.dashboard-path-container-component,.dashboard-loan-card-component,.dashboard-global-sidebar-component,footer,.dashboard-external-account-external-account-card-component-action-links-container,[data-testid=autopilot-learn-more],[aria-label="Link an account"],[data-testid="add-an-account-btn"]').forEach((x) => {
x.remove()
});
document.querySelectorAll('button[title=goals]')[0]?.parentElement?.parentElement?.remove()
document.querySelectorAll('.dashboard-path-global-graph-header-component-retirement-value-label-text')[0]?.parentElement?.parentElement?.remove();
/*
accountsData = [];
document.querySelectorAll('.dashboard-external-account-external-account-card-component,.dashboard-wealthfront-account-card-component').forEach((acct) => {
@philfreo
philfreo / windows_on_macos.md
Created Nov 14, 2019
Testing on Windows from macOS
View windows_on_macos.md
  1. Download & install VirtualBox for OS X
  2. Acquire a Windows 10 environment. Easiest way:
    • Use a maintained fork of ievms, like this:
    • curl -s https://raw.githubusercontent.com/amichaelparker/ievms/master/ievms-node.sh | env IEVMS_VERSIONS="EDGE" bash
  3. Start Windows instance in VirtualBox.
  4. The password for the default Windows IEUser is Passw0rd! (mentioned here)
View ocr-shot.sh
#!/bin/bash
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" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">