Skip to content

Instantly share code, notes, and snippets.

View ldonjibson's full-sized avatar
💭
I may be slow to respond.

Olayanju A. Ajibola ldonjibson

💭
I may be slow to respond.
View GitHub Profile
@ldonjibson
ldonjibson / quotes.py
Created June 25, 2023 03:45 — forked from yashrsharma44/quotes.py
Sample spider for running the new asyncio support in scrapy
import scrapy
from scrapy.Fetch import Fetch
import asyncio
import aiohttp
class QuotesSpider(scrapy.Spider):
name = "quotes"
async def start_requests(self):
urls = [
@ldonjibson
ldonjibson / example.py
Created November 9, 2022 19:14 — forked from bblanchon/example.py
Django Subquery Aggregate (Count, Sum...)
from django.db.models import OuterRef
weapons = Weapon.objects.filter(unit__player_id=OuterRef('id'))
units = Unit.objects.filter(player_id=OuterRef('id'))
qs = Player.objects.annotate(weapon_count=SubqueryCount(weapons),
rarity_sum=SubquerySum(units, 'rarity'))
@ldonjibson
ldonjibson / postgres_manager.py
Created October 3, 2022 02:52 — forked from valferon/postgres_manager.py
Python script to take care of postgres backup and restore of data
#!/usr/bin/python3
import argparse
import logging
import subprocess
import os
import tempfile
from tempfile import mkstemp
import configparser
import gzip
@ldonjibson
ldonjibson / creating-sequence-postgres.sql
Created September 14, 2022 09:09 — forked from slavamokerov/creating-sequence-postgres.sql
Creating sequence in an existing table. PostgreSQL
/*
objects_id_object_seq - sequence name
objects - table name
id_object - ID field name
seq - standard postfix
Doc for setval() and nextval(): https://www.postgresql.org/docs/current/functions-sequence.html
*/
CREATE SEQUENCE IF NOT EXISTS objects_id_object_seq; -- IF NOT EXISTS is works only in Postgres 9.5+
@ldonjibson
ldonjibson / tribearc_email.py
Created September 13, 2022 13:53
Backend to use tribearc mail
import json
from anymail.backends.base_requests import AnymailRequestsBackend, RequestsPayload
from anymail.exceptions import AnymailRequestsAPIError
from anymail.message import AnymailRecipientStatus
from anymail.utils import get_anymail_setting
from django.conf import settings
import requests
class EmailBackend(AnymailRequestsBackend):
"""
@ldonjibson
ldonjibson / firestore-guide.js
Created September 6, 2022 14:47 — forked from vinnihoke/firestore-guide.js
Firestore CRUD Cheat Sheet
// Setup Firestore. Note that all of these will be asyncronous tasks and can have a .then attached. Write in a config process for Firebase. Include the necessary process.env files and instructions how to make a .env file.
***************************************************************
// Add data - C
firestore.collection("CollectionName").add({
key: value,
key: value,
})
@ldonjibson
ldonjibson / pull image from private repo.txt
Last active March 13, 2022 22:00 — forked from rkuzsma/gist:b9a0e342c56479f5e58d654b1341f01e
Example Kubernetes yaml to pull a private DockerHub image
Step by step how to pull a private DockerHub hosted image in a Kubernetes YML.
export DOCKER_REGISTRY_SERVER=https://index.docker.io/v1/
export DOCKER_USER=Type your dockerhub username, same as when you `docker login`
export DOCKER_EMAIL=Type your dockerhub email, same as when you `docker login`
export DOCKER_PASSWORD=Type your dockerhub pw, same as when you `docker login`
kubectl create secret docker-registry myregistrykey \
--docker-server=$DOCKER_REGISTRY_SERVER \
--docker-username=$DOCKER_USER \
@ldonjibson
ldonjibson / commands
Created January 26, 2022 23:32 — forked from toast38coza/commands
Simple systemd unit for running a django app
# start / stop / restart / status
systemctl start test
systemctl stop test
systemctl restart test
systemctl status test
# logs use journalctl:
# tail the logs for unit `django`
journalctl -f -u django
@ldonjibson
ldonjibson / .htaccess
Last active November 17, 2021 08:27 — forked from ivandoric/.htaccess
.htaccess file for video tutorial about deploying Node apps (STRAPI, NEXT, NUXT) to shared hosting. Checkout the video: https://www.youtube.com/watch?v=ebWJbbUT4TA
RewriteEngine On
RewriteRule ^$ http://127.0.0.1:8080/ [P,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://127.0.0.1:1337/$1 [P,L]
@ldonjibson
ldonjibson / flutter.md
Created November 7, 2021 06:59 — forked from matteocrippa/flutter.md
Flutter Cheatsheet

Flutter

A quick cheatsheet of useful snippet for Flutter

Widget

A widget is the basic type of controller in Flutter Material. There are two type of basic Widget we can extend our classes: StatefulWidget or StatelessWidget.

Stateful

StatefulWidget are all the widget that interally have a dynamic value that can change during usage. It can receive an input value in the constructor or reference to functions. You need to create two classes like: