Skip to content

Instantly share code, notes, and snippets.

@carbide-public
Created July 4, 2024 13:54
Show Gist options
  • Save carbide-public/5c5aa2695635aa560ab0ae2f368ebff3 to your computer and use it in GitHub Desktop.
Save carbide-public/5c5aa2695635aa560ab0ae2f368ebff3 to your computer and use it in GitHub Desktop.
Widget Menagerie
///SelectorWidget
var x = ['horse', 'staple', 'amnesia']
x[1]
///SliderWidget
var f = 45,
c = (f - 32) / 1.8
f - c
/// GridArrayWidget
[
{"sepalLength": 5.1, "sepalWidth": 3.5, "petalLength": 1.4, "petalWidth": 0.2, "species": "setosa"},
{"sepalLength": 5.0, "sepalWidth": 3.3, "petalLength": 1.4, "petalWidth": 0.2, "species": "setosa"},
{"sepalLength": 6.2, "sepalWidth": 2.9, "petalLength": 4.3, "petalWidth": 1.3, "species": "versicolor"},
{"sepalLength": 5.1, "sepalWidth": 2.5, "petalLength": 3.0, "petalWidth": 1.1, "species": "versicolor"},
{"sepalLength": 5.7, "sepalWidth": 2.8, "petalLength": 4.1, "petalWidth": 1.3, "species": "versicolor"},
{"sepalLength": 6.3, "sepalWidth": 3.3, "petalLength": 6.0, "petalWidth": 2.5, "species": "virginica"},
{"sepalLength": 6.2, "sepalWidth": 3.4, "petalLength": 5.4, "petalWidth": 2.3, "species": "virginica"},
{"sepalLength": 5.9, "sepalWidth": 3.0, "petalLength": 5.1, "petalWidth": 1.8, "species": "virginica"}
]
/// FormObjectWidget
var x = {"sepalLength": 5.9, "sepalWidth": 3.0, "petalLength": 5.1, "petalWidth": 1.8, "species": "virginica"}
/// ObjectInspector
var object = {Hello: 'doge', what: ['is', 'up']}
/// JSONDiffWidget
import _ from 'lodash'
_.isEqual({Hello: "doge", what: ['is', 'up']},
{hello: 'hal', what: ['is', 'love']})
/// StringDiffWidget
"StringDiffWidget" === "stringbean"
/// SimpleMapWidget
var places = [{"lat":42.293564192170095,"lon":-69.9609375},{"lat":25.48295117535531,"lon":-44.29687499999999},{"lat":10,"lon":-69},{"lat":42,"lon":-90},{"lat":12,"lon":-1}]
/// SinglePointMapWidget
var MIT = {lat: 42.3601, lon:-71.0942}
/// JSONWidget
var record = {"record":{"probably":{"conforms":["to","some","special","schema"]}}}
record.record.probably.conforms[1]
/// Chart1DWidget
var points = []
for(var i = -50; i < 50; i++){
points.push(Math.sin(i/25))
}
points
///ColorPickerWidget
"red"
///TextWidget
var x = "dlroW olleh"
x.split('').reverse().join('').toUpperCase()
///MatrixWidget
[[1,2,3], [4,5,6]]
/// BufferWidget
var res = await fetch('https://i.imgur.com/S2AinSB.jpg')
var arrBuf = await res.arrayBuffer()
new Buffer(arrBuf)
/// HTMLElementWidget
var img = document.createElement('img')
img.style.width ='100%'
img.src = 'https://i.imgur.com/S2AinSB.jpg'
/// ReactRenderWidget
import React from 'react'
import Spinner from 'react-spinner';
<div style={{padding: 200}}>
<Spinner/>
</div>
/// RandExpWidget
/([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})/g
/// DateTimeWidget
new Date("2016-08-10T10:08:50.200Z")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment