Skip to content

Instantly share code, notes, and snippets.

View kanitw's full-sized avatar

Kanit Wongsuphasawat kanitw

View GitHub Profile
@kanitw
kanitw / peerapi-answers-template.html
Last active December 17, 2015 18:29
peerapi-answers-template
<script src="https://learningapi.stanford.edu/static/js/checkboxes.js"></script>
<div class='answers' data-max-score='1' data-min-score='0'>
<p>Long/full answers description</p>
<b>Correct Answers</b>
<ul class='correct-answers' data-add-other='true'>
<li data-score='1'>Correct Answer 1</li>
...
<!--To add/remove other choice, modify data-add-other attribute in the ul tag-->
@kanitw
kanitw / 0_reuse_code.js
Created November 7, 2013 17:48
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@kanitw
kanitw / README.md
Last active January 4, 2016 08:09 — forked from mbostock/.block

This simple force-directed graph shows character co-occurence in Les Misérables. A physical simulation of charged particles and springs places related characters in closer proximity, while unrelated characters are farther apart. Layout algorithm inspired by Tim Dwyer and Thomas Jakobsen. Data based on character coappearence in Victor Hugo's Les Misérables, compiled by Donald Knuth.

Compare this display to a force layout with curved links, a force layout with fisheye distortion and a matrix diagram.

Forked from Mike Bostock http://bl.ocks.org/mbostock/4062045 and resized!

@kanitw
kanitw / gist:8703057
Created January 30, 2014 05:27
add as git remote and pull
git remote add example https://github.com/CSE512-14W/a3-jheer-kanitw.git
git pull example master:master
@kanitw
kanitw / controller.js
Last active August 29, 2015 14:14
angular directive template
'use strict';
angular.module('__appname__')
.controller('__controller__Ctrl', function ($scope) {
$scope.awesomeThings = [
'HTML5 Boilerplate',
'AngularJS',
'Karma'
];
});
@kanitw
kanitw / README.md
Last active August 29, 2015 14:26 — forked from mbostock/.block
Lab and HCL Color Spaces

D3 supports CIELAB (Lab) and CIELCH (HCL) color spaces, which are designed for humans rather than computers.

Lab and HCL color spaces are special in that the perceived difference between two colors is proportional to their Euclidean distance in color space. This special property, called perceptual uniformity, makes them ideal for accurate visual encoding of data. In contrast, the more familiar RGB and HSL color spaces distort data when used for visualization.

You can create Lab or HCL colors in D3 directly using d3.lab or d3.hcl. For example:

var steelblue = d3.lab(52, -4, -32);
var steelblue = d3.hcl(-97, 32, 52);
{
"width": 200,
"height": 200,
"padding": "auto",
"data": [
{
"name": "source",
"url": "data/cars.json",
"format": {"type": "json","parse": {"Acceleration": "number"}},
"transform": [
@kanitw
kanitw / filtered_line.json
Created April 15, 2016 22:17 — forked from willium/filtered_line.json
vega label specs
{
"width": 1,
"height": 1,
"padding": "auto",
"data": [
{
"name": "source",
"url": "data/stocks.csv",
"format": {
"type": "csv",
[
{"x": 1, "cat": null},
{"x": 1, "cat": null},
{"x": 1, "cat": null},
{"x": 1, "cat": null},
{"x": 2, "cat": "a"},
{"x": 3, "cat": 1},
{"x": 2, "cat": 1},
{"x": 2, "cat": null},
{"x": 2, "cat": "b"},
name economy (mpg) cylinders displacement (cc) power (hp) weight (lb) 0-60 mph (s) year
AMC Ambassador Brougham 13 8 360 175 3821 11 73
AMC Ambassador DPL 15 8 390 190 3850 8.5 70
AMC Ambassador SST 17 8 304 150 3672 11.5 72
AMC Concord DL 6 20.2 6 232 90 3265 18.2 79
AMC Concord DL 18.1 6 258 120 3410 15.1 78
AMC Concord DL 23 4 151 3035 20.5 82
AMC Concord 19.4 6 232 90 3210 17.2 78
AMC Concord 24.3 4 151 90 3003 20.1 80
AMC Gremlin 18 6 232 100 2789 15 73