2021/11/29
that there’s a pg_sleep(seconds) function: see https://til.hashrocket.com/posts/8a6f68519d-sleeping-in-postgresql
that there’s a pg_sleep(seconds) function: see https://til.hashrocket.com/posts/8a6f68519d-sleeping-in-postgresql
Not to use BETWEEN for timestamps
Not to use char(n), or varchar(n), since they’re not natively fixed-width and will defy expectations.
See https://wiki.postgresql.org/wiki/Don't_Do_This
Also, I learned that you can’t run chsh(1) with sudo; chsh needs to run as the user who’s changing their shell.
that sudo can be configured with the visudo command and that sudo can produce audit logs.
See https://www.sudo.ws/posts/2022/05/sudo-for-blue-teams-how-to-control-and-log-better/
that there’s an Element.closest(selector) method, which means you can run this function to set the url to the closest link to an element:
((el) => {
let id = el.closest("[id]")?.id;
if (!id) return;
else location.hash = id;
})($0);
that you can use
SELECT /*...*/
FROM one_table
JOIN other_table
USING (common_column)
as shorthand for one_table.common_column = other_table.common_column.
See https://www.postgresql.org/docs/current/sql-select.html#SQL-FROM
That sql has assertions:
CREATE ASSERTION <Constraint name>
CHECK (search condition)
[ <constraint attributes> ]
see https://crate.io/docs/sql-99/en/latest/chapters/20.html#create-assertion-statement.
h/t https://www.scattered-thoughts.net/log/0024/ for bringing that to my attention.
Also, from the weekend: in postgres, at least, you can call TABLE :table_name; directly to SELECT * FROM :table_name;
Also: how to look up a domain name from an ip:
reverse_ip_lookup() {
ip_address="$1"
dig -x $ip_address +noall +answer
}
Also: how to audit AWS VPC flow logs from CloudWatch Log Insights: use the example queries in the right sidebar.
Also: python can execute .zip files directly, like so:
:; echo 'print("Hello, World!")' > __main__.py
:; zip hello-world.zip __main__.py
:; python3 ./hello-world.zip
## Hello, World!
h/t https://pradeepchhetri.xyz/til/pythonzip/ for pointing that out.
Of the existence of MDX (MultiDimensional eXpressions), a query language for OLAP cubes. I came across it while researching clickhouse db.
That SQL implementations with recursive CTEs are Turing-complete! It makes sense: recursion and conditionals are all that is required for Turing completeness.