Skip to content

Instantly share code, notes, and snippets.

View TobeTek's full-sized avatar
🎹
Learning the piano...

Emmanuel Katchy TobeTek

🎹
Learning the piano...
View GitHub Profile
@TobeTek
TobeTek / delete_django_migrations.sh
Created November 9, 2023 20:51
Delete all migrations in a Django project
#!/bin/bash
# Written by ChatGPT with some human help 🙂
# Loop through all apps in your project
for app in $(python manage.py showmigrations -l | grep -v '^\[ \]'); do
echo "Deleting migration files for $app..."
# Delete all migration files except __init__.py
find "$app/migrations" -name '00*.py' -not -name '__init__.py' -exec rm {} \;
/*
Author: Tobe :)
ZKP Circuits for a Game of Battleship
Circom: https://github.com/iden3/circom
3rd-Party circuits gotten from: https://github.com/iden3/circomlib
*/
pragma circom 2.1.5;
@TobeTek
TobeTek / utils.py
Created March 2, 2023 22:48
A cleaner approach to mocking unmanaged models in Django tests
"""
A cleaner approach to temporarily creating unmanaged model db tables for tests
"""
from unittest import TestCase
from django.db import connections, models
class create_unmanaged_model_tables:
"""
@TobeTek
TobeTek / models.py
Last active January 29, 2024 15:41
Querying Django's JSON Field
from django.db import models
from django.utils.translation import gettext_lazy as _
class Person(models.Model):
"""
Store data about people in a school
"""
name = models.CharField(max_length=100)
@TobeTek
TobeTek / vigenere_cipher.py
Last active July 9, 2023 01:55
Vigenere (Keyword) Cipher - Python
"""
Vignere (Keyword) Cipher implementation in Python
"""
import string
def generate_key(keyword: str, keyletter: str = "A") -> str:
"""
Generate a polyalphabetic cipher key
# ./main.py
# -----------------------------------
# new imports
import aiohttp
import asyncio
import async_api
import sync_api
from timeit import default_timer as timer
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
/**
* @title Ballot
* @dev Implements voting process along with vote delegation
*/
contract Ballot {
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
/**
* @author Tobe:)
* @title BasicStorage
* @dev Store & retrieve unsigned integer
*/
contract HelloWorld {
@TobeTek
TobeTek / custom_backtrader_timer.py
Created January 3, 2022 03:32
An OOP approach to Backtrader Timers
#!/usr/bin/env python
# -*- coding: utf-8; py-indent-offset:4 -*-
###############################################################################
#
# Copyright (C) 2021 Emmanuel Katchy
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or