Skip to content

Commit

Permalink
Quartz sync: Jan 3, 2024, 10:43 PM
Browse files Browse the repository at this point in the history
  • Loading branch information
ellie committed Jan 3, 2024
1 parent 7bb92f3 commit fb16670
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 6 deletions.
17 changes: 11 additions & 6 deletions content/notes/postgresql.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ title: PostgreSQL
tags:
- postgresql
- infra
updated: 03/01/2024
---
Some postgres snippets! Just a reference page for the things I forget a lot.

Expand All @@ -24,41 +25,45 @@ Some postgres snippets! Just a reference page for the things I forget a lot.
- `\c dbname` connect to database as current user

### Create table as copy of another
```
```sql
create table new_table as table old_table;
```
Note: this will copy all data, but no indices or constraints

For no data

```
```sql
create table new_table as table old_table with no data;
```

If you'd like to query/filter it:

```
```sql
create table new_table as (select * from old_table where some_condition);
```

### Check for waiting locks
```
```sql
select relation::regclass, * from pg_locks where not granted;
```

### Get database size

```
```sql
SELECT pg_size_pretty(pg_database_size('database name'));
```

### Get table size
```sql
SELECT pg_size_pretty(pg_relation_size('records'));
```
### Monitoring replication slots
```
SELECT * FROM pg_replication_slots;
```

### Monitoring replication lag
```
```sql
SELECT extract(epoch from now() - pg_last_xact_replay_timestamp()) AS replica_lag
```

Expand Down
2 changes: 2 additions & 0 deletions quartz.layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const defaultContentPageLayout: PageLayout = {
Component.MobileOnly(Component.Spacer()),
Component.Search(),
Component.Darkmode(),
Component.DesktopOnly(Component.Links()),
Component.DesktopOnly(Component.RecentNotes()),
],
right: [
Expand All @@ -44,6 +45,7 @@ export const defaultListPageLayout: PageLayout = {
Component.MobileOnly(Component.Spacer()),
Component.Search(),
Component.Darkmode(),
Component.DesktopOnly(Component.RecentNotes()),
],
right: [],
}
47 changes: 47 additions & 0 deletions quartz/components/Links.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { QuartzComponentConstructor, QuartzComponentProps } from "./types"
import { FullSlug, SimpleSlug, resolveRelative } from "../util/path"
import { QuartzPluginData } from "../plugins/vfile"
import { byDateAndAlphabetical } from "./PageList"
import style from "./styles/links.scss"
import { Date, getDate } from "./Date"
import { GlobalConfiguration } from "../cfg"

interface Options {
title: string
}

const defaultOptions = (cfg: GlobalConfiguration): Options => ({
title: "",
})

export default ((userOpts?: Partial<Options>) => {
function Links({ allFiles, fileData, displayClass, cfg }: QuartzComponentProps) {
const opts = { ...defaultOptions(cfg), ...userOpts }
return (
<div class={`links ${displayClass ?? ""}`}>
<h3>{opts.title}</h3>
<ul>
<li>
<h3 style={{marginTop: 0, marginBottom: 0}}><a href="/notes">Notes</a></h3>
<i>where I share what I've learned</i>
</li>
<li>
<h3 style={{marginTop: 0, marginBottom: 0}}><a href="/life">Life</a></h3>
<i>where I write about my adventures</i>
</li>
<li>
<h3 style={{marginTop: 0, marginBottom: 0}}><a href="/posts">Posts</a></h3>
<i>my longer form thoughts</i>
</li>
<li>
<h3 style={{marginTop: 0, marginBottom: 0}}><a href="/projects">Projects</a></h3>
<i>cool things I've made</i>
</li>
</ul>
</div>
)
}

Links.css = style
return Links
}) satisfies QuartzComponentConstructor
2 changes: 2 additions & 0 deletions quartz/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import DesktopOnly from "./DesktopOnly"
import MobileOnly from "./MobileOnly"
import RecentNotes from "./RecentNotes"
import Breadcrumbs from "./Breadcrumbs"
import Links from "./Links"

export {
ArticleTitle,
Expand All @@ -42,4 +43,5 @@ export {
RecentNotes,
NotFound,
Breadcrumbs,
Links,
}
19 changes: 19 additions & 0 deletions quartz/components/styles/links.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.links {
ul {
list-style: none;
margin-top: 1rem;
padding-left: 0;

& > li {
margin: 1rem 0;
.section > .desc > h3 > a {
background-color: transparent;
}

.section > .meta {
margin: 0 0 0.5rem 0;
opacity: 0.6;
}
}
}
}

0 comments on commit fb16670

Please sign in to comment.