Skip to content

Instantly share code, notes, and snippets.

@zischwartz
zischwartz / rgb_to_lab.swift
Created March 23, 2016 19:54
Convert RGB to L*ab color space in Swift
//http://stackoverflow.com/a/24201042/83859
infix operator ^^ { }
func ^^ (radix: Double, power: Double) -> Double {
return Double(pow(Double(radix), Double(power)))
}
//Based on https://github.com/d3/d3-color/blob/master/src/lab.js
document.querySelectorAll('div[class^="B"]').forEach(el=>{ el.className = el.className.replace('Blur','')})
@zischwartz
zischwartz / Readme.md
Last active March 17, 2020 08:00 — forked from josiahdavis/Readme.md
Responsive Multi-Line Chart (D3 V5)

Responsive Multi-Line Chart

@zischwartz
zischwartz / README.md
Last active August 10, 2019 22:41
Shortcut to Toggle Between Github Repo and That Repo's Github Pages

Add it as a custom search engine in Chrome by entering chrome://settings/searchEngines in the search bar and clicking "add".

For the url just write javascript: and then paste the contents of toggle_gh.js after the colon, and hit save.

Alternatively, if you'd like a button, you can just paste the javascript: ... as a "new page" in bookmarks.

@zischwartz
zischwartz / trump_word_counts.csv
Last active April 7, 2019 23:02
Trump Tweet Word Counts
word count
trump 5931
great 5331
will 5309
that 4523
with 3974
have 3529
this 2831
they 2481
president 2435
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
body {
background-color: black;
height: 100vh;
overflow: hidden;
function get_random_emoji(){
let list = ['🌲', '⭐️', '👹', '😱', '👁', '🦀', '🐬', '🏝']
return list[Math.floor(list.length*Math.random())]
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
body {
background-color: black;
height: 100vh;
overflow: hidden;
class Game {
constructor(render_board){
this.render_board = render_board
this.data = [{row:4, col: 4, icon:'🐄' }]
this.render_board(this.data)
}
class Game {
constructor(render_board){
this.render_board = render_board
this.data = []
for (var row = 0; row < 10; row++) {
for (var col = 0; col < 10; col++) {
let icon = col < 5 ? '☀️': '🌵'
this.data.push({row, col, icon})
}
}