Let say you have migrations like this
project/apps/accounts/migrations
├── 0001_initial.py
├── 0002_historicalprofile_historicaluser.py
├── 0003_auto_20190807_1559.py
├── 0004_auto_20190811_1013.py
Let say you have migrations like this
project/apps/accounts/migrations
├── 0001_initial.py
├── 0002_historicalprofile_historicaluser.py
├── 0003_auto_20190807_1559.py
├── 0004_auto_20190811_1013.py
Make sure all sensitive variables use one of the keywords:
API
KEY
PASS
SECRET
SIGNATURE
TOKEN
# when we running script in background using `&` after we logout, the script will be killed, | |
# to prevent the script being killed we can use `nohup` | |
$ nohup bash -c "time python myapp.py" > myapp.log 2>&1 & | |
# this command will run our script in background (even we logout from terminal session) | |
# and we can still watching the log from `myapp.log` | |
# e.g `tail -f myapp.log` |
Traffic Light* | |
Green* | |
timer -> Red | |
Red | |
timer -> Yellow | |
Walk | |
tick -> Stop | |
Stop | |
tick -> Yellow |
""" | |
This is simple snippet to insert multiple data / bulk create in django | |
""" | |
# take example, we have a list of dict data | |
datas = [{ | |
"name": "A", | |
"number: 1, | |
}, { | |
"name": "B", |
module.exports = { | |
up: (queryInterface, DataTypes) => { | |
return queryInterface.sequelize.query("ALTER TYPE enum_students_id_card_type ADD VALUE 'driving_license';"); | |
}, | |
down: (queryInterface, DataTypes) => { | |
// FIXME: Removing enum value is not supported by PostgreSQL, | |
// but there is any tricky way to do this. | |
// ref: https://stackoverflow.com/a/46244969, https://stackoverflow.com/a/25812436 | |
return queryInterface.sequelize.query("UPDATE students SET id_card_type = 'ktp' WHERE id_card_type = 'driving_license';") | |
.then(() => { |
#!/bin/bash | |
# | |
# Backup a Postgresql database into a daily file. | |
# | |
BACKUP_DIR=/pg_backup | |
DAYS_TO_KEEP=14 | |
FILE_SUFFIX=_pg_backup.sql | |
DATABASE= | |
USER=postgres |
## Download first your keybase-private.key and keybase-public.key | |
gpg --allow-secret-key-import --import keybase-private.key | |
gpg --import keybase-public.key | |
## check list gpg | |
gpg --list-secret-keys | |
## fix io error | |
export GPG_TTY=$(tty) |
❱ git config user.signingKey 38AF394C | |
❱ git config commit.gpgSign true | |
❱ echo "test" | gpg --clearsign | |
-----BEGIN PGP SIGNED MESSAGE----- | |
Hash: SHA256 | |
test | |
gpg: signing failed: Inappropriate ioctl for device | |
gpg: [stdin]: clear-sign failed: Inappropriate ioctl for device |
(0, 0, { values })
link to a new record that needs to be created with the given values dictionary
(1, ID, { values })
update the linked record with id = ID (write values on it)
(2, ID)
remove and delete the linked record with id = ID (calls unlink on ID, that will delete the object completely, and the link to it as well)
(3, ID)
cut the link to the linked record with id = ID (delete the relationship between the two objects but does not delete the target object itself)
(4, ID)
link to existing record with id = ID (adds a relationship)
(5)
unlink all (like using (3,ID) for all linked records)
(6, 0, [IDs])
replace the list of linked IDs (like using (5) then (4,ID) for each ID in the list of IDs)