This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { Pool } = require('pg'); | |
const connectionString = require('./connection-string.json'); | |
const pool = new Pool(connectionString); | |
async function main () { | |
const x = await pool.query('Select count(*) from my_table'); | |
console.log(x.rows); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function downloadPage (matches) { | |
for (let match of matches) { | |
const requestUrl = `tktk`; | |
const html = await wget(requestUrl); | |
} | |
} | |
async function wget (requestUrl) { | |
return new Promise((resolve, reject) => { | |
const cmd = `wget -q -O - '${requestUrl}'`; |
If you have any tips or areas to discuss, you can get in touch a few different ways:
- Keybase
- Email
- mhkeller@nytimes.com (note: michael.keller@nytimes is not me so please don't send him email)
- Phone
- (212) 556-7148
- NY Times tips page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\copy (SELECT * FROM persons) to 'C:\tmp\persons_client.csv' with (format csv, header) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const wait = ms => new Promise(f => setTimeout(f, ms)); | |
// wait(500) |
When creating a polylinear time scale, the tricky part is to know to which value in the range the intermediate dates should map.
Let's say we want to "zoom in" on 4 particular days and make them appear with the size of 10 days each. Because these days now take up more space (36 or (factor - 1) * n
), we need to create a linear time scale where the domain ends at 36 days later than we want to show. This scale is then used to determine the intermediary range values of the polylinear scale.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Pool } from 'pg'; | |
export default function db (connectionString) { | |
const pool = new Pool(connectionString); | |
pool.on('error', err => { | |
console.error(err); | |
}); | |
return pool; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1 style="opacity: 0.25;{color}">Hello {name}!</h1> | |
<script> | |
export default { | |
data () { | |
return { | |
color: 'color: #fc0;' | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Adapted from https://unix.stackexchange.com/questions/60577/concatenate-multiple-files-with-same-header#170692 | |
# `head -1` gets first line of the file of the file and stashes them as the header row into `all.txt` | |
# `tail -n +2 -q *.csv >> all.txt` grabs every csv file from the second row down and stashes them into `all.txt` | |
# `all.txt` is a csv file but we use the txt extension to avoid it being captured in the `*.csv` glob. | |
# You could also output to a csv file by having your input files share a naming convention such as `file-001.csv` and glob on `file*.csv` | |
# But renaming `all.txt` to `all.csv` is sometimes easier than worrying about a naming convention and txt and csvs are the same thing | |
head -1 my-csv-01.csv > all.txt; tail -n +2 -q *.csv >> all.txt |