Skip to content

Instantly share code, notes, and snippets.

aahed
aalii
aapas
aargh
aarti
abaca
abaci
aback
abacs
abaft

I dug into it tonight and got it working. Here's the CloudFormation setup I'm using. I ordered the properties in the same order you'd find them on the console GUI if you were setting it up that way:

Thank you to https://github.com/yvele, this is essentially his set up with a few added details.

Note 1: The ForwardedValues property is deprecated and it seems that eventually we'll have to change to a CachePolicy and OriginRequestPolicy. I tried a few different setups but unfortunately I couldn't get it to work using those.

Note 2: After you get the CloudFront Distribution up and running, don't forget to change your app to switch to the new endpoint! i.e. fetching from https://something.appsync-api.region.amazonaws.com/graphql -> https://something.cloudfront.net/graphql

AWSTemplateFormatVersion: 2010-09-09
@phi-line
phi-line / scraper.py
Created February 23, 2019 00:08
Broken cat scraper
import asyncio
import pyppeteer as pyp
from pyppeteer import launch
from bs4 import BeautifulSoup
async def main():
browser = await launch(
headless=True,
devtools=True,
autoClose=False,
@phi-line
phi-line / email-dot-encoder.py
Last active October 10, 2018 23:02
Dot Encoder for gmail usernames
"""
I ran into this issue when trying to bot a site with contact form messages.
After trying to mass send with an address like '[email protected]' but after some sends they banned it from sending mail.
First, I used a f'+{id}' alias onto the email which usually works but this site prevented special characters.
The idea after this point was to encode dots into the gmail username.
Personal gmail accounts ignore dots in email usernames so '[email protected]' == '[email protected]'
By exploiting this trick we can encode in binary, any int.
So, the number '5' is '101' in binary, and encoded into '[email protected]' becomes '[email protected]' where 1's are dots.
# virtualenv --python=/usr/local/bin/python2.7 <path/to/new/virtualenv/
# virtualenv --python=/usr/local/bin/python3.7 <path/to/new/virtualenv/
set_python_version() {
while true; do
echo -n "Please choose Python2 or Python3 (2/3): "
read python_version
if [ "$python_version" = "2" ]; then
echo "Activating: Python 2.7 >> ~/env/bin/activate"
export PYTHONPATH=/Users/username/env/lib/python2.7/site-packages:/Users/username/git
@phi-line
phi-line / nuke_html
Last active July 31, 2018 21:54
The most annoying command to find on the internet (find pattern and delete file)
`find cache -type f -exec grep -q "\<HTML\>" {} \; -delete`
// https://superuser.com/questions/585391/on-linux-how-can-i-find-all-files-that-contain-a-string-and-delete-them
def print_c(message):
"""
Clears last carriage returned line and writes a new one
:param message: (str)
:return: None
"""
sys.stdout.write('\x1b[2K')
sys.stdout.write(message)
sys.stdout.flush()
@phi-line
phi-line / index.html
Created May 9, 2018 23:29
Quadratic Mesh Circle
<html>
<body>
<canvas></canvas>
</body>
@phi-line
phi-line / coin_flip.py
Last active October 19, 2018 20:42
Simple coin toss
from subprocess import call
from gtts import gTTS
from random import randint, seed
import os
def flip():
text = ["It is heads", "It is tails"]
return text[randint(0,1)]