Skip to content

Instantly share code, notes, and snippets.

View chapimenge3's full-sized avatar
👨‍💻
Try not to fail and if you do Try not to break at the same time.

Temkin Mengsitu chapimenge3

👨‍💻
Try not to fail and if you do Try not to break at the same time.
View GitHub Profile
@chapimenge3
chapimenge3 / .bashrc
Last active June 3, 2024 09:24
my custom bash utility functions
function lower() {
echo "$1" | tr '[:upper:]' '[:lower:]'
}
function activate(){
source env/bin/activate
}
function mkvir() {
python3 -m venv env
@chapimenge3
chapimenge3 / sourcemap_cli.py
Last active May 11, 2024 19:50
Generate the source code from the .map file of Node Projects. `python sourcemap_cli.py main2215118a.js.map dest-folder/`
import os
import json
import argparse
import httpx
def rebuild_from_sourcemap(source_map_file, destination_dir):
with open(source_map_file, "r") as f:
source_map = json.load(f)
@chapimenge3
chapimenge3 / bot-models.py
Last active March 25, 2024 20:23
SoleStep Blog Code Snippets
from django.db import models
from django.contrib.auth.models import AbstractUser
class User(AbstractUser):
telegram_id = models.CharField(max_length=255, unique=True)
username = models.CharField(max_length=255)
first_name = models.CharField(max_length=255)
last_name = models.CharField(max_length=255)
phone_number = models.CharField(max_length=255)
created_at = models.DateTimeField(auto_now_add=True)
@chapimenge3
chapimenge3 / scripts.md
Created February 11, 2024 12:19
Useful Scripts for installing softwares on ubuntu.

NodeJs

Requirements

sudo apt-get install software-properties-common

Upgrade

@chapimenge3
chapimenge3 / redis_sub.py
Last active October 11, 2023 20:26
Redis subscriber task runner in parallel multiple tasks.
import asyncio
import threading
import redis
redis_url = 'localhost'
username = 'default'
redis = r = redis.Redis(
host=redis_url,
port=6379,
service: Todo
frameworkVersion: '3'
custom:
tableName: 'todo-table-${self:provider.stage}'
provider:
name: aws
runtime: python3.8
'''
this method goes to below the update_todo function
'''
def delete_todo(event, context):
'''
Delete Todo Application in Dynamo DB
Params:
event: API Gateway Event
'''
this method goes to below the list_todo function
'''
def update(event, context):
'''
Update Todo Application in Dynamo DB
Params:
event: API Gateway Event
'''
this goes to Below the create_todo function
'''
def list_todo(event, context):
'''
List Todo Application in Dynamo DB
Params:
event: API Gateway Event
import os
import boto3
import json
TODO_TABLE = os.getenv('TODO_TABLE')
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table(TODO_TABLE)
def create_todo(event, context):