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 / action.md
Created July 20, 2022 21:32
What is github action all about?

This is an example of a github action that automatically merges master branch with production branch Use cases of this is wide:

  1. Example is automatically running test on your source code and if they passed, you can automatically build the file and push it to production, and then deploy the production branch on an online server

Learn more about github actions here

name: Update Production
@devvspaces
devvspaces / sha1_python.py
Created August 25, 2022 01:07
Creating keyed sha1 hashes and comparing them in time constant
import hashlib
import hmac
def compare_digest(a, b):
"""Compare hashes in constant time."""
return hmac.compare_digest(a, b)
def sha1_hash(message: str, key: str):
@devvspaces
devvspaces / help.md
Last active August 29, 2022 14:58
Encountered problem with network issues when using Ubuntu server linode
@devvspaces
devvspaces / server_vpn.md
Created September 11, 2022 12:51
Creating and Using a VPN Server

Used Digital Ocean and Linode

  • Linode Server was used as the host
  • Linode Server also used as the client

Reading DigitalOcean Reading Linode

Encountered a problem with Dns Resolution Used this to resolve it Article

Steps:

@devvspaces
devvspaces / main.py
Created October 4, 2022 10:04
add functionality to django model admin class. To use separate forms for adding and updating data
class ExtraAdminUtils(admin.ModelAdmin):
add_fieldsets: dict = None
add_form = None
def get_fieldsets(self, request, obj=None):
if not obj and self.add_fieldsets is not None:
return self.add_fieldsets
return super().get_fieldsets(request, obj)
def get_form(self, request, obj=None, **kwargs):
@devvspaces
devvspaces / main.dart
Created October 4, 2022 15:05
Program to print odd numbers ranging from 1 - 30 😎
// Program to print odd numbers ranging from 1 - 30 😎
void main() {
// Loop on numbers range 1 - 30
for (int pointer = 1; pointer <= 30; pointer++){
// Check if value is an odd number or even
if (pointer % 2 != 0) {
print(pointer);
@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;
@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 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 / 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