Merge branch 'dev' into vhs
This commit is contained in:
16
data/recfiles/IP_ASN.md
Normal file
16
data/recfiles/IP_ASN.md
Normal file
@@ -0,0 +1,16 @@
|
||||
---
|
||||
title: "IP Addresses with Recfiles"
|
||||
tags: [ "data", "recfiles", "games" ]
|
||||
requires: "Recfiles"
|
||||
---
|
||||
|
||||
## Download the Database
|
||||
|
||||
Download the csv data, and separate the ipv4 data from the ipv6.
|
||||
|
||||
```sh
|
||||
curl -Lo ips.zip 'https://www.kaggle.com/api/v1/datasets/download/ipinfo/ipinfo-country-asn'
|
||||
unzip -p ips.zip country_asn.csv | csv2rec | recsel -e "start_ip ~ '\.'" > ipv4.rec
|
||||
unzip -p ips.zip country_asn.csv | csv2rec | recsel -e "start_ip ~ '::'" > ipv6.rec
|
||||
```
|
||||
|
121
data/recfiles/bibliography.md
Normal file
121
data/recfiles/bibliography.md
Normal file
@@ -0,0 +1,121 @@
|
||||
---
|
||||
title: "Recfile Bibliography for TeX"
|
||||
tags: [ "data", "database", "recfiles", "tex" ]
|
||||
requires: [ "Recfiles", "TeX", "Makefile" ]
|
||||
---
|
||||
|
||||
Store your bibliography in a `recfile` database, then extract any part with `make`.
|
||||
|
||||
For example, you could store books like this in `bibliography.rec`:
|
||||
|
||||
```recfile
|
||||
%rec: book
|
||||
%key: slug
|
||||
|
||||
slug: thinkingexperience
|
||||
author: H. H. Price
|
||||
title: Thinking and Experience
|
||||
year: 1953
|
||||
publisher: Harvard University Press, Cambridge
|
||||
|
||||
slug: inventingrightwrong
|
||||
author: John Leslie Mackie
|
||||
title: Inventing Right and Wrong
|
||||
year: 1997
|
||||
publisher: Penguin Books, England
|
||||
|
||||
```
|
||||
|
||||
Run `make book` to extract `book.bib`, ready for LaTeX to use:
|
||||
|
||||
```bib
|
||||
@book{thinkingexperience,
|
||||
author = {H. H. Price},
|
||||
title = {Thinking and Experience},
|
||||
year = {1953},
|
||||
publisher = {Harvard University Press, Cambridge},
|
||||
}
|
||||
|
||||
@book{inventingrightwrong,
|
||||
author = {John Leslie Mackie},
|
||||
title = {Inventing Right and Wrong},
|
||||
year = {1997},
|
||||
publisher = {Penguin Books, England},
|
||||
}
|
||||
```
|
||||
|
||||
The `makefile` syntax is just a few lines (though admittedly employs some garbled shell-crud):
|
||||
|
||||
```make
|
||||
bibs != grep -Po '%rec: \K.*' bibliography.rec
|
||||
bibfiles = $(patsubst %, %.bib, $(bibs))
|
||||
|
||||
$(bibfiles): %.bib: bibliography.rec
|
||||
recsel $< -t $(basename $@) |\
|
||||
sed 's/slug: \(.*\)/@$(basename $@){\1,/g' |\
|
||||
sed 's/^\(\b.*\b\): \(.*\)/ \1 = {\2},/gI' |\
|
||||
sed 's/^$$/}\n/g' > $@
|
||||
echo '}' >> $@
|
||||
```
|
||||
|
||||
Here's a longer `bibliography.rec` file, which can also produce `article.bib`:
|
||||
|
||||
```recfile
|
||||
%rec: book
|
||||
%key: slug
|
||||
%type: year int
|
||||
%constraint: year > -2000
|
||||
%sort: year month
|
||||
|
||||
slug: thinkingexperience
|
||||
author: H. H. Price
|
||||
title: Thinking and Experience
|
||||
year: 1953
|
||||
publisher: Harvard University Press, Cambridge
|
||||
|
||||
slug: inventingrightwrong
|
||||
author: John Leslie Mackie
|
||||
title: Inventing Right and Wrong
|
||||
year: 1997
|
||||
publisher: Penguin Books, England
|
||||
|
||||
slug: metaphysicscontemporaryintro
|
||||
author: Michael J. Loux
|
||||
title: Metaphysics: A Contemporary Introduction
|
||||
year: 1998
|
||||
publisher: Routledge, London
|
||||
|
||||
slug: pluralityworlds
|
||||
author: David Lewis
|
||||
title: On the Plurality of Worlds
|
||||
publisher: Blackwell Publishing, Oxford
|
||||
year: 2001
|
||||
|
||||
%rec: article
|
||||
%key: slug
|
||||
%sort: year month
|
||||
|
||||
slug: genuinerealisttheory
|
||||
author: John Divers
|
||||
title: A Genuine Realist Theory of Advanced Modalizing
|
||||
year: 1999
|
||||
pages: 217–240
|
||||
month: april
|
||||
journaltitle: Mind
|
||||
uri: https://academic.oup.com/mind/article-abstract/108/430/217/975258?redirectedFrom=fulltext
|
||||
volume: 108
|
||||
publisher: Harvard University Press, Cambridge
|
||||
|
||||
slug: twokindsmentalrealism
|
||||
author: Tam\'{a}s Demeter
|
||||
title: Two Kinds of Mental Realism
|
||||
year: 2009
|
||||
pages: 40:59-71
|
||||
uri: https://www.researchgate.net/profile/Tamas_Demeter2/publication/41554923_Two_Kinds_of_Mental_Realism/links/0deec53247f5a4ae21000000.pdf
|
||||
month: august
|
||||
journaltitle: Journal for General Philosophy of Science
|
||||
volume: 30
|
||||
publisher: Harvard University Press, Cambridge
|
||||
|
||||
```
|
||||
|
33
data/recfiles/recfixes.md
Normal file
33
data/recfiles/recfixes.md
Normal file
@@ -0,0 +1,33 @@
|
||||
---
|
||||
title: "Recfixes"
|
||||
tags: [ "data", "recfiles" ]
|
||||
requires: "Recfiles"
|
||||
---
|
||||
|
||||
Sometimes `recsel` chokes on a large query, and you need to break the query into chunks with a pipe.
|
||||
|
||||
This Kickstarter file has 374,853 records.
|
||||
Here's the chonky query:
|
||||
|
||||
```sh
|
||||
recsel kick.rec -e "Category = 'Games'" -p "Subcategory,Avg(Goal)" -G Subcategory
|
||||
```
|
||||
|
||||
It breaks down like this:
|
||||
|
||||
| Chunk | Meaning |
|
||||
|:-----------------------------:|:---------------------------------------------:|
|
||||
| `recsel kick.rec` | Select records from `kick.rec` |
|
||||
| `-e "Category = 'Games'"` | Select only records where Category = 'Games' |
|
||||
| `-p "Subcategory,Avg(Goal)"` | Print the Subcategory and average goal |
|
||||
| `-G "Subcategory"` | Group by subcategory |
|
||||
|
||||
Two ways to break the query apart:
|
||||
|
||||
```sh
|
||||
recsel kick.rec -e "Category = 'Games'" | recsel -p "Subcategory,Avg(Goal)" -G "Subcategory"
|
||||
|
||||
recsel kick.rec -e "Category = 'Games'" > games.rec
|
||||
recsel games.rec -p "Subcategory" -G "Subcategory"
|
||||
```
|
||||
|
Reference in New Issue
Block a user