Skip to content

Instantly share code, notes, and snippets.

View philfreo's full-sized avatar

Phil Freo philfreo

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

If you're interested in a Close Segment Destination, please email [email protected]. 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 September 29, 2021 13:46
Segment workaround due to their incorrect Google Analytics server-side integration

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 November 20, 2020 14:05
Stripe Sigma: Year revenue by country
-- 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
@philfreo
philfreo / README.md
Created June 29, 2020 21:26
Pi-Hole Setup

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 February 3, 2020 21:08
Lambda@Edge function for setting HSTS header for Cloudfront+S3 sites

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

@philfreo
philfreo / README.md
Last active February 3, 2020 23:42
Lambda@Edge Dynamic Redirect Example

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 December 28, 2019 13:06
Homebridge Docker Raspberry Pi Setup

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 August 23, 2021 21:27
Wealthfront Accounts List
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 November 14, 2019 21:38
Testing on Windows from macOS
  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)
#!/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">