Skip to content

Instantly share code, notes, and snippets.

View diva-D's full-sized avatar

David Gentile diva-D

View GitHub Profile
@diva-D
diva-D / Update Multiple Google Apps Script projects.py
Created June 14, 2022 22:04
The script_ids.json file is simply a list of script id strings.
import json
import os
import subprocess
# replace with id of your template
template_id_string = '{ "scriptId": "1emazMPaUkLHXbgbEF0nOKwU275gL7H5cwue909bVMtkp2czm_tB5XYwH" }'
def run_update(id):
new_clasp_string = f'{{ "scriptId": "{id}" }}'
# overwrite the clasp file
@diva-D
diva-D / Airtable metadata.js
Last active June 8, 2022 01:40
Visit https://airtable.com/api and select a base. Then open your browsers console (Developer Tools) and run the following https://community.airtable.com/t/metadata-api-for-schema-and-mutating-tables/1856/6
var myapp = {
id:window.application.id,
name:window.application.name,
tables:[]
};
for (let table of window.application.tables){
var mytable = {
id:table.id,
@diva-D
diva-D / html coverage config file.txt
Created May 26, 2022 04:05
https://coverage.readthedocs.io/en/6.4/config.html#config omit is for files/folders you want to not be included in report exclude lines are the ones that shouldn't be covered in report
[run]
omit = *tests*, *venv*, */usr/local/lib*, config.py
[report]
exclude_lines =
if __name__ == .__main__.:
@diva-D
diva-D / Setup mock dynamodb table for testing.py
Created April 27, 2022 22:02
This example also shows how to use it for the "Flow" framework to replace the automatically created database instance with the mock one
import os
import boto3
import pytest
from moto import mock_dynamodb2
from flow import Flow, FlowDynamoDB
flow = Flow(name="test", database=FlowDynamoDB())
def create_table():
# git only
git rm -r --cached .env
# commit and push to delete (but still in previous history)
# remove from Github history
git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch .env" HEAD
git push --force
# file still there but content will be empty
dicts = [{...},{...}, {...}]
with open('output.json', 'w') as f:
json_data = json.dumps(dicts)
f.write(json_listings)
r"^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$"
r"http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+"
r"(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)"