Giter VIP home page Giter VIP logo

til's Introduction

Today I Learned

My Today I Learned snippets. Inspired by jbranchaud/til, which I spotted on Hacker News.

Search these TILs at https://til.simonwillison.net/

508 TILs so far. Atom feed here.

github-actions

python

zeit-now

sqlite

presenting

macos

cloudrun

tailscale

pytest

github

node

firefox

markdown

pypi

asgi

heroku

javascript

django

docker

homebrew

zsh

readthedocs

ics

svg

linux

jq

bash

typescript

aws

jinja

selenium

digitalocean

datasette

jupyter

cookiecutter

gis

sphinx

postgresql

mediawiki

azure

vscode

wikipedia

vega

spatialite

sql

amplitude

vim

reddit

nginx

tesseract

imagemagick

observable-plot

purpleair

electron

googlecloud

git

web-components

kubernetes

deno

fly

caddy

npm

pluggy

cloudflare

webauthn

pixelmator

graphql

google-sheets

twitter

shot-scraper

auth0

webassembly

service-workers

networking

gpt3

quarto

duckdb

awslambda

cocktails

html

mastodon

json

clickhouse

cooking

llms

ab

hacker-news

observable

midjourney

exif

misc

http

discord

yaml

overture-maps

cosmopolitan

google

machinelearning

css

pyodide

playwright

httpx

valtown

chrome

go

til's People

Contributors

davidbgk avatar frosencrantz avatar fynsta avatar hugovk avatar neamar avatar otoolep avatar pronoiac avatar shaver avatar simonw avatar tnorthcutt avatar tomviner avatar tubaman avatar welpo avatar yefim avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

til's Issues

minor issue on simple-recursive-cte.md?

Was reading https://github.com/simonw/til/blob/main/sqlite/simple-recursive-cte.md and wondering if the last query on the page

with recursive counter(x, y) as (
  select 0 as x, 1 as y
    union
  select x + 1, x + 2 from counter
)
select * from counter limit 5;

should read

with recursive counter(x, y) as (
  select 0 as x, 1 as y
    union
  select x + 1, y + 2 from counter
)
select * from counter limit 5;

Note replacement of x+2 with y+2. That would result in the following (from my own VBScript tool using ODBC) which seems to be your intention:

x(vbLong):0,y(vbLong):1
x(vbLong):1,y(vbLong):3
x(vbLong):2,y(vbLong):5
x(vbLong):3,y(vbLong):7
x(vbLong):4,y(vbLong):9

Yeah I know you're asking why not use Datasette...I'd love to but I'm limited to what is provided by OS and what can be compiled with Visual Studio. So for scripting it is VBScript/Javascript and ADO recordsets via ODBC. But I do read/love your site/blog/TIL and always try to keep up with posts just for the SQLite tidbits :-)

Correction to github/migrate-github-wiki

I followed your procedure (thank you for that) but got 'repository not found' on the push step. FIgured out that there is no wiki repo until you add a page. So you need a step, if the wiki on the new repo has never been used, save the home page first.

Downloading the previous database file no longer works (>5MB)

Vercel has a 5MB size limit on responses. The til.db database is now 5.1 MB thanks to the screenshots, which means it can no longer be downloaded. This dramatically slows down the builds as each build has to generate the HTML and screenshot for every page.

Social image broken for latest entry

Hey, just noticed that this post has a broken image in my RSS reader

Shot_2022-12-13_14 06 44@2x

with an alt text of sqlite_multiple_indexes.md. This caught my attention and I viewed the source and realized that social images meta tags are linked to the source file.

<meta name="twitter:image" content="https://til.simonwillison.net/-/media/screenshot/{{ til.path }}">
<meta name="twitter:image:alt" content="Screenshot of this article">
<meta property="og:url" content="https://til.simonwillison.net/til/til/{{ til.path }}">
<meta property="og:type" content="article">
<meta property="og:title" content="{{ til.title }}">
<meta property="og:description" content="{{ til.body[:200] }}">
<meta property="og:image" content="https://til.simonwillison.net/-/media/screenshot/{{ til.path }}">

SSH daemons bound to WireGuard interface only can still be accessed from non-WireGuard network

https://github.com/simonw/til/blob/master/tailscale/lock-down-sshd.md suggests binding SSH daemon to the WireGuard interface only. This security measure can be bypassed because most modern Linux hosts use the Weak Host Model (see rp_filter settings). Packets received on non-WireGuard (e.g., eth0) interface, with destination IP of the WireGuard interface, will be happily delivered to the SSH daemon, and its replies will go out of the non-WireGuard interface. This, in effect, bypasses WireGuard. See rp_filter and https://lwn.net/Articles/806546/ for more information.

Mitigations:

  • Don't rely on VPNs as the primary security mechanism. Use application level security (well-configured and hardened SSH daemon) as the primary security mechanism. VPNs are fine for defense in depth.
  • If you want to rely on VPN as the primary security mechanism, change rp_filter sysctls or add firewall rules.

Lambda Layers

Thank for this text, working on something similar, you might want to explore Lambda Layers and also you can test locally and push your code using vscode aws extension

[IDEA] Tiddlywiki and TIL

Have you ever tried Tiddlywiki for TIL. It is a single page html5 and you can create TIL on the fly using it.

See: https://tiddlywiki.com/

Do not forget to check its forum and a vast of apps created using Tiddlywiki.

Renaming a page breaks the build

The rename in b9f613d broke things: https://github.com/simonw/til/runs/1059759359?check_suite_focus=true

Traceback (most recent call last):
Rendered HTML for github/dependencies-graphql-api.md
  File "build_database.py", line 98, in <module>
    build_database(root)
Rendered HTML for bash/loop-over-csv.md
  File "build_database.py", line 90, in build_database
Rendered HTML for readthedocs/custom-subdomain.md
    record.update(all_times[path])
Rendered HTML for readthedocs/readthedocs-search-api.md
KeyError: 'cloudrun/gcloud-run-services-list.md'

It looks like the all_times = created_changed_times(repo_path) function can't handle files that were renamed.

Deploy fails silently

https://github.com/simonw/til/runs/6887335796 ran successfully but actually didn't deploy:

/usr/local/lib/node_modules/vercel/dist/index.js:201730
        .filter((b) => Boolean(b.config && b.config.zeroConfig && b.src?.startsWith('api/')))
                                                                        ^
SyntaxError: Unexpected token '.'
    at wrapSafe (internal/modules/cjs/loader.js:915:16)
    at Module._compile (internal/modules/cjs/loader.js:963:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
    at internal/main/run_main_module.js:17:47

CSS for code syntax highlighting

The GitHub Markdown renderer produces HTML with classes like this:

<pre>with today_points <span class="pl-k">as</span> (
  <span class="pl-k">select</span>
    datetime,
    mllw_feet
  <span class="pl-k">from</span>
    tide_predictions
  <span class="pl-k">where</span>
    <span class="pl-k">date</span>(<span class="pl-s"><span class="pl-pds">"</span>datetime<span class="pl-pds">"</span></span>) <span class="pl-k">=</span> :p0
    <span class="pl-k">and</span> <span class="pl-s"><span class="pl-pds">"</span>station_id<span class="pl-pds">"</span></span> <span class="pl-k">=</span> :p1
),
min_max <span class="pl-k">as</span> (
  <span class="pl-k">select</span>
    <span class="pl-c1">min</span>(mllw_feet) <span class="pl-k">as</span> min_feet,
    <span class="pl-c1">max</span>(mllw_feet) <span class="pl-k">as</span> max_feet
  <span class="pl-k">from</span>
    today_points
),
points <span class="pl-k">as</span> (
  <span class="pl-k">select</span>
    RANK () OVER (
      <span class="pl-k">ORDER BY</span>
        datetime
    ) <span class="pl-k">-</span><span class="pl-c1">1</span> <span class="pl-k">as</span> rank,
    <span class="pl-c1">min_max</span>.<span class="pl-c1">min_feet</span>,
    <span class="pl-c1">min_max</span>.<span class="pl-c1">max_feet</span>,
    mllw_feet,
    (
      <span class="pl-c1">100</span> <span class="pl-k">*</span> (mllw_feet <span class="pl-k">-</span> <span class="pl-c1">min_max</span>.<span class="pl-c1">min_feet</span>) <span class="pl-k">/</span> (<span class="pl-c1">min_max</span>.<span class="pl-c1">max_feet</span> <span class="pl-k">-</span> <span class="pl-c1">min_max</span>.<span class="pl-c1">min_feet</span>)
    ) <span class="pl-k">as</span> line_height_pct
  <span class="pl-k">from</span>
    tide_predictions,
    min_max
  <span class="pl-k">where</span>
    <span class="pl-k">date</span>(<span class="pl-s"><span class="pl-pds">"</span>datetime<span class="pl-pds">"</span></span>) <span class="pl-k">=</span> :p0
    <span class="pl-k">and</span> <span class="pl-s"><span class="pl-pds">"</span>station_id<span class="pl-pds">"</span></span> <span class="pl-k">=</span> :p1
  <span class="pl-k">order by</span>
    datetime
)
<span class="pl-k">select</span>
  group_concat(rank <span class="pl-k">||</span> <span class="pl-s"><span class="pl-pds">'</span>,<span class="pl-pds">'</span></span> <span class="pl-k">||</span> line_height_pct, <span class="pl-s"><span class="pl-pds">'</span> <span class="pl-pds">'</span></span>)
<span class="pl-k">from</span>
  points</pre>

I'd like to add CSS that colours those in sensible ways.

"I imagine there's a more elegant way to do this using a window function"

https://til.simonwillison.net/sql/cumulative-total-over-time says:

I imagine there's a more elegant way to do this using a window function but this works fine.

I was looking at queries of this sort recently. Here would be my suggestion:

select
  created_at,
  count(*) over (
    order by
      created_at
  ) as cumulative
from
  repos
where
  "owner" = :owner
order by
  created_at desc

It seems to run a little faster than the original query too.

Example query

I'd have written you an e-mail but couldn't find one on your website.

Homepage should be more like a blog

I really like being able to see the most recent ones at the top. I'll have a separate /all page showing everything in one place.

Would be good to show the first paragraph of each one too.

Add Plausible for analytics

I added this to my existing account. Need to add this snippet:

<script defer data-domain="til.simonwillison.net" src="https://plausible.io/js/plausible.js"></script>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.