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]))
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const elementIsInFocus = (el) => (el === document.activeElement); | |
elementIsInFocus(anyElement) // Result: If it is in focus, it will return True, otherwise it will return False |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const isDarkMode = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches | |
console.log(isDarkMode) // Result: True or False |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const hex = () => `#${Math.floor(Math.random() * 0xffffff).toString(16).padEnd(6, "0")}`; | |
console.log(hex()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const even = num => num % 2 === 0; | |
console.log(even(2)); // true | |
console.log(even(3)); // false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const isBrowserTabInView = () => document.hidden; | |
isBrowserTabInView(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const reverse = str => str.split('').reverse().join(''); | |
console.log(reverse('cake is yummy')); | |
// Result: 'ymmuy si ekac' |