Skip to content

Instantly share code, notes, and snippets.

View dcron: setpgid: Operation not permitted.md

dcron: setpgid: Operation not permitted

a.sh:

#!/bin/sh -eu
docker run --rm -v $PWD/b.sh:/b.sh alpine ./b.sh

b.sh:

@x-yuri
x-yuri / Running dcron in a docker container.md
Last active Feb 11, 2021
#dcron #cron #docker #alpine
View Running dcron in a docker container.md

Running dcron in a docker container

a.sh:

#!/bin/sh -eu
docker run --rm -v $PWD/crontab:/etc/crontabs/root -v $PWD/output.sh:/output.sh alpine sh -euxc '
    apk add dcron
    chown root: /etc/crontabs/root
    crond -fM /output.sh
@x-yuri
x-yuri / rails: minitest, rake, pry-byebug.md
Last active Feb 9, 2021
#rails #ruby #minitest #rake #pry #pry-byebug
View rails: minitest, rake, pry-byebug.md

rails: minitest, rake, pry-byebug

  • for rake rails application is required from [Rakefile][a]
  • for rake [before][b] requiring [gems][c] rails sets [RAILS_ENV][d] (if not set yet)
  • the default rake task is [test][e]
  • TESTOPTS can be used to pass parameters to [minitest][h]
  • rails' test task inherits from [Rake::TestTask][i]
    • as such you can specify which files to run by means of the [TEST][j] environment [variable][k]
    • and could pass options to [minitest][l] via [TESTOPTS?/TEST_OPTS?][m], but rails [overrides][n] [define][o], so only TESTOPTS is available
  • [before][p1] running [tests][p2] rails runs [db:test:prepare][p3] -> [db:test:load][p4] -> [db:test:purge][p5] ([drop + create][p7]) -> [db:test:load_schema][p6]
View Gems from test, but not development group might be unavailable when running tests.md

Gems from test, but not development group might be unavailable when running tests

a.sh:

#!/bin/sh -eux
apk add build-base sqlite-dev nodejs tzdata
cat <<GEMFILE >Gemfile
source 'https://rubygems.org'
gem 'rails', '~> 4.0'
View Create a Rails site.md

Create a Rails site

Rails 4:

a.sh:

#!/bin/sh -eu
apk add build-base sqlite-dev nodejs tzdata
cat <<GEMFILE >Gemfile
@x-yuri
x-yuri / passport: local strategy with sessions.md
Created Feb 7, 2021
#passport #sessions #nodejs #express
View passport: local strategy with sessions.md

passport: local strategy with sessions

index.js:

const express = require('express');
const passport = require('passport');
const passportLocal = require('passport-local');
const bodyParser = require('body-parser');
const expressSession = require('express-session');
View Approaches to runing a Python site under Docker (development environment).md

Approaches to runing a Python site under Docker (development environment)

  1. The straightfoward way is:

    docker-compose.yml:

    version: '3'
    services:
        site:
@x-yuri
x-yuri / Migrating from has_and_belongs_to_many to has_many: through.md
Created Feb 5, 2021
#rails #active-record #has-and-belongs-to-many #habtm #has-many-through #migrations #db
View pip installation options.md

pip installation options

First, to put things simply there're installation base and installtion schemes. Installation base provides a reference point, while installation schemes regulate the resulting directory layout (where things are put relative to the installation base).

pip uses distutils for figuring all that out. The latter defines 3 installation schemes:

  • the [user scheme][a]
  • the [home scheme][b]
  • the [prefix scheme][c]