Skip to content

Instantly share code, notes, and snippets.

View answerquest's full-sized avatar

Nikhil VJ answerquest

View GitHub Profile
@answerquest
answerquest / mhvillages-make-geojsonl.py
Created June 9, 2022 05:59
convert Village Boundary_split.7z into single .geojsonl, bring district and taluka names into each shape's properties
# mhvillages-make-geojsonl
# by Nikhil VJ, https://nikhilvj.co.in on 2022-06-09
# MIT Open License Boilerplate:
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
# of the Software, and to permit persons to whom the Software is furnished to do
# so, subject to the following conditions:
@answerquest
answerquest / sample_boundary.gpx
Created May 4, 2022 04:23
sample_boundary.gpx
<?xml version="1.0"?>
<gpx version="1.1" creator="GDAL 3.4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.topografix.com/GPX/1/1" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">
<metadata><bounds minlat="18.601548052999998" minlon="81.648038112999998" maxlat="19.010908051000001" maxlon="82.144620493999994"/></metadata>
<trk>
<trkseg>
<trkpt lat="19.002683533" lon="81.976895614">
</trkpt>
<trkpt lat="18.996481867" lon="81.973134297">
</trkpt>
<trkpt lat="18.986310677" lon="81.971660611">
@answerquest
answerquest / geojson_properties2csv.ipynb
Created January 7, 2021 17:30
Extract the properties of shapes in a geojson into a CSV
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@answerquest
answerquest / osm_pbf_generation.sh
Created September 26, 2020 11:54
osm_pbf_generation.sh
#!/bin/bash
# script for downloading fresh OSM extract for India and making regional extracts
printf "\n\n$(date)\n"
# This stores absolute path of this shell script into $DIR. Similar to python's root = os.path.dirname(__file__)
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
# user-set variables
websiteFolder="/var/www/html/dump"
@answerquest
answerquest / flatten_hierarchical_dict.py
Created June 4, 2020 05:29
flatten_hierarchical_dict.py : convert any nested json with arrays / empty elements also into flat json (brought into python so dicts)
# see https://stackoverflow.com/a/62186294/4355695 for full explanation
# adapted from https://github.com/ScriptSmith/socialreaper/blob/master/socialreaper/tools.py#L8
import collections
crumbs = True
def flatten(dictionary, parent_key=False, separator='.'):
"""
Turn a nested dictionary into a flattened dictionary
:param dictionary: The dictionary to flatten
@answerquest
answerquest / StevenCrowder.20191007.csv
Created October 7, 2019 15:02
Louder with Crowder all videos as of 7 Oct 2019
We can't make this file beautiful and searchable because it's too large.
"num","id","title","date","viewcount","likes","dislikes","thumbnail","link","tags","description"
"1","jRgZ0rOHL6w","#557 7 WORDS YOU CAN’T SAY ON YOUTUBE! | Eric Cochran Guests | Louder with Crowder","2019-10-04","391288","17637","325","https://i.ytimg.com/vi/jRgZ0rOHL6w/hqdefault.jpg","https://youtu.be/jRgZ0rOHL6w","steven crowder,crowder,stephen crowder,louder with crowder,LwC,mug club,Change My Mind,Crowder Confronts,comedy,politics,news,liberal,libertarian,funny conservative,current events,fake news,adam schiff,ukraine,ukraine transcript,whistleblower,trump whistleblower ukraine,7 words,george carlin,impeachment,trump impeachment,trump ukraine,whistleblower complaint,trump whistleblower,biden ukraine,ukraine call,president trump,impeachment inquiry","Talking%20all%20things%20Hillary's%20obsession%20with%20Trump,%20snake%20and%20alligator%20border%20moats,%20scrotum%20paintings,%20and%20why%20Adam%20Schiff%20is%20a%20piece%20of%20sh*t!%20Joined%20by%20Pinterest%20whistleblower%20Eric%20Cochran!%0A%0AShow%2
@answerquest
answerquest / number_to_devnagri.py
Created May 13, 2019 04:30
Python function to convert a number (digits) to unicode devnagri (hindi/marathi/other) equvalent. Preserves all non-numeric characters like decimal
def devnagriNum(n):
devn = ''
for i in list(str(n)):
if i.isdigit():
devn += (chr(2406+int(i) ) )
else: devn += i
return devn
# test:
print(devnagriNum(345)) # ३४५
We can't make this file beautiful and searchable because it's too large.
"num","id","title","date","viewcount","likes","dislikes","thumbnail","link","tags","description"
"1","pUuGvvVMhhs","The Evolutionary Origins of a Good Society (Nicholas Christakis Full Interview)","2019-04-19","22349","723","65","https://i.ytimg.com/vi/pUuGvvVMhhs/hqdefault.jpg","https://youtu.be/pUuGvvVMhhs","nicholas christakis,nicholas christakis yale,nicholas christakis yale halloween,yale halloween costume incident,yale halloween protest,evolutionary origins of a good society,free speech,nicholas christakis dave rubin,nicholas christakis joe rogan","Nicholas%20Christakis%20(Sociologist%20&%20Author)%20joins%20Dave%20to%20discuss%20the%20Yale%20Halloween%20costume%20debacle,%20his%20book%20%E2%80%98Blueprint:%20The%20Evolutionary%20Origins%20of%20a%20Good%20Society%E2%80%99,%20the%20importance%20of%20free%20and%20open%20conversation,%20the%20value%20of%20friendship,%20and%20more.%20**Support%20The%20Rubin%20Report:%20http://www.rubinreport.com/donate%0A%0ASubscribe%20to%20The%20Rubin%20Report:%20http://ww
@answerquest
answerquest / matomo-python-1.py
Last active April 29, 2019 05:24
python function for usage tracking using self-hosted Matomo
import json, requests, platform
'''
29.April.2019 by Nikhil VJ
this Python 3 function sends a non-invasive simple usage ping to your self-hosted Matomo analytics site
No more allowing Google to track your users while they let you have some crumbs in exchange.
Reference: https://developer.matomo.org/api-reference/tracking-api
This function adds in metrics of the operating system (which was my use case).
you can skip all that stuff if you wish.
@answerquest
answerquest / 19.2.19 Delhi GTFS-RT vehicle update feed analysis.ipynb
Last active February 20, 2019 12:42
19.2.19 Delhi GTFS-RT vehicle update feed analysis
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.