#393939 #747369 #515151 #a09f93 #2d2d2d #d3d0c8 #74736930 #cc99cc #f2777a #6699cc
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 monthLengths = { | |
// '2020-03': 31, | |
// '2020-02': 29, | |
// '2020-01': 31, | |
// '2019-12': 31, | |
// '2019-11': 30, | |
// '2019-10': 31, | |
// '2019-09': 30, | |
// '2019-08': 31, |
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
# Put this function to your .bashrc file. | |
# Usage: mv oldfilename | |
# If you call mv without the second parameter it will prompt you to edit the filename on command line. | |
# Original mv is called when it's called with more than one argument. | |
# It's useful when you want to change just a few letters in a long name. | |
function mv() { | |
if [ "$#" -ne 1 ]; then | |
command mv "$@" | |
return |
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 here: https://stackoverflow.com/questions/4413590/javascript-get-array-of-dates-between-2-dates | |
module.exports = function genDateRange(start, end, format) { | |
let arr; | |
let dt; | |
for (arr = [], dt = new Date(start); dt <= end; dt.setDate(dt.getDate() + 1)) { | |
arr.push(new Date(dt)); | |
} | |
if (format === 'strings') { | |
return arr.map(v => v.toISOString().slice(0, 10)); | |
} |
-
Low-level is tedious and not explained in online examples
-
High-level is complex
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
<script> | |
import { LayerCake, Svg, calcExtents, flatten } from 'layercake'; | |
import { tweened } from 'svelte/motion'; | |
import * as eases from 'svelte/easing'; | |
import Line from '../../components/Line.svelte'; | |
export let data; | |
export let shared; | |
const y = tweened(undefined, { |
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
--useful for seeing if a css class exists across all instances of scraped pages in a pgsql database | |
--adapted from here https://stackoverflow.com/questions/36376410/counting-the-number-of-occurrences-of-a-substring-within-a-string-in-postgresql | |
select sum(array_length(string_to_array(html, 'SELECTOR'), 1) - 1) from TABLE_NAME | |
--should equal rows in the table | |
--or this to get occurrences per row | |
select (array_length(string_to_array(html, 'SELECTOR'), 1) - 1) as ct from TABLE_NAME ORDER BY ct DESC |
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 sleep = ms => new Promise(f => setTimeout(f, ms)); | |
async function do_things() { | |
for (const thing of things) { | |
await Promise.all([ | |
doThing(thing), | |
sleep(200) | |
}); | |
} | |
} |
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
`npm install --python=python2.7` and `npm config set python python2.7` |
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
pkgs <- c("packages") | |
check <- sapply(pkgs, require, warn.conflicts = TRUE, character.only = TRUE) | |
if(any(!check)) { | |
pkgs.missing <- pkgs[!check] | |
install.packages(pkgs.missing) | |
check <- sapply(pkgs.missing, require, warn.conflicts = TRUE, character.only = TRUE) | |
} | |
rm(pkgs, check) |