Skip to content

Instantly share code, notes, and snippets.

View abhishekori's full-sized avatar

Abhishek M Kori abhishekori

  • Bangalore
View GitHub Profile
@abhishekori
abhishekori / CalculateThrottleLamda.js
Created February 4, 2022 01:11
AWS Lambda function
exports.handler = async (event) => {
// TODO implement
const getThrottle = function(cs, hysRange, prevSpeed,prevThrottle){
if(cs<0) return 1 // boundary Condition
if(cs>70) return 7 // boundary condition
const step = 10
if(Math.abs(cs-prevSpeed)>hysRange) return prevThrottle // check for rapid change in speed
for(let i = 0 ;i <=70;i+=step){ // loop though the range to calculate the throttle
if( i< cs && cs <=i+step) {
return (i+10)/10
@abhishekori
abhishekori / calculateThrottleLambda.js
Created February 4, 2022 00:43
calcualte throttle with lambda api call
let table = base.getTable('CCS');
let result = await table.selectRecordsAsync()
let recordBtn = await input.recordAsync('',table, {fields: ['Hysteresis Range']}).catch();
let prevThrottle = result.records[0].getCellValue('Throttle Level')
prevThrottle = prevThrottle === null? 0: prevThrottle;
let prevSpeed = result.records[0].name;
// console.log(prevSpeed)
result.records.forEach((rec, i) => {
if(rec.id === recordBtn.id && i > 0){
@abhishekori
abhishekori / calculateThrottle.js
Created February 3, 2022 06:11
Cruise Control calcualte Throttle
let table = base.getTable('CCS'); // reference the table
let result = await table.selectRecordsAsync() // get all the records in the table
let recordBtn = await input.recordAsync('',table, {fields: ['Hysteresis Range']}).catch(); // get the row which the calcualte button was clicked
const getThrottle = function(cs, hysRange, prevSpeed,prevThrottle){
if(cs<0) return 1
if(cs>70) return 7
const step = 10
if(Math.abs(cs-prevSpeed)>hysRange) return prevThrottle
for(let i = 0 ;i <=70;i+=step){
@abhishekori
abhishekori / JSbasics.md
Created September 2, 2019 18:14
Java Script basics

JavaScript Basics

History

JavaScript was introduced in 1995 as a way to add programs to web pages in the Netscape Navigator browser

It is important to note that JavaScript has almost nothing to do with the programming language named Java

After its adoption outside of Netscape, a standard document was written to describe the way the JavaScript language should work so that the various pieces of software that claimed to support JavaScript were actually talking about the same language. This is called the ECMAScript standard, after the Ecma International organization that did the standardization. In practice, the terms ECMAScript and JavaScript can be used interchangeably—they are two names for the same language.

JavaScript Variables

@abhishekori
abhishekori / hacker-news-ui-chat-inteface.ipynb
Created August 5, 2019 04:38
Hacker-news-UI-Chat-Inteface.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
https://www.coursera.org/learn/hadoop/programming/m6H7U/running-wordcount-with-hadoop-streaming-using-python-code
#!/usr/bin/env node
const program = require('commander');
const request = require('request-promise');
const colors = require('colors/safe');
program
.command('search <search_query>')
program
.command('search <search_query>')
.alias('-s')
.description('Search for a question')
.action((searchKey)=>{
console.log(searchKey)
})
program.parse(process.argv);
function getTopAnswer(searchKey){
var queryLink='http://api.stackexchange.com/2.2/search/advanced?sort=relevance&site=stackoverflow&q='+queryBuilder(searchKey);
request(queryLink,{json:true,gzip:true})
.then(function(body){
console.log('\n')
body["items"].reverse().forEach((item,index)=>{
console.log((body["items"].length-index)+" "+colors.bold(item.title)+"\n"+colors.blue.underline(item.link)+'\n\n')
})
@abhishekori
abhishekori / urls.txt
Created June 30, 2018 06:47
toor dal images urls
https://5.imimg.com/data5/KL/CI/MY-42267529/nutritious-toor-dal-500x500.jpg
https://rukminim1.flixcart.com/image/832/832/j8rnpu80/pulses/q/g/w/500-toor-dal-arhar-dal-desi-arhar-dal-un-branded-original-imaeymjgrjw8xgvw.jpeg?q=70
http://3.imimg.com/data3/GO/QH/GLADMIN-145584/toor-dal-250x250.jpg
https://shop.jivabhumi.com/image/cache/catalog/ProductImages/Toor_Dal_DSC5051-500x350.jpg
http://images-cdn.azureedge.net/azure/in-resources/dc9d44f8-61bf-4a88-b20e-c878f6f6151e/Images/ProductImages/Source/Toor%20Dal.jpg;width=600
https://5.imimg.com/data5/DR/QS/MY-5854474/organic-toor-dal-arhar-tur-500x500.jpg
https://images-na.ssl-images-amazon.com/images/I/91iLFk6K3%2BL._SY679_.jpg
http://www.grocyhub.com/image/cache/catalog/indian_grocery/dals_pulses/arhar_dal/gh-arhar-dal-toor-dal-500gm_1-800x800.jpg
http://eboxmart.com/media/catalog/product/cache/1/image/9df78eab33525d08d6e5fb8d27136e95/t/o/toor_dal_4.jpg
https://sc01.alicdn.com/kf/UTB8pSoAXD_IXKJkSalUxh5BzVXai/Toor-Dal-Split-Pigeon-Peas-Yellow-Split.jpeg_350x350.