Skip to content

Instantly share code, notes, and snippets.

@larsgk
larsgk / keybase.md
Created September 25, 2019 08:45
keybase.md

Keybase proof

I hereby claim:

  • I am larsgk on github.
  • I am denladeside (https://keybase.io/denladeside) on keybase.
  • I have a public key ASDuaHY_VUR60d6RJhgH7kPUG00L29tKfOWrMrDzvRsZWQo

To claim this, I am signing this object:

@larsgk
larsgk / color-generator.js
Created September 14, 2017 19:30
Lit singleton tests...
let _color = '#ff0000';
let rnd256 = () => Math.floor(Math.random() * 256);
setInterval(
() => { colorGenerator.color = `rgb(${rnd256()},${rnd256()},${rnd256()})`;},
1000
)
export const colorGenerator = {
@larsgk
larsgk / test-lit-html.js
Created August 28, 2017 15:28
'ticker' experiment over test by @kenchris
<html>
<script type="module">
import { html, render } from './lit-html.min.js';
class MyGreater extends HTMLElement {
static get observedAttributes() { return ['data-names']; }
constructor() {
super();
this.attachShadow({mode: 'open'});
@larsgk
larsgk / gulpfile.js
Created January 27, 2017 15:35
Early addition of Polymer element inner-functional tests
/**
* @license
* Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/
@larsgk
larsgk / justgage-element.html
Last active October 19, 2016 08:17
Example of wrapping an external component in a polymer element
<link rel="import" href="../bower_components/polymer/polymer.html">
<script src="../3rdparty/justgage-1.2.9/raphael-2.1.4.min.js"></script>
<script src="../3rdparty/justgage-1.2.9/justgage.js"></script>
<dom-module id="justgage-element">
<template>
<div id="gauge"></div>
</template>
<script>
Polymer({
@larsgk
larsgk / output.html
Last active October 17, 2016 19:01
(Hacky/crappy) Workaround for missing expressions in polymer 1.x
<div>
<h1>Missing expression eval hack. Can we please get expressions in polymer2?</h1>
<span>In stead of writing e.g. [­[1 + 2]­], write [­[_eval('1 + 2')]­]</span><br>
<h4>Simple expressions</h4>
Plain text: 1 + 2 = 3 <span>(in template: "3")</span><br>
_eval hack: 1 + 2 = 3 <span>(in template: "[­[_eval('1 + 2']­]")</span><br>
Expresison: 1 + 2 = [[1 + 2]] <span>(in template: "[­[1 + 2]­]")</span><br>
<h4>Calling local functions (where this._getValue() returns 7)</h4>
@larsgk
larsgk / app-data.html
Last active October 10, 2016 11:10
It's been tricky for me to figure out how to make singleton behavior in polymer (1.x) .. I'm probably getting old ;) .. anyway - here goes: A tick (1 sec interval) tock (1.5 sec interval) counter service.
<link rel="import" href="../bower_components/polymer/polymer.html">
<dom-module id="app-data">
<script>
(function() {
console.log("This should only run once...");
var listeners = {
tickListeners: [],
tockListeners: []
}
@larsgk
larsgk / designer.html
Created September 12, 2014 11:16
designer
<link rel="import" href="../speech-mic/speech-mic.html">
<link rel="import" href="../google-map/google-map-search.html">
<link rel="import" href="../smoothie-chart/smoothie-chart.html">
<link rel="import" href="../paper-input/paper-input.html">
<link rel="import" href="../google-map/google-map.html">
<polymer-element name="my-element">
<template>
<style>
@larsgk
larsgk / designer.html
Last active August 29, 2015 14:05
designer
<link rel="import" href="../paper-input/paper-input.html">
<link rel="import" href="../paper-button/paper-button.html">
<link rel="import" href="../paper-calculator/paper-calculator.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
13:53:50: Running steps for project test2...
13:53:50: Configuration unchanged, skipping qmake step.
13:53:50: Starting: "/usr/bin/make"
/home/lgk/Apps/android-ndk-r8d/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/arm-linux-androideabi-g++ -c -Wno-psabi -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -DANDROID -Wa,--noexecstack -std=gnu++0x -g -g -marm -O0 -fno-omit-frame-pointer -Wall -Wno-psabi -W -D_REENTRANT -fPIE -DQT_NO_PRINTDIALOG -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_QUICK_LIB -DQT_QML_LIB -DQT_NETWORK_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../../Apps/Qt5.1.0Android/5.1.0-beta1/android_armv7/mkspecs/android-g++ -I../test2 -I../test2/qtquick2applicationviewer -I../../../Apps/Qt5.1.0Android/5.1.0-beta1/android_armv7/include -I../../../Apps/Qt5.1.0Android/5.1.0-beta1/android_armv7/include/QtQuick -I../../../Apps/Qt5.1.0Android/5.1.0-beta1/android_armv7/include/QtQml -I../../../Apps/Qt5.1.0Android/5.1.0-beta1/android_armv7