-
Embedded Programming Notes
Embedded Programming Interview Prep
-
Automating the Howard Chu Homepage
This is done via
github webhookandsystemd. When github receives a push (likely from local branch), it notifies the remote server that it should pull. The remote server pulls from github, and runsdocker buildto build the website, and serves it withnginx.The auto-build program is a
Flaskscript managed bysystemd, setup by generating asystemdservice file using theauto-build-setup.shshell script.service="[Unit] Description=howard-chu-www auto build daemon [Service] Type=simple WorkingDirectory=$(pwd) ExecStart=$(pwd)/.venv/bin/flask run --host 0.0.0.0 --port 5000 Restart=on-failure RestartSec=3 KillSignal=SIGKILL Environment="FLASK_ENV=production" Environment="PYTHONUNBUFFERED=1" [Install] WantedBy=multi-user.target" echo "$service" > /etc/systemd/system/howard-chu-www.service sudo systemctl daemon-reload sudo systemctl enable howard-chu-www sudo systemctl start howard-chu-www -
Study notes on the C++ template
overload > specialization > general template
specialization:
// special version of compare to handle pointers to character arrays template <> int compare(const char* const &p1, const char* const &p2) { return strcmp(p1, p2); } // this is also specialization: template <class T> struct ValidityError; template <> struct ValidityError<core::Signal*> { enum { value = HSA_STATUS_ERROR_INVALID_SIGNAL }; }; template <> struct ValidityError<core::Agent*> { enum { value = HSA_STATUS_ERROR_INVALID_AGENT }; }; -
Using lldb to read C++ standard library
C++ standard library can be hard to read, using a debugger to help with learning can be a good approach.
My machine is a mac so this will be
clang’s std library. And I’m usinglldbbecause it’s better supported thangdb. Here’s how to do it.Install
lldb, typically usexcode-select --install -
How to contribute to perf
TL;DR:
- Clone the repo:
git clone https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/ # switch to perf-tools-next branch git checkout perf-tools-next # cd into the perf's directory cd tools/perf -
perf trace: Add support for enum arguments
perf tracenow supports pretty printing for enum argumentsWell, that been said, there is only one argument that can be pretty printed in all syscalls, which is
enum landlock_rule_type rule_typefrom syscalllandlock_add_rule.This feature is implemented using the BPF Type Format.
Here is
perf tracebefore:perf $ ./perf trace -e landlock_add_rule 0.000 ( 0.008 ms): ldlck-test/438194 landlock_add_rule(rule_type: 2) = -1 EBADFD (File descriptor in bad state) 0.010 ( 0.001 ms): ldlck-test/438194 landlock_add_rule(rule_type: 1) = -1 EBADFD (File descriptor in bad state) -
Shared vim clipboard when using SSH
- For Windows, download MobaXterm or Xming; for Mac, download XQuartz as the X server. After downloading, open the application.
Note that on Mac XQuartz works after I uncheck the
Enable Syncing, and check it back again. Link And tmux doesn’t work well on Mac’s default Terminal.app. For sharing clipboard you need to install tmux-yank plugin - In the server’s SSH configuration file located at
/etc/ssh/sshd_config, enableX11Forwarding yes. - Based on personal experience, use the X server address provided in MobaXterm and set the Windows environment variable
$env:DISPLAYto that address. This can be done inEdit System Environment Variables.
- For Windows, download MobaXterm or Xming; for Mac, download XQuartz as the X server. After downloading, open the application.
-
Launch Elixir app with mix
0.5 define
main.ex, usemix run main.ex(duplicates with 2.)main.ex:
defmodule Main do Server.main() endserver.ex:
defmodule Server do # no need to import def main do path = Path.join(File.cwd!(), "title.yaml") yaml_list = YamlElixir.read_from_file(path) IO.inspect(yaml_list) end endoutput
server > mix run main.ex Compiling 1 file (.ex) Generated server app {:ok, %{1. Use
iex -S mixormix run -e