This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const LABEL_NAME = "1099expense" | |
const HANDLED_LABEL_NAME = `${LABEL_NAME}_done` | |
const SPREADSHEET_URL = "https://docs.google.com/spreadsheets/d/EXAMPLE-q-EXAMPLE/edit#gid=9999" | |
const SHEET_NAME = "All Business Expenses" | |
const DRIVE_RECEIPTS_FOLDER = "1099 Receipts" | |
// This isn't very efficient and could definitely be refactored | |
// It's overly explicit to allow for easier following/logging | |
function createLabelIfNotExists(labelName) { | |
const label = GmailApp.getUserLabelByName(labelName) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Pi-hole's Lists Updater by Jack'lul | |
; https://github.com/jacklul/pihole-updatelists | |
; Remote list URL containing list of adlists to import | |
ADLISTS_URL="https://v.firebog.net/hosts/lists.php?type=tick" | |
; Remote list URL containing exact domains to whitelist | |
WHITELIST_URL="https://raw.githubusercontent.com/anudeepND/whitelist/master/domains/whitelist.txt" | |
; Remote list URL containing regex rules for whitelisting |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const cfDist = new cloudfront.CloudFrontWebDistribution(this, 'CfDistribution', { | |
comment: 'CDK Cloudfront Secure S3', | |
viewerCertificate: ViewerCertificate.fromAcmCertificate(cert, { | |
aliases: [DOMAIN_NAME, WWW_DOMAIN_NAME], | |
}), | |
defaultRootObject: ROOT_INDEX_FILE, | |
viewerProtocolPolicy: ViewerProtocolPolicy.REDIRECT_TO_HTTPS, | |
httpVersion: HttpVersion.HTTP2, | |
priceClass: PriceClass.PRICE_CLASS_100, // the cheapest | |
originConfigs: [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const cert = new acm.Certificate(this, 'WebCert', { | |
domainName: WWW_DOMAIN_NAME, | |
subjectAlternativeNames: [DOMAIN_NAME], | |
validation: CertificateValidation.fromDns(), | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const accessIdentity = new OriginAccessIdentity(this, 'CloudfrontAccess'); | |
const cloudfrontUserAccessPolicy = new PolicyStatement(); | |
cloudfrontUserAccessPolicy.addActions('s3:GetObject'); | |
cloudfrontUserAccessPolicy.addPrincipals(accessIdentity.grantPrincipal); | |
cloudfrontUserAccessPolicy.addResources(siteBucket.arnForObjects('*')); | |
siteBucket.addToResourcePolicy(cloudfrontUserAccessPolicy); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const siteBucket = new s3.Bucket(this, 'WebsiteBucket', { | |
encryption: BucketEncryption.S3_MANAGED, | |
removalPolicy: RemovalPolicy.DESTROY, | |
autoDeleteObjects: true, | |
// No website related settings | |
accessControl: BucketAccessControl.PRIVATE, | |
publicReadAccess: false, | |
blockPublicAccess: BlockPublicAccess.BLOCK_ALL, | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Based on https://forums.aws.amazon.com/thread.jspa?messageID=832982#832982 | |
import { randomBytes, createHash } from 'crypto'; | |
import { Buffer } from 'buffer'; | |
import fetch from 'node-fetch'; | |
import { URLSearchParams } from 'url'; | |
const base64UrlSafe = (b64: string) => b64.replace(/\+/g, '-').replace(/\//g, '_').replace(/\=/g, ''); | |
async function main() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@asynctest.mock.patch("asyncio.create_subprocess_shell") | |
@pytest.mark.asyncio | |
async def test_list_files(self, mock_subproc_popen): | |
mock_subproc_popen.return_value = AsyncioCreateSubprocessShellCommunicateMock( | |
( | |
b""" | |
a.txt | |
b.txt | |
""", | |
b"", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Used to mock calls to asyncio.create_subprocess_shell | |
# Patches the `communicate` object with a future as specified during construction | |
import asynctest | |
import mock | |
class AsyncioCreateSubprocessShellCommunicateMock: | |
def __init__(self, future_result): | |
process_mock = mock.Mock() | |
future = asynctest.asyncio.Future() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://github.com/pypa/pipenv/issues/3827#issuecomment-521442936 | |
LOCK_FILE=$(find ~/Library/Caches/pipenv | grep lock) | |
sudo rm -rf ${LOCK_FILE} |
NewerOlder