Skip to content

Instantly share code, notes, and snippets.

View devvspaces's full-sized avatar
👩‍💻
Blockchain and Web3

Ayanwola Ayomide devvspaces

👩‍💻
Blockchain and Web3
View GitHub Profile
@devvspaces
devvspaces / db.sql
Created January 22, 2024 09:32
Complex SQL query
WITH ForumMembersWithRanked AS (
WITH ForumMembersRanked AS (
SELECT
"members".*,
"user"."picture" AS "user.picture",
ROW_NUMBER() OVER (PARTITION BY "members"."ForumId" ORDER BY "members"."id") AS row_num
FROM
"ForumMembers" AS "members"
LEFT OUTER JOIN
@devvspaces
devvspaces / deploy.yml
Created September 21, 2023 15:28
Deploying Build artifacts to AWS EC2
name: Deploy Application
on:
push:
branches: [master]
jobs:
deploy:
runs-on: ubuntu-latest
@devvspaces
devvspaces / deploy.bat
Created February 14, 2023 23:06
Batch script for quickly merging dev branch to main branch
@echo off
title Sync with Main Branch
echo Syncing with Main Branch...
@REM accept batch file arguments
set /p commitMessage=Commit Message:
@devvspaces
devvspaces / schema.py
Created December 13, 2022 18:35
Code snippet for wrapping Django restframwork swagger api response with Success, Path, Status
from drf_yasg import openapi
from drf_yasg.inspectors import SwaggerAutoSchema
from drf_yasg.openapi import Schema
class BaseSchema(SwaggerAutoSchema):
def wrap_schema(self, schema):
"""Wrap schema with success, status, message, data and path fields
:param schema: Schema to wrap
@devvspaces
devvspaces / states.md
Last active November 18, 2022 11:23
nigerian states with respective local government areas

Another file output, Format:

{
    "State": ["lga1", "lga2", "..."]
}

Data:

@devvspaces
devvspaces / model_change_func_mixin.py
Created October 24, 2022 07:09
Mixin to monitor changes on model fields, and call a function when a change is detected
from typing import Callable, Dict, List
from django.db import models
class ModelChangeFunc(models.Model):
"""
Mixin to monitor changes on model fields,
and call a function when a change is detected
@devvspaces
devvspaces / managers.py
Created October 21, 2022 05:11
Code snippet from TripValue API consisting of a Vehicle, Trip and Booking managers. The Trip manager is the most interesting, uses django postgres to perform full text search and rank results. The functionality is also built to work fast using caches and optimized complex queries.
import datetime
from typing import Dict, Type, TypeVar, overload
from django.contrib.postgres.search import (SearchQuery, SearchRank,
SearchVector)
from django.db.models import Manager, QuerySet
from utils.base.crypto import hash_digest
from django.core.cache import cache as _cache
from django.conf import settings
from django.core.cache.backends.base import BaseCache
@devvspaces
devvspaces / main.dart
Created October 7, 2022 15:43
console bank
class BankAccount {
String? accountName;
String? accountNumber;
double accountBalance = 0;
BankAccount(String name, String number){
accountName = name;
// Validate account number
RegExp pattern = RegExp(r'^\d+$');
@devvspaces
devvspaces / main.dart
Created October 7, 2022 14:30
console bank
void main() {
for (int i = 0; i < 5; i++) {
print('hello ${i + 1}');
}
}
@devvspaces
devvspaces / main.dart
Created October 6, 2022 18:37
tropical-osmium-7597
void main() {
print(add(3, 2));
print(multiply(12, 2));
print(divide(1, 2));
print(subtract(9, 2));
print(mod(5, 2));
}
num add(int a, b){
return a + b;