Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am matthiaskainer on github.
  • I am matthias_kainer (https://keybase.io/matthias_kainer) on keybase.
  • I have a public key ASAZ47c1zOdTW7ilmSrksXxnL-jFRtZW6JlRi3Vh0WHm5Ao

To claim this, I am signing this object:

// ==UserScript==
// @name GSlack
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Using the css from https://github.com/paveyry/Slack-Theme-for-Hangouts-Chat/
// @author You
// @match https://chat.google.com/*
// @grant none
// ==/UserScript==
const unsigned char LED_RED = 3;
const unsigned char LED_GREEN = 5;
const unsigned char LED_BLUE = 6;
void setup() {
Serial.begin(9600);
pinMode(LED_GREEN, OUTPUT);
pinMode(LED_BLUE, OUTPUT);
pinMode(LED_RED, OUTPUT);
}
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
#define PIN 4
Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
strip.begin();
strip.setBrightness(20);
@customElement("demo-element")
export class DemoElement extends LitElement {
state: DispatcherType<DemoElementState>;
constructor() {
super()
// register dispatcher in the constructor
this.state = useDispatcher<DemoElementState>(this, { actions: [] })
}
@MatthiasKainer
MatthiasKainer / SpringRestTemplateLoggingRequestInterceptor.kt
Last active May 28, 2020 07:30
Logging everything from a Spring RestTemplate with Kotlin
package de.matthiaskainer.spring.net.resttemplate.logging
import mu.KotlinLogging
import org.springframework.http.HttpRequest
import org.springframework.http.client.ClientHttpRequestExecution
import org.springframework.http.client.ClientHttpRequestInterceptor
import org.springframework.http.client.ClientHttpResponse
import java.io.BufferedReader
import java.io.IOException
import java.io.InputStreamReader
import { html, LitElement } from "lit-element";
import { useState, useReducer } from "lit-element-state-decoupler";
import { pureLit } from "pure-lit";
import { LitElementWithProps } from "pure-lit/types";
type ListProps = { items: string[] };
const add = (state: string) => ({
update: (payload: string) => payload,
add: () => state,
import {
LitElement,
customElement,
html,
css,
property
} from "lit-element";
const blockStyle = css`:host { display: block; }`
(element) => {
const { publish, getState } = useState(element, TodoReducer, { todos: [] });
return html`
<button @click="${() => publish("add", "lala")}">
Add value
</button>
<textarea>${getState().join(",")}</textarea>
`
}
pureLit("dispatch-todo", (element) => {
const { publish, getState } = useState(element, { todos: [] } as TodoState);
return html`
<h2>Your todos</h2>
<todo-add
@add="${(e: CustomEvent) =>
publish({ todos: [...getState().todos, e.detail] })}"
></todo-add>
<todo-list
.items="${getState().todos}"