Skip to content

Instantly share code, notes, and snippets.

@porsager
porsager / housekeeping.sql
Last active November 8, 2021 14:55
Remove all but the latest n rows with group by
-- Simply set the offset to the amount of rows you want to keep. An index of (id, date desc) will make this fast.
delete from some_table st
using (
select distinct
x.id,
x.date
from some_table st1
join lateral (
@porsager
porsager / finished-polyfill.js
Last active May 17, 2020 21:26 — forked from simevidas/finished-polyfill.js
Animation.prototype.finished polyfill
// only polyfill .finished in browsers that already support animate()
if (document.body.animate) {
// Chrome does not seem to expose the Animation constructor globally
if (typeof Animation === 'undefined') {
window.Animation = document.body.animate({}).constructor;
}
if (!Animation.prototype.hasOwnProperty('finished')) {
Object.defineProperty(Animation.prototype, 'finished', {

Keybase proof

I hereby claim:

  • I am porsager on github.
  • I am porsager (https://keybase.io/porsager) on keybase.
  • I have a public key ASAIdAmlDJgUyiWx2gWW_kGj8lwRNWeP7OgVZPYuPWHqLwo

To claim this, I am signing this object:

const Pgp = require('pg-promise')
, config = require('./config')
const pgp = new Pgp(options)
, db = pgp(config.postgresUrl)
module.exports = function(x, ...args) {
if (!Array.isArray(x) || !Array.isArray(x.raw))
throw new Error('db queries must be done as template strings')
Verifying my Blockstack ID is secured with the address 1H3a2VBWFZ9tYGnBydFJPrtGYJb9D2JMNp https://explorer.blockstack.org/address/1H3a2VBWFZ9tYGnBydFJPrtGYJb9D2JMNp
create table countries (
country text not null unique,
country_code char(2) not null unique
);
create table country_areas (
country_area text not null,
country text not null references countries(country) on update cascade,
unique (country_area, country)
);
@porsager
porsager / README.md
Created March 26, 2019 20:15
Danish Members of the European Parliament contact info EU MEP

Danish Members of the European Parliament as of 26th of March 2019