Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am arjun27 on github.
  • I am arjun27 (https://keybase.io/arjun27) on keybase.
  • I have a public key ASBk0f0VlGFakDayBer6BhYzUkyro7dAehMft5J_zr1_ago

To claim this, I am signing this object:

@arjunattam
arjunattam / polyline.py
Created September 1, 2016 06:15
Time aware polyline example
# A location is [latitude, longitude]
locations = [
[19.13626, 72.92506],
[19.13597, 72.92495],
[19.13553, 72.92469],
]
# With Google's encoded polyline algorithm, locations are encoded as
google_polyline = 'spxsBsdb|Lx@TvAr@'
from rest_framework.fields import DateTimeField
TIME_CORRECTION_THRESHOLD = 5 * 60 # threshold offset difference in seconds
class TrueDateTimeField(DateTimeField):
'''
Custom DateTimeField that offsets the value during
validation to ensure bad device time is corrected
@arjunattam
arjunattam / main.m
Last active May 12, 2018 18:32
decode time aware polyline in objective-c
// main.m
#import <Foundation/Foundation.h>
// Main methods declaration
NSArray *getDecodedPolyline(NSString *);
NSArray *getLocationsTillTime(NSArray *, NSDate *);
// Helper methods declaration
NSArray *getDecodedDimensionFromPolyline(NSString *, int);
NSArray *getFormattedDimensions(NSNumber *, NSNumber *, NSNumber *);
@arjunattam
arjunattam / directory-structure
Last active January 6, 2017 05:59
Snippets for building a cordova plugin
HyperTrackWrapper
|-- src
| |-- android
| | |--HyperTrackWrapper.java
| |
| |-- ios
| | |--HyperTrackWrapper.m
|
|-- www
| |-- HyperTrackWrapper.js
def encode(data, modelers):
'''
data is a list of vector. each vector
has n elements. modelers is a list of
n functions, for each element of the vector.
'''
encoded = ''
if not data:
# This script finds vertex ids in an LSIF output file that have been referenced
# in edge declarations (as outV or inV), before being declared as a vertex.
#
# Usage
# To run on lsif.json file:
# $ python validate-lsif.py lsif.json
#
import json
import sys
@arjunattam
arjunattam / index.html
Last active January 13, 2020 23:48
gistpad-playground
<h1>Testing</h1>
<div id="root">
&nbsp;
</div>
@arjunattam
arjunattam / redux.test.js
Last active April 5, 2024 21:22
Redux store testing with Playwright
const pw = require('playwright');
(async () => {
const browser = await pw.chromium.launch();
const context = await browser.newContext();
// set addInitScript to run this on every page load in this context
// in the app, use window.IS_PLAYWRIGHT to set window.store = store;
await context.addInitScript('window.IS_PLAYWRIGHT = true;')