Skip to content

Instantly share code, notes, and snippets.

View tapanpandita's full-sized avatar

Tapan Pandita tapanpandita

  • Monzo
  • London, England
View GitHub Profile
SECURE_HSTS_SECONDS = 86400 # 1 day
SECURE_HSTS_INCLUDE_SUBDOMAINS = True
SECURE_HSTS_PRELOAD = True
SECURE_BROWSER_XSS_FILTER = True
SECURE_CONTENT_TYPE_NOSNIFF = True
X_FRAME_OPTIONS = 'DENY'
@tapanpandita
tapanpandita / embed.html
Last active March 6, 2017 22:29
Embeddable Dashboard
<iframe frameborder="0" scrolling="no" marginheight="0"
marginwidth="0" width="100%" height="100%"
src="https://dashboard.hypertrack.io/widget/users/<YOUR_USER_ID>/timeline;action_id=<YOUR_ACTION_ID>?key=SECRET_KEY">
@tapanpandita
tapanpandita / HyperTrack
Last active March 6, 2017 21:47
HyperTrack iOS and Android getting started
// Swift and Java
HyperTrack.setUserId("249d26da-c31c-4a70-bab8-53ef164411f0");
HyperTrack.startTracking();
@tapanpandita
tapanpandita / HyperTrack.swift
Last active March 6, 2017 21:35
HyperTrack iOS Get Started
HyperTrack.setUserId("249d26da-c31c-4a70-bab8-53ef164411f0")
HyperTrack.startTracking()
input {
syslog {
port => "1514"
tags => ["input_core_api_syslog"]
}
syslog {
port => "1515"
tags => ["input_mqtt_broker_syslog"]
}
syslog {
@tapanpandita
tapanpandita / jobs.py
Created October 8, 2016 03:58
Old jobs code
@shared_task(bind=True, max_retries=settings.EVENT_MAX_RETRIES)
def push_event(self, event_id):
event = Event.objects.get(id=event_id)
# code to push webhook
@tapanpandita
tapanpandita / views.py
Created October 8, 2016 03:57
Transaction code
with transaction.atomic():
# update task
# update driver
event = Event.objects.create(...)
push_event.delay(event.id)
@tapanpandita
tapanpandita / jobs.py
Created October 8, 2016 03:57
Transaction aware task
@shared_task(base=TransactionAwareTask, bind=True, max_retries=settings.EVENT_MAX_RETRIES)
def push_event(self, event_id):
event = Event.objects.get(id=event_id)
# code to push webhook
@tapanpandita
tapanpandita / celery.py
Created October 8, 2016 03:56
Transaction aware celery abstract task
class TransactionAwareTask(Task):
'''
Task class which is aware of django db transactions and only executes tasks
after transaction has been committed
'''
abstract = True
def apply_async(self, *args, **kwargs):
'''
Unlike the default task in celery, this task does not return an async
@tapanpandita
tapanpandita / celery.py
Last active February 10, 2021 06:22
A celery abstract task class that is fired when a transaction is committed
class TransactionAwareTask(Task):
'''
Task class which is aware of django db transactions and only executes tasks
after transaction has been committed
'''
abstract = True
def apply_async(self, *args, **kwargs):
'''
Unlike the default task in celery, this task does not return an async