Skip to content

Instantly share code, notes, and snippets.

View Anjaan-g's full-sized avatar
🚀
Aiming higher and higher

Anjaan Gaire Anjaan-g

🚀
Aiming higher and higher
View GitHub Profile
# This is the code to resize images on upload with Django Python. Works with both local files and cloud storages like S3.
import PIL
from django.db import models
from django.utils.translation import gettext_lazy as _
class Image(models.Model):
name = models.CharField(_("Name"), max_length=254)
image = models.ImageField(_("Image"), upload_to="images", blank=True, null=True)
@Anjaan-g
Anjaan-g / .bashrc
Created January 12, 2023 12:49
Modify terminal for better look
# Show git branch name
force_color_prompt=yes
color_prompt=yes
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;31m\]$(parse_git_branch)\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\W$(parse_git_branch)\$ '
class MyViewSet(mixins.ListModelMixin, viewsets.GenericViewset):
queryset = MyModel.objects.select_related()
serializer_class = MyModelSerializer
@action(methods=['GET'], detail=False, url_path='some_path')
def get_something_done(self, request):
cache_data = Cache.get('something')
if cache_data:
return Response(cache_data, status=status.HTTP_200_OK)
@Anjaan-g
Anjaan-g / client.py
Created July 9, 2020 05:48
Socket Programming to connect server and client on same network(eg. wifi, LAN).
import socket
HEADER = 64
PORT = 5050
FORMAT = 'utf-8'
DISCONNECT_MSG = "!DISCONNECT"
SERVER = socket.gethostbyname(socket.gethostname())
ADDR = (SERVER, PORT)
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

Keybase proof

I hereby claim:

  • I am Anjaan-g on github.
  • I am anjaan (https://keybase.io/anjaan) on keybase.
  • I have a public key whose fingerprint is 04E3 45DB 6BE1 4A4D A9BD 72CB 05CB 654C 3987 08AA

To claim this, I am signing this object: