class TestClass:
def __init__(self, a, b):
self.a = a
self.b = b
def __repr__(self):
return '{self.__class__.__name__}({self.a}, {self.b})'.format(self=self)
Tuesday, December 3, 2019
Sunday, December 1, 2019
Convert dictionary 'key' in list to lowercase (python3)
Using List Comprehension and Dictionary Comprehension
>>> rs = [{'ABC': '123', 'DEF': '456'}]
>>> ret = [{k.lower():v for k,v in i.items()} for i in rs]
>>> ret
>>> [{'abc': '123', 'def': '456'}]
Using Lambda Function
>>> rs = list(map((lambda i: { k.lower(): v for k,v in i.items()}), rs))
>>> rs = [{'ABC': '123', 'DEF': '456'}]
>>> ret = [{k.lower():v for k,v in i.items()} for i in rs]
>>> ret
>>> [{'abc': '123', 'def': '456'}]
Using Lambda Function
>>> rs = list(map((lambda i: { k.lower(): v for k,v in i.items()}), rs))
Friday, November 22, 2019
How to set TimeZone in Linux Docker Container
#How to set TimeZone in Linux Docker Container
```
apk add tzdata
```
ex:
Dockerfile
```
from python:3.7-alpine
RUN apk add tzdata
ENV TZ=Asia/Bangkok
CMD xxxx
```
#TimeZone in slim and Ubuntu Linux Docker Container
ex:
Dockerfile
```
from python
ENV TZ=Asia/Bangkok
CMD xxxx
```
ex:
Run Container (slim or full linux images)
```
docker run --name container-name -e 'TZ=Asia/Bangkok' python
```
```
apk add tzdata
```
ex:
Dockerfile
```
from python:3.7-alpine
RUN apk add tzdata
ENV TZ=Asia/Bangkok
CMD xxxx
```
#TimeZone in slim and Ubuntu Linux Docker Container
ex:
Dockerfile
```
from python
ENV TZ=Asia/Bangkok
CMD xxxx
```
ex:
Run Container (slim or full linux images)
```
docker run --name container-name -e 'TZ=Asia/Bangkok' python
```
Wednesday, November 20, 2019
SET TimeZone on Ubuntu19 with Command Line
:Find Current TimeZone
$ timedatectl list-timezones | grep -i [zone]
ex:
$ timedatectl list-timezones | grep -i europe
:Remove link
$ sudo unlink /etc/localtime
:Set new TimeZone
sudo ln -s /usr/share/zoneinfo/[Zone/TimeZone] /etc/localtime
ex:
sudo ln -s /usr/share/zoneinfo/Asia/Bangkok /etc/localtime
$ timedatectl list-timezones | grep -i [zone]
ex:
$ timedatectl list-timezones | grep -i europe
:Remove link
$ sudo unlink /etc/localtime
:Set new TimeZone
sudo ln -s /usr/share/zoneinfo/[Zone/TimeZone] /etc/localtime
ex:
sudo ln -s /usr/share/zoneinfo/Asia/Bangkok /etc/localtime
Monday, November 18, 2019
"tail -f" in Windows PowerShell
"tail -f" in Windows PowerShell
Get-Content .\file_name -wait | Where {$_ -match "search_name"}
Get-Content .\file_name -wait -tail 30 | Where {$_ -match "search_name"}
Get-Content .\file_name -wait | Where {$_ -match "search_name-1" -and $_ -match "search_name-2}
Get-Content .\file_name -wait | Where {$_ -match "search_name"}
Get-Content .\file_name -wait -tail 30 | Where {$_ -match "search_name"}
Get-Content .\file_name -wait | Where {$_ -match "search_name-1" -and $_ -match "search_name-2}
Friday, November 8, 2019
GGATE Error 'OCI Error ORA-01407: cannot update ("HRIS"."SYS_CLIENTIDENTIFIER"."SYS_USER_ID") to NULL (status = 1407)'
Transaction can't update table column to NULL
ex:
table name: "HRIS"."SYS_CLIENTIDENTIFIER"
column name: "SYS_USER_ID"
check constraint in "DBA_CONS_COLUMNS" or "ALL_CONS_COLUMNS"
SELECT
CONSTRAINT_NAME, TABLE_NAME, COLUMN_NAME
FROM
DBA_CONS_COLUMNS
WHERE
OWNER LIKE 'HRIS'
AND
TABLE_NAME LIKE 'SYS_CLIENTIDENTIFIER'
CONSTRAINT_NAME TABLE_NAME COLUMN_NAME
------------------------------ ------------------------------ --------------------
FK_SYS_CLIENTIDENTIFIER_USER SYS_CLIENTIDENTIFIER SYS_USER_ID <--------------
PK_SYS_CLIENTIDENTIFIER SYS_CLIENTIDENTIFIER ID
SYS_C0024107 SYS_CLIENTIDENTIFIER TERMINALIP
SYS_C0024106 SYS_CLIENTIDENTIFIER CREATEBY
SYS_C0024105 SYS_CLIENTIDENTIFIER CREATEDATETIME
SYS_C0024104 SYS_CLIENTIDENTIFIER GUID
SYS_C0024103 SYS_CLIENTIDENTIFIER ID
SYS_C00241XXX SYS_CLIENTIDENTIFIER SYS_USER_ID <--------------
DROP CONFLICT CONSTRAINT
ALTER TABLE "HRIS"."SYS_CLIENTIDENTIFIER" DROP CONSTRAINT SYS_C00241XXX;
and restart GGATE replicat
ex:
table name: "HRIS"."SYS_CLIENTIDENTIFIER"
column name: "SYS_USER_ID"
check constraint in "DBA_CONS_COLUMNS" or "ALL_CONS_COLUMNS"
SELECT
CONSTRAINT_NAME, TABLE_NAME, COLUMN_NAME
FROM
DBA_CONS_COLUMNS
WHERE
OWNER LIKE 'HRIS'
AND
TABLE_NAME LIKE 'SYS_CLIENTIDENTIFIER'
CONSTRAINT_NAME TABLE_NAME COLUMN_NAME
------------------------------ ------------------------------ --------------------
FK_SYS_CLIENTIDENTIFIER_USER SYS_CLIENTIDENTIFIER SYS_USER_ID <--------------
PK_SYS_CLIENTIDENTIFIER SYS_CLIENTIDENTIFIER ID
SYS_C0024107 SYS_CLIENTIDENTIFIER TERMINALIP
SYS_C0024106 SYS_CLIENTIDENTIFIER CREATEBY
SYS_C0024105 SYS_CLIENTIDENTIFIER CREATEDATETIME
SYS_C0024104 SYS_CLIENTIDENTIFIER GUID
SYS_C0024103 SYS_CLIENTIDENTIFIER ID
SYS_C00241XXX SYS_CLIENTIDENTIFIER SYS_USER_ID <--------------
DROP CONFLICT CONSTRAINT
ALTER TABLE "HRIS"."SYS_CLIENTIDENTIFIER" DROP CONSTRAINT SYS_C00241XXX;
and restart GGATE replicat
Thursday, October 31, 2019
Backup Docker container
Convert Container to Docker images:
docker commit container_name name/tag
Save docker images to files:
docker save name/tag > backupfile.tar
Import docker images from Files
docker load -i backupfile.tar
docker commit container_name name/tag
Save docker images to files:
docker save name/tag > backupfile.tar
Import docker images from Files
docker load -i backupfile.tar
Subscribe to:
Posts (Atom)
ALCATEL 6900
write memory copy running certified reload from working no rollback-timeout
-
SET LLDP System NAME: system name ALL-Uplink system location SIAM-FL11 SHOW LLDP Configure: show lldp config or show lldp local-syste...
-
grant execute on utl_http to wc grant execute on dbms_lock to wc; BEGIN DBMS_NETWORK_ACL_ADMIN.create_acl ( acl => ...
-
:system view system-view or sys :show all config dis current-configuration :create vlan vlan vlan_number :show ip interface ...