Skip to content

Instantly share code, notes, and snippets.

View chintanp's full-sized avatar
🎯
Focusing

Chintan Pathak chintanp

🎯
Focusing
View GitHub Profile
@chintanp
chintanp / migrator.py
Last active May 28, 2021 07:56
Migrate Redash Queries, Visualizations and Dashboards
# Original source: https://gist.github.com/arikfr/e1c01f6c04d8348da52f33393b5bf65d
import json
import requests
import logging
import sys
logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
logging.getLogger("requests").setLevel("ERROR")
@chintanp
chintanp / process.md
Last active June 26, 2020 00:23
AWS SAM Python Setup and Debugging

This changes often and may not work as is for you.

Last checked on 06-25-2020

Step - 0 (What)

The steps below show how to setup an AWS Lambda function using AWS SAM CLI for Python. The setup takes one through the process of initialization, building, deploying and debugging a AWS Lambda function. The default SAM template also creates an API endpoint for testing the Lambda function. This testing can be done locally, and after deploying the function to AWS. While most of the instructions are easily found on the AWS docs, the instructions for debugging through VS Code and testing using Postman are not well-documented. Please install SAM CLI and read the AWS SAM python deployment guide.

Step - 1

sam init

This initializes the AWS SAM CLI using the configu

@chintanp
chintanp / serial-port-sendyne.js
Created February 11, 2016 00:16
Trying to interact with Sendyne Current Sensor SFP101
var com = require("serialport");
var serialPort = new com.SerialPort("/dev/ttyUSB0", {
baudrate: 19200,
parser: com.parsers.raw
});
serialPort.open(function (error) {
if ( error ) {
console.log('failed to open: '+error);
} else {
@chintanp
chintanp / SFP_Protocol.cpp
Created February 10, 2016 21:06
Arduino Code for Sendyne Sensor - SFP101
/*
Copyright 2015-2016 Sendyne Corp., New York, USA
http://www.sendyne.com
THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
@chintanp
chintanp / node-socketcan.js
Last active February 10, 2016 20:22
The node implementation to interact with ELCON charger over CANBus
var can = require('socketcan');
var channel = can.createRawChannel("can0");
// id is the device id, data represents data that has to be written
var canmsg = { id: 403105268, data: new Buffer([ 0, 0xFA, 0, 0x32, 0, 0, 0, 0 ]), "ext" : true };
// Log any message
//channel.addListener("onMessage", function(msg) { console.log(msg); } );
@chintanp
chintanp / socketcan.c
Last active February 10, 2016 02:39
Working C code that sends data over CANBus to an ELCON charger and corresponding node implementation (that doesnt work yet)
/*
* $Id$
*/
/*
* cansend.c - simple command line tool to send CAN-frames via CAN_RAW sockets
*
* Copyright (c) 2002-2007 Volkswagen Group Electronic Research
* All rights reserved.
*
@chintanp
chintanp / i2c-test.js
Created December 2, 2015 21:05
Node-i2c-example
var vol, rbc, fcc, soc, temp, cur;
var Wire, Gauge, gauge, address, buffer;
Wire = require('i2c');
Gauge = (function() {
function Gauge(address) {
this.address = address;
this.wire = new Wire(this.address, {device: '/dev/i2c-1', debug: false});
@chintanp
chintanp / stream_hum_temp.js
Created September 5, 2015 06:47
Live Streaming temperature and humidity data from a DHT11 though Arduino UNO to plotly
// Code inspired from http://adilmoujahid.com/posts/2015/07/practical-introduction-iot-arduino-nodejs-plotly/
// and modified to use multiple traces, using : https://github.com/plotly/plotly-nodejs/blob/master/examples/streaming-multiple-traces.js
var serialport = require('serialport'),
plotly = require('plotly')('chintanp','vu32637k4y'),
tokens = ['xg5vkjdoct', 'qsc0j3pqks'];
var portName = 'COM5';
// serial port part works fine, and was checked independently