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 / 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 / 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 / 1.cron_handler.py
Last active October 21, 2021 14:07
Google Cloud Tasks in Django
import datetime
import json
import logging
import pickle
import sys
import timeit
from time import sleep
from django.conf import settings
from django.core.serializers.json import DjangoJSONEncoder
"""
Node Depths:
The distance between a node in a Binary Tree and the tree's root is called the node's depth.
Write a function that takes in a Binary Tree and returns the sum of its nodes' depths.
Each BinaryTree node has an integer value, a left child node, and a right child node.
Children nodes can either be BinaryTree nodes themselves or None / null.
https://www.algoexpert.io/questions/Node%20Depths
"""
const jsonObj = {"doorsWindows":[{'ID':"A","style":"apple"},{'ID':"B","style":"apple"},{'ID':"C","style":"apple"}]}
const doorsWindowsIds = []
for (var i = 0; i < jsonObj.doorsWindows.length; i++) {
let doorWindow = jsonObj.doorsWindows[i];
doorsWindowsIds.push(doorWindow.ID)
}
console.log(doorsWindowsIds)
@paulonteri
paulonteri / reverse_linked_list_two.py
Created July 19, 2021 19:21
Reverse Linked List II: Given the head of a singly linked list and two integers left and right where left <= right, reverse the nodes of the list from position left to position right, and return the reversed list.
"""
Reverse Linked List II:
Given the head of a singly linked list and two integers left and right where left <= right,
reverse the nodes of the list from position left to position right, and return the reversed list.
Follow up: Could you do it in one pass?
Example 1:
Input: head = [1,2,3,4,5], left = 2, right = 4
Output: [1,4,3,2,5]
@paulonteri
paulonteri / .gitlab-ci.yml
Created May 22, 2021 07:52 — forked from illuzor/.gitlab-ci.yml
Config for gitlab ci android with unit tests and instrumented tests
image: openjdk:8-jdk
variables:
ANDROID_COMPILE_SDK: "29"
ANDROID_BUILD_TOOLS: "29.0.3"
SDK_TOOLS: "6200805" # from https://developer.android.com/studio/#command-tools
EMULATOR_VERSION: "24"
before_script:
- wget --quiet --output-document=android-sdk.zip https://dl.google.com/android/repository/commandlinetools-linux-${SDK_TOOLS}_latest.zip
#!/bin/bash
# Originally written by Ralf Kistner <ralf@embarkmobile.com>, but placed in the public domain
set +e
bootanim=""
failcounter=0
timeout_in_sec=900
@paulonteri
paulonteri / drf_utils.py
Created April 20, 2021 19:44 — forked from twidi/drf_utils.py
Make Django Rest Framework correctly handle Django ValidationError raised in the save method of a model
"""
Sometimes in your Django model you want to raise a ``ValidationError`` in the ``save`` method, for
some reason.
This exception is not managed by Django Rest Framework because it occurs after its validation
process. So at the end, you'll have a 500.
Correcting this is as simple as overriding the exception handler, by converting the Django
``ValidationError`` to a DRF one.
"""
from django.core.exceptions import ValidationError as DjangoValidationError
@paulonteri
paulonteri / Breadcrumbs.js
Created April 4, 2021 17:48
Next.js Breadcrumbs
import React, { useEffect, useState } from "react";
import { useRouter } from "next/router";
import Link from "next/link";
const convertBreadcrumb = (string) => {
return string
.replace(/-/g, " ")
.replace(/oe/g, "ö")
.replace(/ae/g, "ä")
.replace(/ue/g, "ü")