Skip to content

Instantly share code, notes, and snippets.

@skyjur
skyjur / data.json
Last active February 17, 2022 15:19
[
{
"url": "blob:https://dev.realtimeboard.com/d9f095e9-5df2-4b4b-93cb-45ad9b6e4238",
"title": "TestBoard, Online Whiteboard for Visual Collaboration",
"img": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/4gIoSUNDX1BST0ZJTEUAAQEAAAIYAAAAAAQwAABtbnRyUkdCIFhZWiAAAAAAAAAAAAAAAABhY3NwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAA9tYAAQAAAADTLQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAlkZXNjAAAA8AAAAHRyWFlaAAABZAAAABRnWFlaAAABeAAAABRiWFlaAAABjAAAABRyVFJDAAABoAAAAChnVFJDAAABoAAAAChiVFJDAAABoAAAACh3dHB0AAAByAAAABRjcHJ0AAAB3AAAADxtbHVjAAAAAAAAAAEAAAAMZW5VUwAAAFgAAAAcAHMAUgBHAEIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFhZWiAAAAAAAABvogAAOPUAAAOQWFlaIAAAAAAAAGKZAAC3hQAAGNpYWVogAAAAAAAAJKAAAA+EAAC2z3BhcmEAAAAAAAQAAAACZmYAAPKnAAANWQAAE9AAAApbAAAAAAAAAABYWVogAAAAAAAA9tYAAQAAAADTLW1sdWMAAAAAAAAAAQAAAAxlblVTAAAAIAAAABwARwBvAG8AZwBsAGUAIABJAG4AYwAuACAAMgAwADEANv/bAEMAAwICAgICAwICAgMDAwMEBgQEBAQECAYGBQYJCAoKCQgJCQoMDwwKCw4
@skyjur
skyjur / api.apib
Created June 11, 2020 11:44
Orkestro API
FORMAT: 1A
HOST: https://api.orkestro.io/
# Orkestro API
Orkestro's public API enables customers to programatically integrate Orkestro's marketplace capabilities into their own platform.
API consumers are able to submit orders, get their statuses, cancel them and get constant status updates for them through webhooks.
## Glossary
- **Order** - Represents a logical unit of work to get a parcel from location A to B using Orkestro's Platform.
@skyjur
skyjur / run_changefeed_forever.js
Created January 30, 2020 21:58
Change feed listener
const _log = require("../../utils/logger")
/**
* @typedef {{
* query: any,
* includeInitial?: boolean,
* onChange(oldVal: any, newVal: any, ctx?: Ork.Context): any,
* onState?: (state: string, ctx?: Ork.Context) => any,
* dataTimeoutInterval?: number,
* stateTimeoutInterval?: number,
@skyjur
skyjur / lazy_wrapper.js
Last active January 27, 2020 02:34
javascript string literal tag for pg queries
const { query } = require("../connection")
/**
* @template T
* @param {Pg.QueryConfig | string} queryConfig
* @param {Ork.Context} ctx
* @returns {Sql.LazyQuery<T>}
*/
function lazyQuery(queryConfig, ctx = {}) {
let { name = "", text, values = [] } =
@skyjur
skyjur / main.dart
Created July 26, 2019 02:27
updating final values
void main() {
final order1 = Order(
address: Address(
street: "Daguan",
city: "Taipei",
postcode: "231",
country: "Taiwan"
),
person: Person(
firstName: "Chloe",
@skyjur
skyjur / main.dart
Created July 25, 2019 10:06
Folding maps
void main() {
final map = {
Product(price: 1): 2,
Product(price: 2): 3,
};
final total = map.entries.fold(
0,
(total, entry) => total + (entry.key.price * entry.value)
);
@skyjur
skyjur / bitslice.js
Created February 5, 2019 06:28
bit slicing
// Binary bit slice from the right to the left
// msb: n-th more significant bit from the right (inclusive)
// lsb: n-th less signnificant bit from the right (inclusive)
//
// bitSlice(x, 2, 0) - last 3 bits of a number
// bitSlice(x, 3, 2) - 4th and 3rd least significant bits
function bitSlice(n, msb, lsb) {
return (n & ((1 << (msb + 1)) - 1)) >> lsb
}
main() async {
List<String> testList = ['sfs','sdfsdf', 'sfdsf'];
for(final value in testList) {
await Future.delayed(Duration(seconds: 1));
print('Writing another word $value');
};
}
@skyjur
skyjur / main.dart
Last active January 22, 2019 14:36
void main() {
Map firstMap = { "id": 1, "value": [{"key": "A"}, {"key": "B"}]};
List valueList = firstMap["value"];
List<Map> newList = valueList.map((valueItem) => {
"id": firstMap["id"],
"value": [valueItem]
}).toList();
@skyjur
skyjur / utils.dart
Created January 22, 2019 06:01
dart:randomString
import 'dart:math';
String randomString(int length) {
final rand = Random.secure();
final codeUnits = List.generate(length, (index) {
return rand.nextInt(33) + 89;
});
return String.fromCharCodes(codeUnits);
}