Skip to content

Instantly share code, notes, and snippets.

View barklund's full-sized avatar
🍩
Always on the lookout for new snacks!

Morten Barklund barklund

🍩
Always on the lookout for new snacks!
View GitHub Profile
@barklund
barklund / fetchWeather.js
Created January 27, 2021 16:23
Return best weather service that answers within a timed limit
function fetchWeather(services, timeout) {
let bestData = null;
const controllers = services.map(() => new AbortController());
const cancelFrom = index => controllers.slice(index).map(c => c.abort());
const fetches = services.map((url, index) =>
fetch(url, {signal: controller[index].signal})
.then((res) => {
bestData = res;
cancelFrom(index+1);
return res;
Percentage: float(0..1)
Dimension: int(0..255)
Angle: int(0..360)
Color: object(
r: Dimension,
g: Dimension,
b: Dimension,
a: Percentage,
)
Stop: object(
@barklund
barklund / app.js
Created November 18, 2019 22:51
Context service provider pattern
import { MyServiceProvider, useMyService } from './myservice';
function App() {
return (
<MyServiceProvider>
// more services here
</MyServiceProvider>
);
}

Keybase proof

I hereby claim:

  • I am barklund on github.
  • I am barklund (https://keybase.io/barklund) on keybase.
  • I have a public key ASBSQ-WD4ZBtz7lLAikBAlhNQvOvjZT40z-pRXobUEQq2go

To claim this, I am signing this object:

@barklund
barklund / .eslintrc
Created April 19, 2018 08:08
Pt. godkendt .eslintrc
{
"extends": "airbnb",
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 8,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
@barklund
barklund / huset_config.json
Last active August 3, 2018 07:51
Huset config
{
"floors": [
{
"floor": 4,
"locations": [
{
"name": "Xenon",
"scene_type": "Performance Arts",
"feed_name": "Xenon",
"default_image": "xenon.png",