- Compile time errors become runtime errors (in case of circular dependencies, ...)
- You can't have async initialization
- It's encourages a style I don't like: instead of initialization in a parent class method, most people just call ctor where you then have to do work.
Think
parent.createChildWithConfigFile("foo.ini")
vsnew Child("foo.ini")
<- now you have to do I/O in your ctor. - It's way harder to understand in what order things get initialized
- It's so easy to write it out by hand
- It encourages you to make a very wide and flat tree/graph because it's so easy to just add one more dependency.
- hides dependencies between projects. E.g. what dependencies are needed by storage? Stuff can be added from anywhere.
- all dependency relations become hidden in this big grab-bag, there is no "this module needs this interfaces and exports these", the bootstrapper for a module just adds stuff to the container it's passed in, but you have no idea what it takes out of the container to created those values.
- GTK: https://en.wikibooks.org/wiki/GTK%2B_By_Example/Tree_View/Custom_Models
- Cocoa: https://developer.apple.com/documentation/appkit/nstableviewdatasource
- UWP:
ListView.ItemsSource
can be set to any object implementingIEnumerable
. ImplementingIList
enabled virtualization for better performance. See https://docs.microsoft.com/en-us/uwp/api/Windows.UI.Xaml.Controls.ListView. - Qt: Implement
QAbstractItemModel
, see https://doc.qt.io/qt-5/qabstractitemmodel.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
const ENCODED : &'static [u8] = b"aGVsbG8gd29ybGQ="; | |
//const ENCODED : &'static [u8] = b"aGVlbGxvIHdvcmxk"; | |
let mut encoded = [0u8; 16]; | |
assert_eq!(ENCODED.len(), encoded.len()); | |
for i in 0..ENCODED.len() { | |
encoded[i] = ENCODED[i]; | |
} | |
let decoded = base64_decode(encoded.as_mut()).unwrap(); |
Given a chain of Rx operators, you can run certain parts of the chain on a different scheduler. SubscribeOn sets the initial scheduler of the chain, and when you call ObserveOn, the rest of the chain starts running on that scheduler, until you call ObserveOn again. You can call SubscribeOn at any point, and calling it multiple times makes little sense. ObserveOn applies to the rest of the chain from there on, so calling it multiple times makes a lot of sense. Nice diagram: http://reactivex.io/documentation/scheduler.html
Observable.From(...) ----------\
v |
Map |-- runs on threadpool
v |
Filter ----------------------/
v
ObserveOn(UIScheduler)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script type="text/javascript"> | |
function runWorker() { | |
function createMessage(n) { | |
return { | |
"foo": "bar", | |
"body": "hello world " + n, | |
"date": Date.now() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//get file from https://ccadb-public.secure.force.com/mozilla/IncludedCACertificateReportPEMCSV | |
const parse = require('csv-parse'); | |
const fs = require('fs'); | |
let data = fs.readFileSync(process.argv[2], {encoding: 'utf8'}); | |
parse(data, {}, (err, lines) => { | |
lines.forEach(line => { | |
let name = line[0]; | |
name = name.substr(0, 15); | |
let pem = line[28]; | |
pem = pem.substr(1, pem.length - 2); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//use as: sh -c 'sleep 0.3; xdotool type "$(node counted_msg.js)"; xdotool key KP_Enter' | |
const fs = require('fs'); | |
const counterPath = '/home/bwindels/Temp/counter'; | |
function getCounter() { | |
const str = fs.readFileSync(counterPath, 'utf8'); | |
return parseInt(str, 10); | |
} | |
function setCounter(n) { | |
fs.writeFileSync(counterPath, n.toString(), {flag: 'w'}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<style type="text/css"> | |
body { | |
padding: 0; | |
margin: 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Event<S> { | |
id: S | |
} | |
impl<T: AsRef<str>> Event<T> { | |
fn print(&self) { | |
println!("event({})", self.id.as_ref()); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<script> | |
function asPromise(req) { | |
return new Promise((resolve, reject) => { | |
req.onerror = (e) => reject(e.target.error); | |
req.onsuccess = (e) => resolve(e.target.result); | |
}); | |
} |