Skip to content

Instantly share code, notes, and snippets.

View paulonteri's full-sized avatar
💻
Building

Paul Onteri paulonteri

💻
Building
View GitHub Profile
@paulonteri
paulonteri / cloud_build.yaml
Created October 31, 2021 05:43
Deploy a React Native app to PlayStore using Google Cloud Build
timeout: 3600s
logsBucket: 'gs://$_CACHE_BUCKET'
options:
# machineType: 'E2_HIGHCPU_8'
steps:
- name: 'reactnativecommunity/react-native-android'
entrypoint: bash
args:
- -c
@paulonteri
paulonteri / email_sender.py
Last active December 14, 2021 14:57 — forked from ninapavlich/email_sender.py
Convert HTML emails with python
import os
import re
from email.mime.image import MIMEImage
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from smtplib import SMTP, SMTP_SSL, SMTPAuthenticationError, SMTPException
from urllib.parse import urlparse
import requests
from bs4 import BeautifulSoup
from jinja2 import Template
@paulonteri
paulonteri / search_suggest_system.py
Created November 20, 2021 10:09
Search Suggestions System
"""
- given: products, searchword
- suggests at most 3 (common prefix)
- after each character is typed
BF: (P.W + P log P) * S
- search arr, get all words with prefix
- sort by lexographic order, return top 3
@paulonteri
paulonteri / README.md
Last active May 11, 2022 09:20
Django model cron jobs. Clone of https://djangosnippets.org/snippets/1127

Django model cron jobs

Clone of https://djangosnippets.org/snippets/1127

Author: willhardy Posted: October 11, 2008

Inspired by snippet 1126, I thought I would post a module that stores crontab entries in a database, with a less powerful, but more end-user friendly API. ("twice a week starting on Sat 1 Dec 2007, 6:23am", instead of "23 6,18 * ").

The crontab is synchronised when an entry is changed, and relevant environment variables, function name and arguments are provided. You might want to store this as an app called "scheduler" to match the imports.

@paulonteri
paulonteri / create_cloudflare_txt_file.py
Last active January 10, 2022 06:28
Used to transer from Google Cloud DNS to Cloudflare DNS. This is after exporting the Google Cloud DNS config to a yaml file.
import yaml
with open("records.yaml", "r") as stream:
with open('cloudflare.txt', 'w+') as cloudflare_file:
docs = yaml.load_all(stream)
for doc in docs:
item = dict(doc.items())
@paulonteri
paulonteri / django.yaml
Created January 17, 2022 08:26
Deploy Django to Cloud Run
name: Deploy Backend Production
on:
push:
branches:
- production
paths:
- "backend/**"
workflow_dispatch:
@paulonteri
paulonteri / RichTextEditor.jsx
Created February 17, 2022 06:23
Adding Ckeditor5 to Next JS / React
import React, { useEffect, useRef, useState } from "react";
function Editor({ onChange, editorLoaded, name, value }) {
const editorRef = useRef();
const { CKEditor, ClassicEditor } = editorRef.current || {};
useEffect(() => {
editorRef.current = {
CKEditor: require("@ckeditor/ckeditor5-react").CKEditor, // v3+
ClassicEditor: require("@ckeditor/ckeditor5-build-classic")
@paulonteri
paulonteri / terms_of_service.markdown
Created August 4, 2022 20:55 — forked from sirshurf/terms_of_service.markdown
A general Terms of Service under the Creative Commons License

Terms of Service

Last revised on [DATE]

The Gist

[COMPANY] operates the [SERVICE] service, which we hope you use. If you use it, please use it responsibly. If you don't, we'll have to terminate your account.

For paid accounts, you'll be charged on a monthly basis. You can cancel anytime, but there are no refunds.

Privacy Policy

Last revised on [DATE]

The Gist

[COMPANY] will collect certain non-personally identify information about you as you use our sites. We may use this data to better understand our users. We can also publish this data, but the data will be about a large group of users, not individuals.

We will also ask you to provide personal information, but you'll always be able to opt out. If you give us personal information, we won't do anything evil with it.