Skip to content

Instantly share code, notes, and snippets.

write code for humans

Naveen Yadav navyad

write code for humans
View GitHub Profile
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:
name: mysite-app
branches: [ test-workflow ]
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 / 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 /
Created Aug 2, 2016
methods for API responses
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)