Skip to content

Instantly share code, notes, and snippets.

View parth-paradkar's full-sized avatar

Parth Paradkar parth-paradkar

View GitHub Profile
@parth-paradkar
parth-paradkar / parser.py
Created October 11, 2022 13:41
react_import_parser
import json
import os
def parse_imports(file_path):
abs_file_path = os.path.abspath(file_path)
if abs_file_path.endswith(".js") or abs_file_path.endswith(".jsx"):
if abs_file_path.endswith(".js"):
abs_file_path = abs_file_path.strip(".js")
if abs_file_path.endswith(".jsx"):
@parth-paradkar
parth-paradkar / vtune_automate.py
Created October 19, 2021 06:43
Automate collection of performance metrics from Intel VTune
import os
import csv
RUN_FILE_NAME = "models_dict.py"
VTUNE_COMMAND = "vtune -collect performance-snapshot ./models_dict.py"
NUM_RUNS = 10
METRICS = ["SP GFLOPS", "DP GFLOPS", "x87 GFLOPS", "Elapsed Time", "Average CPU Frequency"]
content = list()
layers = list()
@parth-paradkar
parth-paradkar / scrape.py
Created April 2, 2021 09:47
Scrape Facebook page for posts
from selenium.webdriver import Firefox
from os import getenv
import time
def refresh_feed_elements(driver: Firefox):
main_feed = driver.find_elements_by_xpath(".//div[@role='feed']")[1]
posts = main_feed.find_elements_by_xpath("./div")
return main_feed, posts
#define byte unsigned char
void printBytes(byte *target, int size) {
byte select = 128;
byte *i = target;
while(size--) {
byte currentByte = *i;
for(int k = 0; k < 8*sizeof(byte); k++) {
printf("%d", (int)((currentByte & select) > 0));
currentByte <<= 1;
@parth-paradkar
parth-paradkar / json_to_csv.py
Created February 5, 2021 16:34
Convert JSON to CSV file with headers
# Usage: python json_to_csv.py <JSON file>
import json
import csv
from sys import argv
with open(argv[1], 'r') as json_file:
data = json.load(json_file)
with open("result.csv", "w") as csv_file:
writer = csv.DictWriter(csv_file, fieldnames = list(data[0].keys()))
writer.writeheader()
@parth-paradkar
parth-paradkar / csv_to_json_header.py
Created February 5, 2021 16:27
Convert CSV file with headers to JSON
from sys import argv
import csv
import json
with open(argv[1], 'r') as csv_file:
reader = csv.DictReader(csv_file)
data = [d for d in reader]
with open("result.json", 'w') as f:
json.dump(data, f)
@parth-paradkar
parth-paradkar / task.js
Last active October 26, 2019 10:41
Average luminosity for each Indian district from the DMSP OLP dataset on Google Earth engine
var table = ee.FeatureCollection("users/parthparadkar3/india_pc_2014");
var districts = ee.FeatureCollection(table)
// Considering data for January 2010
var dataset = ee.ImageCollection('NOAA/DMSP-OLS/NIGHTTIME_LIGHTS')
.filter(ee.Filter.date('2010-01-01', '2010-01-31'));
var nighttimeLights = dataset.select('avg_vis');
var totalNightLights = nighttimeLights.reduce(ee.Reducer.mean());
var districtLights = totalNightLights.reduceRegions({
collection: districts,
reducer: ee.Reducer.mean(),
@parth-paradkar
parth-paradkar / README-Template.md
Created February 21, 2019 18:58 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites