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
/** | |
* @param {UUID} sourceId An ID to find. | |
* | |
* @returns {Object} an single object instance of Sequelize Model. | |
*/ | |
async function getMyTableData(sourceId) { | |
const sequelize = await this.hub.api('DbConnector', 'Sequelize'); | |
const mytable = await sequelize | |
.query(`SELECT * | |
FROM "my_table_name" |
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 |