Skip to content

Instantly share code, notes, and snippets.

View olamigokayphils's full-sized avatar

Olamigoke Philip A. olamigokayphils

View GitHub Profile
@olamigokayphils
olamigokayphils / example.py
Created October 16, 2024 11:15
Python Type annotation example[.]py
import datetime
import requests
from typing import Final, TypedDict
MAX_VALUE: Final = 10_000
"""
Special typing construct to indicate final names to type checkers.
A final name cannot be re-assigned or overridden in a subclass.
"""
@olamigokayphils
olamigokayphils / convert_jsondata_to_sql.py
Last active August 22, 2024 12:35
Convert SQL JSON Exports to INSERT Statements
# Basic Script - CONVERT SQL JSON EXPORT TO INSERT STATEMENT
# Convert SQL JSON Exports to INSERT Statements
# Motivation:
# - I got feedup with Workbench import/export functionality. It is unreliable and slow, especially for large datasets or complex schemas.
# - Hopefully i can contribute to Workbench's program soonest.
# - This script aims to provide a more robust and efficient way to migrate data between databases or systems.
# Basic Features of this Script:
@olamigokayphils
olamigokayphils / rock_paper_scissors.py
Created June 11, 2024 13:30
Simple Rock, Paper, Scissors in Python (No Functions)
# Simple Rock, Paper, Scissors in Python (No Functions)
# Educational implementation without functions.
# Feel free to use, modify, and comment on the code.
# Python 3.10 - Rock, Paper, Scissors Game
# Olamigoke Philip 11-06-2024
import random
menu_message = "\n\n\tMenu Options \n1. Enter 'End' to Close Game.\n:"
@olamigokayphils
olamigokayphils / django_logout.py
Created January 31, 2023 09:17
Auto Logout all active Django sessions
import datetime
from django.conf import settings
from django.contrib.auth import logout
from django.contrib.sessions.models import Session
from django.http import HttpRequest
from importlib import import_module
now = datetime.datetime.now()
session_engine = import_module(settings.SESSION_ENGINE)
sessions = Session.objects.filter(expire_date__gt=now)
@olamigokayphils
olamigokayphils / howto
Created December 8, 2020 19:20 — forked from hilkeheremans/howto
Fonts in React Native for Android vs iOS
REACT NATIVE IOS vs ANDROID FONT USE
Tested for React Native 0.41+
IOS:
- Place the fonts in the assets and make sure they are bundled along
- On iOS, fontFamily in Text match the Font Family name as described in Font Book (macOS). Font weights can be specified exactly.
ANDROID:
On Android, there are two ways of using fonts:
@olamigokayphils
olamigokayphils / urls.py
Created November 27, 2020 09:22
Setting up RSS Feed in your Django app
from django.urls import path
from .feeds import LatestEntriesFeed
urlpatterns = [
# ...
path('latest/feed/', LatestEntriesFeed()),
# ...
]
@olamigokayphils
olamigokayphils / feeds.py
Created November 27, 2020 09:20
Setting up RSS Feed in your Django app
from django.contrib.syndication.views import Feed
from django.urls import reverse
from blog.models import BlogPost
class LatestEntriesFeed(Feed):
title = "Blog | Olamigoke Philip"
link = "/feeds/"
description = "I'm Ola; a Full stack web developer. I also ..."
def items(self):
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<style>
#intro {
Afghanistan
Albania
Algeria
Andorra
Angola
Antigua and Barbuda
Argentina
Armenia
Australia
Austria
@olamigokayphils
olamigokayphils / Exm.py
Created May 25, 2017 15:35
worked on my first GUI (simple)program.
#
from tkinter import *
class Application(Frame):
"""A updated Version of delete me. """
def __init__(self, master):
super(Application, self).__init__(master)
self.grid()
self.create_widget()