- Backup data to Time machine drive
- Backup some important data to HDD drive manually
- Make a list which directory should be\ copied into the new OS
- Export vicosity config into a file
This file contains 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
import contextlib | |
import pytest | |
from unittest.mock import patch | |
class A(object): | |
def say(self, msg): | |
return f'A say {msg!r}.' | |
@contextlib.contextmanager |
This file contains 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
import contextlib | |
import cProfile | |
import datetime | |
import io | |
import pstats | |
import time | |
def log(msg): | |
cur_datetime_str = datetime.datetime.now().strftime('%Y-%m-%dT%H:%M:%S') |
This file contains 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
docker rmi $(docker images -q) |
This file contains 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 | |
docker rmi $(docker images -q) |
This file contains 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 setup_logging(): | |
import logging | |
import os | |
from logging.handlers import RotatingFileHandler | |
from logging import Formatter | |
handler = RotatingFileHandler('log/flask.log', maxBytes=10000, backupCount=1) | |
process_id = os.getpid() | |
handler.setFormatter(Formatter( | |
#'[%(asctime)s] [%(levelname)s]: %(message)s [in %(pathname)s:%(lineno)d]' # for debug | |
'[%(asctime)s #' + str(process_id) + '] [%(levelname)s]: %(message)s' |
This file contains 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
import os | |
os.urandom(24) |
This file contains 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
require 'msgpack' | |
require 'json' | |
def usage | |
puts <<EOT | |
usage: ruby msgpack_util.rb <option> <input-file-path> [<output-file-path>] | |
option: | |
-d, --decode: Decode msgpack formatted data into JSON formatted data | |
-e, --encode: Encode JSON formatted data into msgpack formatted data | |
EOT |
This file contains 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
CREATE USER r_only_user identified by 'password'; | |
GRANT SELECT, SHOW VIEW, PROCESS, REPLICATION CLIENT ON *.* TO 'r_only_user'@'%' IDENTIFIED BY 'password'; | |
GRANT SELECT, SHOW VIEW, PROCESS, REPLICATION CLIENT ON *.* TO 'r_only_user'@'localhost' IDENTIFIED BY 'password'; | |
FLUSH PRIVILEGES; |
This file contains 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
require 'pg' | |
require 'socket' | |
require 'pp' | |
TIMEOUT = 5 | |
IDLE_CONN_TIMEOUT_MINUTES = 30 # 30 minutes | |
#IDLE_CONN_TIMEOUT_MINUTES = 1 # 1 minute for testing | |
CURRENT_SESSIONS_QUERY = "select * from stv_sessions where user_name = '%{user}' and starttime < CURRENT_TIMESTAMP - INTERVAL '%{timeout} minutes' order by starttime;" | |
KILL_CONNECTION_QUERY = "select pg_terminate_backend(%{pid})" |
NewerOlder