Skip to content

Instantly share code, notes, and snippets.

@lega911
lega911 / test.py
Created July 16, 2024 00:26
bson vs json vs pickle
"""
bson.encode 3.905530183998053
bson.decode 2.354907840999658
orjson.dumps 0.35170182900037616
orjson.loads 1.2572932409966597
pickle.dumps 0.9980631790022017
pickle.loads 1.2438834620043053
"""
COUNT = 100000
@lega911
lega911 / benchmark.py
Created July 16, 2024 00:10
MongoDB compression
"""
Results:
orig
write 21.48s (0.215ms)
read x5 24.67s (0.049ms)
size 142.30Mb
ujson + zlib
write 33.79s (0.338ms)
@lega911
lega911 / se.xkb
Created December 10, 2022 19:20
xkb
// file: /usr/share/X11/xkb/symbols/se
default partial alphanumeric_keys
xkb_symbols "basic" {
include "latin(type2)"
include "se(se)"
};
partial alphanumeric_keys
<script>
import Button from './button.xht';
// able to create a component/block by JS
function Custom($option) {
return document.createTextNode('Custom JS-component');
}
</script>
@lega911
lega911 / App.xht
Last active January 2, 2022 12:39
Malina.js + TypeScript example
<script type="typescript">
let name: string = 'bar';
</script>
<h1>Hello {name}!</h1>
@lega911
lega911 / App.xht
Created July 8, 2021 01:38
Todo example
<script>
let name = '';
let todos = [{name: 'Linux'}, {name: 'Ubuntu', done: true}];
let active;
function add() {
if(!name) return;
todos.push({name});
name = '';
}
@lega911
lega911 / App.xht
Created July 5, 2021 15:42
Insert block of JS
<script>
const styleDiv = el => {
el.style.border = '2px dotted red';
el.style.padding = '8px';
}
</script>
<div {* styleDiv($element) }>
{* $element.textContent = 'inserted text' }
</div>
diff --git a/dist/static/index.html b/dist/static/index.html
index 889ce60..66c9f93 100644
--- a/dist/static/index.html
+++ b/dist/static/index.html
@@ -4,10 +4,10 @@
<meta charset='utf-8'>
<meta name='viewport' content='width=device-width,initial-scale=1'>
<title>Malina.js - import ES modules</title>
- <link rel="shortcut icon" href="./malinajs.svg">
- <link rel='stylesheet' href='./global.css'>
@lega911
lega911 / App.xht
Created May 15, 2021 21:48
Passing class to component
<script>
import Box from './Box.xht';
</script>
<Box class="purple">Purple class</Box>
<Box class="green">Green</Box>
<style>
.purple {
@lega911
lega911 / App.xht
Created May 15, 2021 21:09
Example of anchor
<script>
import Child from './Child.xht';
let value = 'text';
const action = (el) => {
el.style.backgroundColor = '#b1daf8';
}
</script>
Value: {value}