Skip to content

Instantly share code, notes, and snippets.

View Chandler's full-sized avatar

Chandler Abraham Chandler

View GitHub Profile
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))
@Chandler
Chandler / sRGB.py
Last active November 28, 2016 19:56
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 = []
@Chandler
Chandler / XYZ.py
Last active November 27, 2016 03:21
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 = []
@Chandler
Chandler / failures.log
Created January 25, 2016 08:00 — forked from jsanders/failures.log
Servo WebSocket test failures
▶ 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
@Chandler
Chandler / slack_history.py
Last active March 26, 2024 14:35
Download Slack Channel/PrivateChannel/DirectMessage History
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
@Chandler
Chandler / gens.scala
Created November 18, 2015 19:21
intro to scalacheck gens
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])
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())
scala> def test(name: String = "joe"): Boolean = true
test: (name: String)Boolean
scala> val test: String => Boolean = { (name: String = "joe") => true }
<console>:1: error: ')' expected but '=' found.
case class WriteEvent(name: String, records: List[Int])
case class SingleRecord(name: String, value: Int)
val events = List(
WriteEvent("follow", List(1,2,3)),
WriteEvent("block", List(2,3,4)),
WriteEvent("follow", List(5,6,7))
)
def sideEffect() {
//increment hadoop counter
}
val list = List(Some("a"),Some("b"),None, Some("e"), None)
val filtered = list.flatMap { x =>
if(x.isEmpty) sideEffect()
x
}