Skip to content

Instantly share code, notes, and snippets.

@lega911
lega911 / App.xht
Created September 28, 2020 22:28
Attach a class 2
<script>
import Button from './Button.xht';
</script>
<Button .btn="red bold" name="Red bold" />
<Button .btn="purple" name="Purple" />
<Button name="Default" />
<style>
.red {color: red;}
@lega911
lega911 / App.xht
Created September 28, 2020 22:17
Attach a class
<script>
import Button from './Button.xht';
</script>
<h1>Pass class</h1>
<Button name="Red" class="btn" />
<Button name="Default" />
<style>
@lega911
lega911 / App.xht
Created September 28, 2020 19:02
Named $class
<script>
import Child from './Child.xht';
let cond = true;
</script>
<input type="checkbox" :checked={cond} />
<Child .header="red bold" .body:italic={cond} />
<style>
@lega911
lega911 / App.xht
Created September 28, 2020 18:51
Property $class
<script>
import Child from './Child.xht';
let cond = true;
</script>
<input type="checkbox" :checked={cond} />
<Child class="red italic" class:bold={cond} />
<style>
@lega911
lega911 / App.xht
Created September 25, 2020 18:47
Example how to pass CSS-class to child component
<script>
import Icon from './Icon.xht';
let name = 'world';
</script>
<Icon />
<Icon .icon="green bold" />
<br/>
<Icon .icon="aqua big" />
@lega911
lega911 / test.py
Created August 7, 2020 09:09
test connection to web.smscom.se
import requests
import time
def main():
ok = 0
fail = 0
for i in range(1000):
try:
r = requests.post('https://web.smscom.se/sendSms/sendSms.asmx')
print(i, r, r.content[:100] + b'...')
@lega911
lega911 / 1_repeat_fragment.html
Last active August 1, 2020 18:20
Example of fragments
<script>
const run = () => {};
const runLots = () => {};
const add = () => {};
const partialUpdate = () => {};
</script>
{#fragment:button id, name}
<div class="col-sm-6 smallpad">
<button type="button" class="btn" id={id} @click>{name}</button>
@lega911
lega911 / test.html
Created July 28, 2020 10:57
Chrome & FF hangs on HTML
<!DOCTYPE html>
<html lang="en">
<head>
<style>.x {display: grid;}</style>
</head>
<body>
<p><div class="x"><div></p></div>
<p><div class="x"><div></p></div>
<p><div class="x"><div></p></div>
@lega911
lega911 / bindings.md
Last active September 25, 2020 19:00
Svelte, Malina.js
Svelte Malina.js Shortcut / Comment
Reference to element
bind:this={ref} #ref
1-way binding
prop={prop} prop={prop}
{prop} {prop}
2-way binding
bind:value={value} bind:value={value} :value={value} / :value:value
bind:value bind:value :value
import {
$$htmlToFragment, $$removeItem, $$childNodes, $watch, $ChangeDetector, $$removeElements,
$digest, $$htmlBlock, $$compareDeep, $$compareArray, $watchReadOnly, $$ifBlock
} from 'malinajs/runtime.js';
export default function App($element, $option) {
if ($option == null) $option = {};
let name = '';
let event = '';
const click = e => {