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 / navigator.geolocation.getAccuratePosition
Created August 5, 2010 19:48
navigator.geolocation.getAccuratePosition
// navigator.geolocation.getAccuratePosition() is an improved version of navigator.geolocation.getCurrentPosition()
//
// getAccuratePosition() is designed and tested for iOS.
//
// The problem with getCurrentPosition() is that it returns an inaccurate position even with "enableHighAccuracy" enabled.
// The problem with watchPosition() is that it calls the success handler every second, and it is resource-intensive.
//
// getAccuratePosition() calls the callback only once, but uses watchLocation() internally to obtain a position that meets your accuracy needs.
// If the timeout is exceeded before a position meeting your accuracy is needed, the best position is returned to the
// success callback, and the error callback does not fire. If you really care about accuracy, you should check it
@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 / 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:1083936
Created July 15, 2011 02:43
postgres table-as-queue lock experiment
#!/bin/bash
# RESULTS, feel free to repro yourself
#
# noLock FAIL
# accessShare FAIL
# rowShare FAIL
# rowExclusive FAIL
# shareUpdateExclusive SUCCESS
# share FAIL+DEADLOCKS
# shareRowExclusive SUCCESS
@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 / heroku_ssl_only.md
Last active December 16, 2020 10:20
Enforce SSL-only (ie disable non-ssl) on Heroku via apache.

The safest way to prevent any non-SSL traffic is to not have your web server listen on http/port 80. This way, people cannot even accidentally transmit sensitive data in an insecure fashion.

Unfortunately Heroku doesn't seem to have a switch to DISABLE non-SSL traffic, but at least we can make the non-SSL traffic die an early death and hopefully minimize the amount of non-SSL traffic ever sent.

With apache, this can be done quickly like so:

    # you might need this
    RewriteEngine On
 
@apinstein
apinstein / ipfw bandwidth throttle.sh
Created August 3, 2009 19:38
ipfw bandwidth throttling
#!/bin/sh
#
# Use ipfw to throttle bandwidth.
# usage:
# ./throttle.sh # Throttle at default (60KB/s)
# ./throttle.sh 5 # Throttle at custom speed (5KB/s)
# ./throttle.sh off # Turn throttling off
# flush rules
ipfw del pipe 1
@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;"
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Dial timeout="15">404-461-9639</Dial>
<Say>Hello, you have reached Tourbuzz. Please leave us a message and we will get back to you as soon as possible.</Say>
<Record transcribe="true" transcribeCallback="http://twimlets.com/voicemail?Email=support@tourbuzz.net"/>
</Response>