Skip to content

Instantly share code, notes, and snippets.

View GitHubEmploy's full-sized avatar

Mohit Varikuti GitHubEmploy

View GitHub Profile
import time
s = time.time()
tsum = 0
for i in range(100000000): tsum += i
print(f'Sum: {tsum}')
print(f'For loop: {time.time() - s} seconds')
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
fig.set_size_inches(14, 7)
ax.imshow(mars[0], cmap="viridis")
ax.axis('off')
plt.show()
import rasterio
import numpy as np

mars = rasterio.open('Mars_MGS_MOLA_DEM_mosaic_global_463m.tif')
mars = mars.read()

print(mars.shape)
print(np.amin(mars[0]))
const touchSupported = () => {
(‘ontouchstart’ in window || window.DocumentTouch && document instanceof window.DocumentTouch);
}
console.log(touchSupported()); // Result: If touch event is supported, it will return True, otherwise it will return False
const elementIsInFocus = (el) => (el === document.activeElement);
elementIsInFocus(anyElement) // Result: If it is in focus, it will return True, otherwise it will return False
const isDarkMode = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches
console.log(isDarkMode) // Result: True or False
const hex = () => `#${Math.floor(Math.random() * 0xffffff).toString(16).padEnd(6, "0")}`;
console.log(hex());
const even = num => num % 2 === 0;
console.log(even(2)); // true
console.log(even(3)); // false
const isBrowserTabInView = () => document.hidden;
isBrowserTabInView();
const reverse = str => str.split('').reverse().join('');
console.log(reverse('cake is yummy'));
// Result: 'ymmuy si ekac'