Skip to content

Instantly share code, notes, and snippets.

View kristw's full-sized avatar

Krist Wongsuphasawat kristw

View GitHub Profile
#!/bin/bash
func install_yamlfmt {
# Check the machine architecture
arch=$(uname -m)
# Set the URL based on the machine architecture
if [[ $arch == "x86_64" ]]; then
url="https://github.com/google/yamlfmt/releases/download/v0.10.0/yamlfmt_0.10.0_Linux_x86_64.tar.gz"
elif [[ $arch == "arm64" ]]; then
#!/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}"`;
const myRadarChart = new Chart(ctx, {
type: 'radar',
data: data,
options: options
});
{
"$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"
},
<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}
@kristw
kristw / example-g2.js
Last active September 10, 2020 19:38
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);
<ReactRough>
<Rectangle x={15} y={15} width={90} height={80} fill="red" />
</ReactRough>
@kristw
kristw / example-nivo.jsx
Last active September 10, 2020 19:41
blog example: nivo
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 August 16, 2020 07:33
blog example: deck.gl
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 August 17, 2020 06:28
blog example: echarts
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],