Skip to content

Instantly share code, notes, and snippets.

View athulmurali's full-sized avatar
🎯
Focusing

Athul Muralidharan athulmurali

🎯
Focusing
View GitHub Profile
const chalk = require('chalk');
const semver = require('semver');
function chalkLog(color, message) {
console.log(chalk[color](message));
}
function loadNodeVersionFromPackageJson() {
chalkLog('green', 'Loading... loadNodeVersionFromPackageJson from ~/.zshrc');
const packageJsonPath = `${process.cwd()}/package.json`;
@athulmurali
athulmurali / sample-datasource.js
Last active August 20, 2020 00:01
grafana-datasource.js
// original code
async query(options) {
var query = await this.buildQueryParameters(options);
if (query.targets.length <= 0) {
return this.q.when({ data: [] });
}
return this.doRequest(query).then(result => {
var res = []
_.forEach(result.data.results, r => {
[[{"y":1,"x":"03:25","label":1589340372559},{"y":0,"x":"03:30","label":1589340372559},{"y":0,"x":"03:35","label":1589340372559},{"y":0,"x":"03:40","label":1589340372559},{"y":0,"x":"03:45","label":1589340372559},{"y":0,"x":"03:50","label":1589340372559},{"y":0,"x":"03:55","label":1589340372559},{"y":0,"x":"04:00","label":1589340372559},{"y":0,"x":"04:05","label":1589340372559},{"y":0,"x":"04:10","label":1589340372559},{"y":0,"x":"04:15","label":1589340372559},{"y":0,"x":"04:20","label":1589340372559},{"y":0,"x":"04:25","label":1589340372559}],[{"y":1,"x":"03:25","label":1589340372632},{"y":0,"x":"03:30","label":1589340372632},{"y":0,"x":"03:35","label":1589340372632},{"y":0,"x":"03:40","label":1589340372632},{"y":0,"x":"03:45","label":1589340372632},{"y":0,"x":"03:50","label":1589340372632},{"y":0,"x":"03:55","label":1589340372632},{"y":0,"x":"04:00","label":1589340372632},{"y":0,"x":"04:05","label":1589340372632},{"y":0,"x":"04:10","label":1589340372632},{"y":0,"x":"04:15","label":1589340372632},{"y":0,"x":"
@athulmurali
athulmurali / README.md
Last active October 22, 2019 05:27
Spring boot common issues | Debug

Things to do:

  1. Update the schema name in DatabaseConnection.java

  2. Remove all duplicate code for creating connection in all DAOs first.

  3. Just use the getConnection method from DatabaseConnection.java At any instance, do not duplicate the connection strings or copy paste connection methods to stay away from trouble.

  4. Remove duplicate package tags in pom.xml

def merge_arr(a, b):
result = []
i = 0
j = 0
while i < len(a) or j < len(b):
if i < len(a) and ((j < len(b) and a[i] < b[j]) or j >= len(b)):
result.append(a[i])
i += 1
Practise:
1. Create a js based html with button
2. Click button to call flask api
3. Flask api sends response as stream
4. Request gets closed
-- Flask :
@athulmurali
athulmurali / Amazon_q.json
Last active July 11, 2019 22:56
Amazon_questions
{
"Amazon": [
[
"1",
"Two Sum",
"44.3%",
"Easy"
],
[
"2",
class Solution:
def nextPermutation(self, nums: List[int]) -> None:
n = len(nums)
prev = -float("inf")
ind = n -1
for i in range(n):
ind = n - i -1
if nums[ind] < prev:
j = n -1
while(nums[j] <= nums[ind] and j > ind) :
class Solution:
def maxSubArray(self, nums: List[int]) -> int:
local_sum = 0
global_sum = -float("inf")
for i in nums:
local_sum = local_sum + i
if i >= local_sum:
local_sum = i
if local_sum > global_sum:
@athulmurali
athulmurali / k_largest.py
Last active June 18, 2019 02:57
K largest and smallest elements in python
import heapq
def k_largest(arr,k):
h= []
heapq.heapify(h)
for i in arr:
heapq.heappush(h,i)
if len(h) > k :
heapq.heappop(h)
result = []
while h: