Skip to content

Instantly share code, notes, and snippets.

@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 => {
<script>
let name = '';
let todos = [{name: 'Linux'}, {name: 'Ubuntu', done: true}];
let active;
function add() {
if(!name) return;
todos.push({name: name});
name = '';
}
@lega911
lega911 / malina-app.html
Last active September 19, 2020 22:29
Small benchmark
<script>
let todos = [];
let duration = '';
function timeit(fn) {
let start = Date.now();
fn();
setTimeout(() => {
duration += ' + ' + (Date.now() - start);
}, 10);
# xkbcomp 2.xkb $DISPLAY
# xkbcomp $DISPLAY - > init.2
# xmodmap
xkb_keymap {
xkb_keycodes {
include "evdev+aliases(qwerty)"
<LALT> = 108;
<RALT> = 64;
words = ['abc', 'ubuntu', 'linux', 'ubuntu 16 LTS', 'redhat', 'unix', 'windows', 'macos X']
def tre(w):
w = w.lower()
r = {'__' + w[0], '_' + w[:2]}
for i in range(len(w)):
k = w[i:i+3]
while len(k) < 3:
k += '_'
r.add(k)
@lega911
lega911 / xkb.symbols.se
Created October 30, 2019 11:15
keyboard layout se for ubuntu 19+
// file /usr/share/X11/xkb/symbols/se
partial alphanumeric_keys
xkb_symbols "se" {
name[Group1]="Swedish";
// tool: xev
// mapping key file: /usr/share/X11/xkb/keycodes/evdev
// reload conf: setxkbmap -layout se
// key <code> {[ default, +shift, +altGr, +shit +altgr ]};
import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import java.io.IOException;
import java.util.UUID;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.TimeoutException;
@lega911
lega911 / client_and_worker.py
Last active December 17, 2019 21:59
RPC example
# client.py
import requests
print(requests.post('http://127.0.0.1:8001/test/command', json={'id': 1, 'params': 'Hello'}).json())
# worker.py
import requests
while True:
req = requests.post('http://127.0.0.1:8001/test/command', headers={'Type': 'get'}).json()
response = {
'id': req['id'],
load: 0.369427308000013
find: 0.03731154500019329
sample 1: ['6.19889798576753', '306.03317783754981', 'NCV']
sample 2: ['6.19889798576753', '306.03317783754981', 'NCV']