Skip to content

Instantly share code, notes, and snippets.

Avatar

Krist Wongsuphasawat kristw

View GitHub Profile
View git_clean_local_branches.sh
#!/bin/bash
function git_clean_local_branches {
OPTION="-d";
if [[ "$1" == "-f" ]]; then
echo "WARNING! Removing with force";
OPTION="-D";
fi;
TO_REMOVE=`git branch -r | awk "{print \\$1}" | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk "{print \\$1}"`;
View example-chartjs.js
const myRadarChart = new Chart(ctx, {
type: 'radar',
data: data,
options: options
});
View example-vl-candlestick.json
{
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"width": 400,
"data": {"url": "data/ohlc.json"},
"encoding": {
"x": {
"field": "date",
"type": "temporal",
"title": "Date"
},
View example-victory.jsx
<VictoryChart
theme={VictoryTheme.material}
domainPadding={{ x: 25 }}
scale={{ x: "time" }}
>
<VictoryAxis tickFormat={(t) => `${t.getDate()}/${t.getMonth()}`}/>
<VictoryAxis dependentAxis/>
<VictoryCandlestick
candleColors={{ positive: "#5f5c5b", negative: "#c43a31" }}
data={sampleDataDates}
View example-g2.js
import { Chart } from '@antv/g2';
const data = [
{country: "China", population: 131744},
{country: "India", population: 104970},
{country: "US", population: 29034},
];
const chart = new Chart({ container: 'container', autoFit: true, height: 500 });
chart.data(data);
View example-react-rough.jsx
<ReactRough>
<Rectangle x={15} y={15} width={90} height={80} fill="red" />
</ReactRough>
@kristw
kristw / example-nivo.jsx
Last active Sep 10, 2020
blog example: nivo
View example-nivo.jsx
import { Calendar } from '@nivo/calendar';
<Calendar
data={[
{ "day": "2016-02-05", "value": 397 },
{ "day": "2015-09-17", "value": 283 },
]}
from="2015-04-01"
to="2016-12-12"
emptyColor="#eeeeee"
@kristw
kristw / example-deckgl.jsx
Last active Aug 16, 2020
blog example: deck.gl
View example-deckgl.jsx
import {Deck} from '@deck.gl/core';
import {ScatterplotLayer} from '@deck.gl/layers';
const INITIAL_VIEW_STATE = {
latitude: 37.8,
longitude: -122.45,
zoom: 15
};
const deckgl = new Deck({
@kristw
kristw / example-echarts.js
Last active Aug 17, 2020
blog example: echarts
View example-echarts.js
option = {
xAxis: {
data: ['2017-10-24', '2017-10-25', '2017-10-26', '2017-10-27']
},
yAxis: {},
series: [{
type: 'candlestick',
data: [
[20, 30, 10, 35],
[40, 35, 30, 55],
@kristw
kristw / example-vega-lite.json
Last active Sep 10, 2020
blog example: vega-lite
View example-vega-lite.json
{
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"description": "A simple bar chart with embedded data.",
"data": {
"values": [
{"country": "China", "population": 131744},
{"country": "India", "population": 104970},
{"country": "US", "population": 29034}
]
},
You can’t perform that action at this time.