Skip to content

Instantly share code, notes, and snippets.

View apinstein's full-sized avatar

Alan Pinstein apinstein

  • Atlanta, GA
View GitHub Profile
@apinstein
apinstein / enumerate_emails.gs
Last active September 18, 2023 19:03
Google Apps Script to enumerate all email addresses active on a domain
/***
* INSTRUCTIONS
* 1. Change the domain in the CONFIG below to your domain.
* 2. Logged in as a Google Workspace admin for the domain of interest, create a new Google Sheet in the Workspace.
* 3. In the sheet, select the menu Extentions > Apps Scripts
* 4. In the script editor, add a Service (with the + in "Services") and add the "AdminDirectory" API.
* 5. Copy/paste this code into the CODE section
* 6. Save & Run the code
* 7. The sheet should be updated with a full inventory of your domain's email address surface area!
*/
@apinstein
apinstein / workspace.code-workspace
Created October 13, 2021 01:57
VSCode llvm debug configuration for php extensions on mac
{
"launch": {
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "attach",
"name": "Attach to running process",
"pid": "${command:pickMyProcess}" // use ${command:pickProcess} to pick other users' processes
},
@apinstein
apinstein / swoole-mutex.php
Last active September 5, 2021 14:55
Mutex and RWMutex for Swoole
<?php declare(strict_types=1);
require __DIR__ . '/../src/bootstrap.php';
require_once __DIR__ . '/../src/Util/Swoole/Utils.php';
use Swoole\Coroutine;
use SneakyStu\Util\Swoole;
// TODO: will this help speed up concurrency servicing (via better scheduler?) not sure if it causes new userland concurrency coding issues
ini_set("swoole.enable_preemptive_scheduler", "1");
@apinstein
apinstein / gist:cb2921cbc93530fda760d8556903eb3b
Last active September 29, 2021 14:18
Apps Script for Google Sheets to implement automatic UUID and LAST UPDATED features.
const headerRowI = 1; // the row with the header cols
const UUID_COLUMN_NAME = 'UUID'
const LAST_UPDATED_COLUMN_NAME = 'LAST UPDATED'
// ENTRY POINTS
// SHEET HOOK ENTRY POINTS
function onEdit(e) {
// Spreadsheet is the 'file', Sheet is the actual sheet, similar but incompatible APIs on different objects, quite the gotcha
var sheet = e.source.getActiveSheet();
@apinstein
apinstein / gist:d94a85207ee015b2d82323cab885969f
Last active January 1, 2017 20:06
Stuff I put on my mac
# Markdown Quicklook plugin
port install qlmarkdown
# multiple clipboard
http://jumpcut.sourceforge.net
# don't go to sleep, sometimes
http://lightheadsw.com/caffeine/
@apinstein
apinstein / gist:917346f203b68d06df7a19e4ed52a2f5
Created December 27, 2016 18:31
R data.table function issue
is_established_customerF <- function(customer_segment, credits_purchased) {
print(typeof(customer_segment)) # prints only once?
established_customer_threshold <- 100000000 # infinitely large
customer_segment <- as.character(customer_segment)
if (customer_segment == "multiple_photographer_company") {
established_customer_threshold <- 3000
} else if (customer_segment == "in_house_photography_department") {
established_customer_threshold <- 1000
} else if (customer_segment == "full_time_single_re_photographer") {
@apinstein
apinstein / factor.r
Created December 18, 2016 20:06
Plotting data via bin'd factors
## DEMO of appropriate way to bin variables with a factor
## this is particularly useful if one wants to bin things of asymmetric widths
## alternative would be non-linear axis
library(ggplot2)
library(grid)
library(gridExtra)
library(data.table)
r <- data.table(x = rgeom(1000, .01))
@apinstein
apinstein / .screenrc.local
Created January 12, 2016 15:09
screenrc for vagrant dev
chdir /opt/www/domains/tourbuzz/current
screen -t db 0 rake db
screen -t code 1
chdir /opt/www/domains/tourbuzz/shared/log
screen -t log 2
@apinstein
apinstein / test-wifi.sh
Last active June 1, 2020 11:07
A simple shell script to test wifi connection over time and record data in a format for easy analysis.
#!/bin/zsh
# configure curl output format
echo '%{url_effective},%{time_namelookup},%{time_connect},%{time_appconnect},%{time_pretransfer},%{time_redirect},%{time_starttransfer},%{time_total}' > curltime.format
# configure postgres
echo "create table wifi_data (ssid text,url_effective text,time_namelookup numeric(9,5),time_connect numeric(9,5),time_appconnect numeric(9,5),time_pretransfer numeric(9,5),time_redirect numeric(9,5),time_starttransfer numeric(9,5),time_total numeric(9,5));"
echo ""
echo "\\\\copy wifi_data from './wifi-data.csv' DELIMITER ',' CSV HEADER"
echo "select ssid, count(*), avg(time_total), stddev(time_total), min(time_total), max(time_total) from wifi_data group by ssid having count(*) > 5;"