Skip to content

Instantly share code, notes, and snippets.

You probably want the activerecord-postgres_enum gem, because it adds some good stuff for your migrations and allows you to keep using the schema.rb (instead of switching to a schema.sql:

gem 'activerecord-postgres_enum'

Your migration would then look like this:

class AddCountryToCities < ActiveRecord::Migration[5.2]
import async from 'async'
export default class RetryQueue {
constructor (strategy, opts = {}) {
const options = Object.assign({
times: 14,
interval (retryCount) {
return 1000 * Math.pow(2, retryCount)
}
}, opts)
@danieldiekmeier
danieldiekmeier / DoublePunch.js
Created December 4, 2018 12:39
A basic version of Turbolinks + Stimulus, in blazing small 2kb
import mitt from 'mitt'
const routeCache = new Map()
const hotCache = new Map()
const instanceCache = new Map()
let latestRequest = null
let isShowingPreview = false
let prevRoute
const eventBus = mitt()
import fsExtra from 'fs-extra'
export default function jsonLog (filepath) {
return async function (data) {
await fsExtra.ensureFile(filepath)
await fsExtra.appendFile(filepath, JSON.stringify(data) + '\n')
}
}
.Element {
display none @ <320px; block @ >=320px
font-size 12px @ 320px; 20px @ 1280px
}
.Element {
display (
<320px: none
block
)
var vendor = Element.prototype.matches || Element.prototype.msMatchesSelector
function matches (el, selector) {
if (!el || el.nodeType !== 1) return false;
if (vendor) return vendor.call(el, selector);
return false;
}
function closest (element, selector) {
var parent = element
<ifModule mod_headers.c>
Header set Connection keep-alive
Header set Strict-Transport-Security "max-age=31536000;"
Header set Content-Security-Policy "script-src 'self'"
Header set X-Frame-Options "Deny"
Header set X-XSS-Protection "1; mode=block"
Header set X-Content-Type-Options "nosniff"
Header set Referrer-Policy ""
Header set Content-Security-Policy "default-src 'self';"
</ifModule>
# from https://www.reddit.com/r/dailyprogrammer/comments/6eerfk/20170531_challenge_317_intermediate_counting/
import re
challenges = """CCl2F2
NaHCO3
C4H8(OH)2
PbCl(NH3)2(COOH)2"""
stack = [{
'elements': {},
# from https://www.reddit.com/r/dailyprogrammer/comments/65vgkh/20170417_challenge_311_easy_jolly_jumper/
challenges = """4 1 4 2 3
5 1 4 2 -1 6
4 19 22 24 21
4 19 22 24 25
4 2 -1 0 2"""
def solve(challenge):