summaryrefslogtreecommitdiffstats
path: root/software
diff options
context:
space:
mode:
Diffstat (limited to 'software')
-rw-r--r--software/Xorg.page3
-rw-r--r--software/api.page6
-rw-r--r--software/bash.page2
-rw-r--r--software/css.page20
-rw-r--r--software/debian.page41
-rw-r--r--software/design_ethics.page23
-rw-r--r--software/ebook_reader.page24
-rw-r--r--software/golang.page15
-rw-r--r--software/javascript.page29
-rw-r--r--software/packaging.page4
-rw-r--r--software/photos.txt2
-rw-r--r--software/postgres.page20
-rw-r--r--software/python.page30
-rw-r--r--software/rsyslog.page20
-rw-r--r--software/rust.page118
-rw-r--r--software/rust_libs.txt7
-rw-r--r--software/sign_pdf.md16
-rw-r--r--software/web-design.page3
18 files changed, 379 insertions, 4 deletions
diff --git a/software/Xorg.page b/software/Xorg.page
new file mode 100644
index 0000000..39eb55b
--- /dev/null
+++ b/software/Xorg.page
@@ -0,0 +1,3 @@
+
+ sleep 2; DISPLAY=:0 xrandr --auto
+
diff --git a/software/api.page b/software/api.page
new file mode 100644
index 0000000..6349851
--- /dev/null
+++ b/software/api.page
@@ -0,0 +1,6 @@
+
+"Joshua Bloch: Bumper-Sticker API Design"
+https://www.infoq.com/articles/API-Design-Joshua-Bloch
+
+- https://restful-api-design.readthedocs.io/en/latest/methods.html
+- https://github.com/WhiteHouse/api-standards/blob/master/README.md#general-guidelines-for-restful-urls
diff --git a/software/bash.page b/software/bash.page
index 0d5325b..5d82fdc 100644
--- a/software/bash.page
+++ b/software/bash.page
@@ -37,6 +37,8 @@ Note that `join`, `grep`, and others sometimes exit non-zero return codes on
purpose (eg, pipe input closed or found no matches, as expected), which makes
life difficult. Sometimes `|| true` is enough to get around this.
+More on this: <http://redsymbol.net/articles/unofficial-bash-strict-mode/>
+
## General Style
Google has a style guide: https://google.github.io/styleguide/shell.xml
diff --git a/software/css.page b/software/css.page
new file mode 100644
index 0000000..bcf3467
--- /dev/null
+++ b/software/css.page
@@ -0,0 +1,20 @@
+
+## CSS Microframeworks
+
+good overview: https://blakewatson.com/journal/surveying-the-landscape-of-css-micro-frameworks/
+
+Prefered options:
+
+- https://simplecss.org/
+- https://picocss.com/
+- https://picnicss.com/
+- https://gdcss.netlify.app/
+- https://watercss.kognise.dev/
+
+Other stuff:
+
+- https://purecss.io/
+- https://picturepan2.github.io/spectre/
+- http://getskeleton.com/
+- https://jenil.github.io/chota/
+- https://tdarb.org/typesafe-css/
diff --git a/software/debian.page b/software/debian.page
index ebe3856..da874e0 100644
--- a/software/debian.page
+++ b/software/debian.page
@@ -159,7 +159,7 @@ Persist Laptop Power Saving Flags
`powertop` helps identify system flags that need tuning (`sysfs`, `iw`, etc),
which are super helpful, but these tweaks don't persist through reboots.
-You can automate setting *all* the `powertop` tunings at bood by adding
+You can automate setting *all* the `powertop` tunings at boot by adding
`powertop --auto-tune` to `/etc/rc.local` (and making sure `rc-local.service`
is configured under `systemd` if you are using that for init).
@@ -175,6 +175,45 @@ Chromium Fonts
Surprisingly, this trick worked for me:
http://www.internalpointers.com/post/fixing-ugly-fonts-chrome-chromium-debian-xfce
+More fonts:
+
+ sudo apt-get install fonts-arphic-ukai fonts-arphic-uming fonts-ipafont-mincho fonts-ipafont-gothic fonts-unfonts-core
+
+Big Fonts List
+----------------
+
+Eg, if trying to do general international stuff (PDFs from web or whatever),
+might want all of:
+
+ fonts-arphic-bkai00mp
+ fonts-arphic-bsmi00lp
+ fonts-arphic-gbsn00lp
+ fonts-arphic-gkai00mp
+ fonts-arphic-ukai
+ fonts-arphic-uming
+ fonts-farsiweb
+ fonts-indic
+ fonts-ipafont-gothic
+ fonts-ipafont-mincho
+ fonts-liberation
+ fonts-lklug-sinhala
+ fonts-nafees
+ fonts-noto
+ fonts-noto-cjk
+ fonts-noto-mono
+ fonts-noto-unhinted
+ fonts-sil-abyssinica
+ fonts-sil-ezra
+ fonts-sil-padauk
+ fonts-thai-tlwg
+ fonts-unfonts-core
+ fonts-unfonts-extra
+ xfonts-100dpi
+ xfonts-75dpi
+ xfonts-base
+ xfonts-cyrillic
+ xfonts-scalable
+
Stretch Upgrade Notes
-----------------------
diff --git a/software/design_ethics.page b/software/design_ethics.page
new file mode 100644
index 0000000..71c646b
--- /dev/null
+++ b/software/design_ethics.page
@@ -0,0 +1,23 @@
+
+## Maciej Cegłowski
+
+Six Fixes:
+
+- Right To Download
+- Right To Delete
+- Limits on Behavioral Data Collection
+- Right to Go Offline
+- Ban on Third-Party Advertising
+- Privacy Promises
+
+Later rephrased:
+
+1. The right to examine, download, and delete any data stored about you. A time horizon (weeks, not years) for how long companies are allowed to retain behavioral data (any data about yourself you didn’t explicitly provide).
+
+2. A prohibition on selling or transferring collections of behavioral data, whether outright, in an acquisition, or in bankruptcy.
+
+3. A ban on third-party advertising. Ad networks can still exist, but they can only serve ads targeted against page content, and they cannot retain information between ad requests.
+
+4. An off switch on Internet-connected devices, that physically cuts their access to the network. This switch should not prevent the device from functioning offline. You should be able to stop the malware on your refrigerator from posting racist rants on Twitter while still keeping your beer cold.
+
+5. A legal framework for offering certain privacy guarantees, with enforceable consequences. Think of this as a Creative Commons for privacy. If they can be sure data won’t be retained, users will be willing to experiment with many technologies that would pose too big a privacy risk in the current reality.
diff --git a/software/ebook_reader.page b/software/ebook_reader.page
new file mode 100644
index 0000000..74f1612
--- /dev/null
+++ b/software/ebook_reader.page
@@ -0,0 +1,24 @@
+
+dpt-rp1-py
+============
+
+To get PDF uploading to work from Debian with my Quaderno digital reader, I
+installed the `dpt-rp1-py` package for just my user (not system wide):
+
+ # or, in a venv/pipenv
+ pip3 install --user dpt-rp1-py
+
+Before running commands, ensure device and laptop are on the same local
+network. Then, run things like:
+
+ dptrp1 list-folders
+
+or, to upload files:
+
+ dptrp1 upload thing.pdf Document/Papers/
+
+To upload everything in a directory newer than a given date:
+
+ find ~/toread -iname '*.pdf' -type f -newermt "2022-05-01" | parallel -j1 dptrp1 upload {} Document/Papers/
+
+TODO: sometimes this fails for some fraction of the documents? need a delay?
diff --git a/software/golang.page b/software/golang.page
index 729b6e5..9897b65 100644
--- a/software/golang.page
+++ b/software/golang.page
@@ -12,6 +12,21 @@ function itself is called (this is intuitive).
The golang documentation gives the examples of closing file handles and
printing HTML footers (defer right after printing the header).
+Language Notes
+----------------
+
+`complex64` and `complex128` are built-in numeric types. `rune` is also built-in.
+
+Capitalization controls visibility. Everything is visible within a package;
+only upper-case things are visible outside the package.
+
+All types have a "zero value" which they are automatically initialized with if
+not defined otherwise. These include `false` for boolean, 0 for numerics, empty
+string, and `nil` in many cases. This recurses down in to structs, collections,
+etc.
+
+TODO: capitalization of struct fields
+
Learning Resources
-------------------
In addition to the excellent dynamic Tour, documentation, and other things
diff --git a/software/javascript.page b/software/javascript.page
new file mode 100644
index 0000000..217b6e5
--- /dev/null
+++ b/software/javascript.page
@@ -0,0 +1,29 @@
+
+## In-Browser Vanilla Javascript
+
+Alternatives to jQuery: https://blog.garstasio.com/you-dont-need-jquery/
+
+
+## Development Environment with nvm
+
+Use `nvm` to install nodejs, npm, etc, separately from operating system
+packages.
+
+`nvm` asks you to do a curl/bash thing, but you can just download the `nvm.sh`
+script, put it in `~/.nvm/nvm.sh`, and source it from `~/.bashrc`. Or do a git
+checkout there or something?
+
+ mkdir -p ~/.nvm
+ cd ~/.nvm
+ wget https://raw.githubusercontent.com/nvm-sh/nvm/master/nvm.sh
+ echo 'export NVM_DIR="$HOME/.nvm' >> ~/.bash_profile
+ echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> ~/.bash_profile
+ echo '[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"' >> ~/.bash_profile
+
+Then for a specific project, figure out a recent version of node and then:
+
+ cd $PROJECTDIR
+ nvm install 18
+ nvm use 18
+
+ npm install --global yarn
diff --git a/software/packaging.page b/software/packaging.page
new file mode 100644
index 0000000..52919e8
--- /dev/null
+++ b/software/packaging.page
@@ -0,0 +1,4 @@
+
+"Quick and dirty" packaging options (aka, not clean/official Debian process):
+
+- https://github.com/goreleaser/nfpm
diff --git a/software/photos.txt b/software/photos.txt
new file mode 100644
index 0000000..e195dc2
--- /dev/null
+++ b/software/photos.txt
@@ -0,0 +1,2 @@
+
+geeqie: tool for viewing/sorting photos
diff --git a/software/postgres.page b/software/postgres.page
index bdb01d8..32f2fe4 100644
--- a/software/postgres.page
+++ b/software/postgres.page
@@ -15,3 +15,23 @@ Basic status from the psql command line:
\l+ (list databases)
\dt+ (describe table)
+
+## Temporary Databases in Tests
+
+Try `pg_tmp`, though it may not work with high concurrency (due to internal
+postgres locking), and might need special configuration in CI environments.
+
+Debian also ships with `pg_virtualenv` for temporary databases.
+
+---------
+
+More refs/links:
+
+- https://stackoverflow.com/questions/9604723/alternate-output-format-for-psql
+- https://brandur.org/postgres-connections
+- https://www.citusdata.com/blog/2017/07/16/customizing-my-postgres-shell-using-psqlrc/
+- `bind "^R" em-inc-search-prev`
+- https://www.citusdata.com/blog/2019/07/17/postgres-tips-for-average-and-power-user/
+- https://github.com/citusdata/pg_auto_failover
+- https://repmgr.org/
+
diff --git a/software/python.page b/software/python.page
index 0fd2531..7133013 100644
--- a/software/python.page
+++ b/software/python.page
@@ -205,3 +205,33 @@ and create a `pytest.ini` like:
norecursedirs = .svn _build tmp*
Need to mock? <https://blog.fugue.co/2016-02-11-python-mocking-101.html>
+
+Debugging Memory Usage
+------------------------
+
+Most helpful tools I found were `psutil` and `pympler` (both need to be
+installed).
+
+ import os, psutil
+ process = psutil.Process(os.getpid())
+ print(process.memory_info().rss)
+ # ... do some stuff ...
+ print(process.memory_info().rss)
+
+and
+
+ from pympler import tracker
+ tr = tracker.SummaryTracker()
+ tr.print_diff()
+
+ # ... do some stuff ...
+ tr.print_diff()
+
+
+Canonical Timestamp
+--------------------
+
+As a terse one-liner (with `datetime` imported):
+
+ f"{datetime.datetime.utcnow().isoformat()[:-3]}Z"
+
diff --git a/software/rsyslog.page b/software/rsyslog.page
new file mode 100644
index 0000000..b55c127
--- /dev/null
+++ b/software/rsyslog.page
@@ -0,0 +1,20 @@
+
+Put these in files like `/etc/rsyslog.d/40-grobid-skip.conf`.
+
+Filter out lines from a given program:
+
+ :programname, isequal, "GROBID" ~
+
+Or matching a pattern:
+
+ :msg, startswith, "inserting line to HBase: sha1:"
+ :msg, contains, " INFO GET http"
+
+For list of operations ("isequal", "regex", "contains"):
+
+ https://www.rsyslog.com/doc/v8-stable/configuration/filters.html
+
+For list of properties (":msg", ":programname"):
+
+ https://www.rsyslog.com/doc/v8-stable/configuration/properties.html
+
diff --git a/software/rust.page b/software/rust.page
index df99de4..b76c097 100644
--- a/software/rust.page
+++ b/software/rust.page
@@ -3,9 +3,11 @@ Rust
## Resources
-- [http://xion.io/post/code/rust-iter-patterns.html]()
-- [https://deterministic.space/rust-cli-tips.html]()
-- [https://manishearth.github.io/blog/2018/01/10/whats-tokio-and-async-io-all-about/]()
+- <http://xion.io/post/code/rust-iter-patterns.html>
+- <https://deterministic.space/rust-cli-tips.htm>
+- <https://deterministic.space/elegant-apis-in-rust.html>
+- <https://manishearth.github.io/blog/2018/01/10/whats-tokio-and-async-io-all-about/>
+- <https://saghm.github.io/five-rust-things/>
Optimization: use `RUSTFLAGS="-C target-cpu=native"` to take advantage of CPU
special features.
@@ -22,3 +24,113 @@ Run tests with stdout output:
To run tests with logging enabled (eg, with `env_logger`), make sure you add
`env_logger::init()` to the test function itself.
+
+
+## map() and Result Ergonomics
+
+`.collect()` has some magical features! In addition to turning an iterator of
+`Item` into `Vec<Item>`, it will turn an iterator of `Result<Item>` into
+`Result<Vec<Item>>`. This makes it really useful for the end of functions.
+
+This is particularly useful for resolving some categories of "error handling in
+map closures": you can use `?` in the map closure as long as you wrap the happy
+path with `Ok()` and call collect on the outside. Eg:
+
+ let list: Vec<Item> = junk
+ .iter()
+ .map(|thing| Ok(Item {
+ a: thing.a,
+ b: fixup(thing.widget)?,
+ }))
+ .collect::Result<Vec<Item>>()?;
+
+What about when `map` over an `Option`? Eg:
+
+ let toy = Shiny {
+ a: 123,
+ b: component.map(|v| paint(v).expect("paint to succeed"),
+ };
+
+Should use match in this case:
+
+ let toy = Shiny {
+ a: 123,
+ b: match component {
+ None => None,
+ Some(v) => Some(paint(v)?),
+ },
+ };
+
+## 2020-05-17 Reading
+
+While working on fatcat-cli tool, checked the The Rust Programming Language
+book to read about trait objects and the `dyn` keyword, which I had ignored
+previously.
+
+They seem like they could be used in a few places in fatcat-server rust code.
+We don't particularly care about per-function-call performance there, and most
+entities are already allocated on the heap.
+
+Other small syntax and thing learned:
+
+Can copy a struct while only updating specific fields with ".." syntax. Might
+use this in fatcat-cli for update mutation.
+
+This is the cleanest example of using ErrorKind that I have seen:
+
+ let f = match f {
+ Ok(file) => file,
+ Err(error) => match error.kind() {
+ ErrorKind::NotFound => match File::create("hello.txt") {
+ Ok(fc) => fc,
+ Err(e) => panic!("Problem creating the file: {:?}", e),
+ },
+ other_error => {
+ panic!("Problem opening the file: {:?}", other_error)
+ }
+ },
+ };
+
+I didn't realize that test code may get compiled into non-test binaries unless
+annotated with `#[cfg(test)]`. You are supposed to create a sub-module within
+each `src/` file with unittests, like:
+
+ #[cfg(test)]
+ mod tests {
+ use super::*;
+
+ #[test]
+ fn it_works() {
+ assert_eq!(2 + 2, 4);
+ }
+ }
+This doesn't apply to `tests/` directory, which is for integration tests.
+
+The common pattern for binary crates (vs. library crates) is to have `main.rs`
+and `lib.rs`, with any code that needs to be tested in `lib.rs` (aka, all the
+actual logic).
+
+I think I knew `eprintln!()` (for stderr) vs. `println!()` (for stdout), but
+good to remember.
+
+There is a description of how to avoid memory leaks with reference counting
+using "weak" `Rc` references. Probably worth reading the [entire chapter on smart pointers](https://doc.rust-lang.org/book/ch15-06-reference-cycles.html#preventing-reference-cycles-turning-an-rct-into-a-weakt)
+(including Box, Rc, RefCell) again.
+
+For the `Sized` trait, and `Sized` trait alone, can specify an ambiguous trait
+constraint with `?` to indicate "may or may not be Sized", which doesn't really
+mean anything but does explicitly allow generic functions over non-sized traits
+like:
+
+ fn my_generic_func<T: ?Sized>(t: &T) {
+ // --snip--
+ }
+
+A trait can depend on another trait. For example, a PrettyPrint trait could
+rely on Display (and impl functions could call functions from Display). This is
+done on the trait definition line. Such a trait is called a "supertrait".
+
+Implementing Deref on a wrapper type allows transparent access to all the trait
+methods on the interior object.
+
+Also, a new longer post on error handling: <https://nick.groenen.me/posts/rust-error-handling/>
diff --git a/software/rust_libs.txt b/software/rust_libs.txt
new file mode 100644
index 0000000..967a4b6
--- /dev/null
+++ b/software/rust_libs.txt
@@ -0,0 +1,7 @@
+
+https://github.com/RazrFalcon/pico-args
+ smaller than clap
+
+https://lib.rs/crates/dirs
+
+https://lib.rs/crates/axum
diff --git a/software/sign_pdf.md b/software/sign_pdf.md
new file mode 100644
index 0000000..c81643d
--- /dev/null
+++ b/software/sign_pdf.md
@@ -0,0 +1,16 @@
+
+How to sign a PDF on Linux
+===========================
+
+First, you need a transparent image of signature, eg as a PNG file. Android
+works pretty well for this: you can sign a blank piece of paper, take a
+photo, and clean it up. Then can use gimp if necessary to remove background
+and make a transparent image.
+
+NOTE: if text import isn't working, need to go in preferences and change input
+type (!), see also <https://github.com/xournalpp/xournalpp/issues/2035>.
+
+To edit PDFs, use `xournalpp`, which is a GUI tool packaged in Debian. You
+can add text and paste images, then export as PDF.
+
+Via: <https://www.xmodulo.com/add-signature-pdf-document-linux.html>
diff --git a/software/web-design.page b/software/web-design.page
index 48ee7a0..02412f5 100644
--- a/software/web-design.page
+++ b/software/web-design.page
@@ -2,5 +2,8 @@
- http://bootswatch.com/simplex/
- https://semantic-ui.com/
- https://purecss.io/
+- https://bulma.io/
+- https://simplecss.org/ ("classless"; used in adenosine)
+- https://picocss.com/
"Little UI Details": https://twitter.com/i/moments/880688233641848832