Skip to content

Instantly share code, notes, and snippets.

Avatar
💻
write code for humans

Naveen Yadav navyad

💻
write code for humans
View GitHub Profile
@navyad
navyad / github-actions
Created Nov 29, 2020
github actions for postgres and redis for python app
View github-actions
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: mysite-app
on:
push:
branches: [ test-workflow ]
pull_request:
branches: [ master ]
View gist:b019498dcd3f29c51d3ea18e71fc9f71
from builtins import property as _property, tuple as _tuple
from operator import itemgetter as _itemgetter
from collections import OrderedDict
class point(tuple):
'point(x, y, z)'
__slots__ = ()
_fields = ('x', 'y', 'z')
@navyad
navyad / gist:f069103b4d10fc2dad19ea9dcd87e60d
Created May 24, 2018
default values without KeyError
View gist:f069103b4d10fc2dad19ea9dcd87e60d
In [1]: from collections import defaultdict
In [2]: dd = defaultdict(lambda: 100, a=22, b=11)
In [3]: dd
Out[3]: defaultdict(<function __main__.<lambda>>, {'a': 22, 'b': 11})
In [4]: dd.update({"c": 33})
In [5]: dd
@navyad
navyad / responses.py
Created Aug 2, 2016
methods for API responses
View responses.py
from django.http.response import JsonResponse
def _send(data, status_code):
"""
Generic method to send the JSON response
"""
return JsonResponse(data=data, status=status_code)