Skip to content

Instantly share code, notes, and snippets.

@ndrhzn
ndrhzn / getcolor.py
Last active December 10, 2017 22:16 — forked from zollinger/getcolor.py
Simple way to get dominant colors from an image in Python
import Image, ImageDraw
def get_colors(infile, outfile, numcolors=10, swatchsize=20, resize=150):
image = Image.open(infile)
image = image.resize((resize, resize))
result = image.convert('P', palette=Image.ADAPTIVE, colors=numcolors)
result.putalpha(0)
colors = result.getcolors(resize*resize)
@ndrhzn
ndrhzn / index.html
Last active January 5, 2019 22:31
P5 - Jittering Lines
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.7.2/p5.js"></script>
<title>Jittering Lines</title>
</head>
<style media="screen">
body {
@ndrhzn
ndrhzn / index.html
Last active January 5, 2019 22:50
P5 - Jittering Rectangles
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.7.2/p5.js"></script>
<title>Jittering Rectangles</title>
</head>
<style media="screen">
body {
@ndrhzn
ndrhzn / index.html
Last active January 5, 2019 23:10
P5 - Rotating Squares
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.7.2/p5.js"></script>
<title>Rotating Squares</title>
</head>
<style media="screen">
body {
@ndrhzn
ndrhzn / index.html
Last active January 5, 2019 23:31
Vega-Lite - Bubble Map
<!DOCTYPE html>
<html>
<head>
<title>Населення України</title>
<meta charset="utf-8">
<script src="https://cdn.jsdelivr.net/npm/vega@4.3.0"></script>
<script src="https://cdn.jsdelivr.net/npm/vega-lite@3.0.0-rc10"></script>
<script src="https://cdn.jsdelivr.net/npm/vega-embed@3.24.1"></script>
<link href="https://fonts.googleapis.com/css?family=Ubuntu+Condensed" rel="stylesheet">
<style media="screen">
@ndrhzn
ndrhzn / index.html
Last active January 5, 2019 23:33
Vega-Lite - Ticks - Responsive Data Visualization
<!DOCTYPE html>
<html>
<head>
<title>Температура в Києві, 1812-2016 рік</title>
<meta charset="utf-8">
<script src="https://cdn.jsdelivr.net/npm/vega@3.0.10"></script>
<script src="https://cdn.jsdelivr.net/npm/vega-lite@2.1.2"></script>
<script src="https://cdn.jsdelivr.net/npm/vega-embed@3.0.0"></script>
<link href="https://fonts.googleapis.com/css?family=Ubuntu+Mono" rel="stylesheet">
<style media="screen">
@ndrhzn
ndrhzn / average_daily_temp.csv
Last active January 5, 2019 23:43
Vega-Lite - Ribbon & Line - Responsive Data Visualization
date temp_mean temp_min temp_max month season
2016-01-01 -12 -14 -10 January Winter
2016-01-02 -10.5 -15 -9 January Winter
2016-01-03 -15 -16 -12 January Winter
2016-01-04 -14 -17 -12 January Winter
2016-01-05 -8 -12 -6 January Winter
2016-01-06 -3.5 -6 0 January Winter
2016-01-07 -5 -6 -4 January Winter
2016-01-08 -4.5 -11 -1 January Winter
2016-01-09 -4 -7 3 January Winter
@ndrhzn
ndrhzn / conditions.csv
Last active January 6, 2019 15:32
Vega-Lite - Vertical Ticks
date conds
2016-01-01 Clear
2016-01-01 Mist
2016-01-01 Scattered Clouds
2016-01-01 Light Snow
2016-01-01 Light Snow Showers
2016-01-02 Light Snow
2016-01-02 Overcast
2016-01-02 Mostly Cloudy
2016-01-02 Scattered Clouds
@ndrhzn
ndrhzn / chart.js
Last active January 7, 2019 12:52
G2 - Bar Chart with Annotations
// add data
const data =
[{"letter":"а","count":129899,"share":8.8817824965317},
{"letter":"б","count":23864,"share":1.63168967811325},
{"letter":"в","count":68853,"share":4.70779120881375},
{"letter":"г","count":22280,"share":1.52338442961629},
{"letter":"ґ","count":647,"share":0.0442383180413707},
{"letter":"д","count":36900,"share":2.52301999339502},
{"letter":"е","count":65909,"share":4.50649660554668},
@ndrhzn
ndrhzn / index.html
Last active January 7, 2019 15:30
P5 - Pulsing Circles
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.7.2/p5.js"></script>
<title>Pulsing Circles</title>
</head>
<style media="screen">
body {