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
from bs4 import BeautifulSoup | |
# from terminal | |
# curl http://www.flowerexplosion.com/by-flower/roses.html?p=[1-11] > roses.html | |
# python scrape.py | |
filename = "roses.html" | |
with open (filename, "r") as infile: | |
html = BeautifulSoup(infile.read()) |
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 org.scalacheck.Gen | |
//Gen a long | |
val genLong = Gen.posNum[Long] | |
// Gen a string | |
val genString = Gen.alphaChar | |
//Gen random length list of longs | |
val genList = Gen.listOf(Gen.posNum[Long]) |
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
print("UPDATE AUG 2023: this script is beyond old and broken") | |
print("You may find interesting and more up to date resources in the comments of the gist") | |
exit() | |
from slacker import Slacker | |
import json | |
import argparse | |
import os | |
# This script finds all channels, private channels and direct messages |
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
▶ TIMEOUT [expected OK] /websockets/Create-Secure-extensions-empty.htm | |
▶ Unexpected subtest result in /websockets/Create-Secure-extensions-empty.htm: | |
└ NOTRUN [expected PASS] W3C WebSocket API - Create Secure WebSocket - wsocket.extensions should be set to '' after connection is established - Connection should be closed | |
▶ Unexpected subtest result in /websockets/Create-Secure-extensions-empty.htm: | |
│ FAIL [expected PASS] W3C WebSocket API - Create Secure WebSocket - wsocket.extensions should be set to '' after connection is established - Connection should be opened | |
│ → assert_equals: extensions should be empty expected (string) "" but got (undefined) undefined | |
│ | |
│ @http://web-platform.test:8000/websockets/Create-Secure-extensions-empty.htm:9:13 |
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 numpy | |
# R() is the reflectance of an object at a given band | |
# E() is the energy of the illuminant at a given band | |
# x_cmf() is the sensitivitiy of the X primary at a given band | |
# numpy.trapz(x_values, y_values) cacluated the area under a curve | |
X_curve = [] | |
Y_curve = [] | |
Z_curve = [] |
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 numpy | |
XYZ_to_sRGB_matrix = \ | |
numpy.array( | |
[[3.2404542, -1.5371385, -0.4985314], | |
[-0.9692660, 1.8760108, 0.0415560], | |
[0.0556434, -0.2040259, 1.0572252]]) | |
def apply_srgb_gamma(RGB): | |
non_linear = [] |
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
def render_single_kai_pixel(bands, hyperion_pixel): | |
weighted_R = [] | |
weighted_G = [] | |
weighted_B = [] | |
used_bands = [] | |
for band in bands: | |
if band >= 320 and band <= 1000: | |
used_bands.append(band) | |
weighted_R.append(hyperion_pixel(band) * KAI_R(band)) | |
weighted_G.append(hyperion_pixel(band) * KAI_G(band)) |
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 numpy as np | |
import rasterio | |
original = rasterio.open("original.tif").read() | |
# cmd: | |
# convert -compress LZW -type TrueColor original.tif lossless.tif | |
lossless = rasterio.open("lossless.tif").read() | |
# cmd: |
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
# Echo client program | |
import socket | |
HOST = '127.0.0.1' # The remote host | |
PORT = 50007 # The same port as used by the server | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
s.connect((HOST, PORT)) | |
s.send('Hello, world') | |
data = s.recv(1024) | |
s.close() |
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 gpxpy | |
def load_gpx_file(path): | |
gpx = gpxpy.parse(open(path, 'r')) | |
points = [] | |
for track in gpx.tracks: | |
for segment in track.segments: | |
for point in segment.points: | |
points.append([point.longitude, point.latitude]) | |
return points |