title: "Git Aliases to Supercharge Your Workflow" date: 2024-03-21 draft: false ShowToc: true TocOpen: false math: true summary: "Git aliases are a powerful workflow tool that create shortcuts to frequently used Git commands." tags: [ "git", "version-control", "workflow", "development", "productivity", "command-line", "aliases", "git-commands", "git-aliases", "coding",
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
- based no splits 1000 splits | |
- based on time eg 10s | |
- based on time interval 2:10 -> 2:50 | |
- 10 people upload 1 gb 2 file daily | |
- we have design a system to split it into 1000 partitions | |
Solution: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fibonacci(n): | |
if n <= 2: | |
return 1 | |
return fibonacci(n - 1) + fibonacci(n - 2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.urls import path, include | |
from rest_framework import routers | |
from .views import UploadViewSet | |
router = routers.DefaultRouter() | |
router.register(r'upload', UploadViewSet, basename="upload") | |
# Wire up our API using automatic URL routing. | |
urlpatterns = [ | |
path('', include(router.urls)), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from rest_framework.serializers import Serializer, FileField | |
# Serializers define the API representation. | |
class UploadSerializer(Serializer): | |
file_uploaded = FileField() | |
class Meta: | |
fields = ['file_uploaded'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from rest_framework.viewsets import ViewSet | |
from rest_framework.response import Response | |
from .serializers import UploadSerializer | |
# ViewSets define the view behavior. | |
class UploadViewSet(ViewSet): | |
serializer_class = UploadSerializer | |
def list(self, request): | |
return Response("GET API") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BookModelSerializer(ModelSerializer): | |
authors = SerializerMethodField("get_author_serializer") | |
publisher = SerializerMethodField("get_publisher_serializer") | |
class Meta: | |
model = Book | |
fields = '__all__' | |
def get_author_serializer(self, obj): | |
request = self.context.get('request') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from rest_framework.routers import DefaultRouter | |
from .views import BookModelViewSet | |
router = DefaultRouter(trailing_slash=False) | |
router.register(r'book', BookModelViewSet, base_name='book') | |
urlpatterns = router.urls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from rest_framework.viewsets import ModelViewSet | |
from rest_framework.authentication import SessionAuthentication | |
from .serializers import BookModelSerializer | |
from .models import Book | |
# Create your views here. | |
class BookModelViewSet(ModelViewSet): | |
""" | |
A simple ViewSet for viewing and editing books. |
NewerOlder