(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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Traffic Light* | |
Green* | |
timer -> Red | |
Red | |
timer -> Yellow | |
Walk | |
tick -> Stop | |
Stop | |
tick -> Yellow |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(() => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
❱ 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For my issue. adding alias is solved | |
$ docker inspect YOUR-CONTAINER | |
get the IP and add to alias | |
$ sudo ifconfig lo0 alias IP | |
$ sudo ifconfig lo0 alias 172.17.0.1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- encoding: utf-8 -*- | |
"""Install, Uninstall, Upgrade a module""" | |
import xmlrpclib | |
import argparse | |
import getpass | |
import time | |
parser = argparse.ArgumentParser() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_selection_name(models, fields, value): | |
""" Get text value of Selection fields | |
:param models: models of fields | |
:param fields: fields name to get | |
:param value: fields value | |
:return text: Text value of the fields or '' | |
""" | |
res = dict(models.fields_get(allfields=[fields])[fields]['selection'])[value] if value else '' |