This file contains 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
from PIL import Image | |
import numpy as np | |
im = Image.open('cold_cat.png') | |
im = im.convert('RGBA') | |
data = np.array(im) # "data" is a height x width x 4 numpy array | |
red, green, blue, alpha = data.T # Temporarily unpack the bands for readability | |
# Replace white with red... (leaves alpha values alone...) |
This file contains 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 express from 'express'; | |
import { initializeApp } from 'firebase/app'; | |
import { getDatabase, ref, set, onValue } from "firebase/database"; | |
import 'dotenv/config' | |
import { dirname } from 'path'; | |
import { fileURLToPath } from 'url'; | |
import { createRequire } from 'module' | |
const require = createRequire(import.meta.url) | |
const Vonage = require('@vonage/server-sdk') | |
var bodyParser = require('body-parser') |
This file contains 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 random | |
a_list = [] | |
for i in range(0, 20): | |
j = random.randint(1, 30) | |
a_list.append(j) | |
print(j, end= " ") |
This file contains 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
x = 1 | |
n = 5 | |
a_list = [] | |
for i in range(1, n + 1): | |
a_list.append(x) | |
x = x * i |
This file contains 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
x = 1 | |
n = 5 | |
for i in range(1, n + 1): | |
x = x * i |
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<style> | |
#v1, #c1, #c2 { display: none } | |
</style> | |
</head> | |
<body> | |
<video id="v1" width="320" height="240" autoplay></video> | |
<canvas id="c1" width="320" height="240"></canvas> |
This file contains 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
class Node: | |
def __init__(self, data, next=None): | |
self.data = data | |
self.next = next | |
class Queue: | |
def __init__(self): | |
self.front = None | |
self.rear = None |
This file contains 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 heapq | |
def dijkstra(graph, starting_vertex): | |
distances = {vertex: float('infinity') for vertex in graph} | |
distances[starting_vertex] = 0 | |
pq = [(0, starting_vertex)] | |
while len(pq) > 0: | |
current_distance, current_vertex = heapq.heappop(pq) |
This file contains 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
#exercise 1 | |
print("It was a bright cold day in April, and the clocks were striking thirteen."[:33]) | |
#exercise 2 | |
print(""" "Hi" """) | |
#exercise 3 | |
print('A screaming comes across the sky.'.replace('s', '$')) | |
#exercise 4 |
This file contains 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
# exercise 1 | |
for c in "Camus": | |
print(c) | |
# exercise 2 | |
print("aldous was born in 1894.".capitalize()) | |
# exercise 3 | |
print("Where now? Who now? When now?".split('?')) |
NewerOlder