Skip to content

Instantly share code, notes, and snippets.

SELECT * FROM sys.time_zone_info; -- list available timezones
SELECT
-- CONVERT to VARCHAR because Ignition JDBC can't use datetimeoffset type
CONVERT(VARCHAR, GETDATE() AT TIME ZONE 'Mountain Standard Time') as local_mnt, -- server timezone is Mountain, server stores datetime in this timezone
CONVERT(VARCHAR, SWITCHOFFSET(GETDATE() AT TIME ZONE 'Mountain Standard Time', -420)) as local_mnt2,
CONVERT(VARCHAR, GETDATE() AT TIME ZONE 'Mountain Standard Time' AT TIME ZONE 'Eastern Standard Time') as est, -- convert to Eastern
CONVERT(VARCHAR, SWITCHOFFSET(GETDATE() AT TIME ZONE 'Mountain Standard Time', -300)) as est_2, -- convert to Eastern except using Eastern's timezone offset in minutes
CONVERT(VARCHAR, SWITCHOFFSET(TODATETIMEOFFSET(GETDATE(), -420), -300)) as est_3, -- convert using offset in minutes for local Mountain time and Eastern time
DATEDIFF_BIG(MILLISECOND, '1970-01-01', GETDATE() AT TIME ZONE 'Mountain Standard Time') as unix_timestamp;
@nikolai-wolterstorff
nikolai-wolterstorff / MySQL_standalone.txt
Last active March 29, 2021 15:35
MySQL Windows Service Won't Start
# https://stackoverflow.com/questions/35670755/the-mysql-service-on-local-computer-started-and-then-stopped
# Will output error to console
bin\mysqld --defaults-file="C:\Program Files\MySQL\MySQL Server 5.0\my.ini" --standalone --console
@nikolai-wolterstorff
nikolai-wolterstorff / MySQL8_skipGtidSlaveTransac.sql
Created February 4, 2021 20:47
MySQL 8 Skip Slave Transaction (GTID)
-- https://www.abhinavbit.com/2019/05/gtid-replication-skip-transaction-using.html
-- In command line interface (bin/mysql):
show slave status \G;
-- In Workbench:
show slave status;
-- Find the Master_UUID column and note the value
-- example: 11387751-34f3-11e4-a177-005056881ef0
-- Find the Executed_Gtid_Set column and find the Master_UUID set
-- example: Executed_Gtid_Set: 11387751-34f3-11e4-a177-005056881ef0:1233-86906
@nikolai-wolterstorff
nikolai-wolterstorff / MySQL8_logs.sql
Last active February 4, 2021 20:50
MySQL 8 Log Notes
---- General Log (All Queries Executed) ----
-- show variables like '%general%'; -- returns variables "general_log" and "general_log_file"
-- show variables like '%log_output%'; -- shows if "log_output" is going to FILE, TABLE or both
-- SET GLOBAL general_log = 1; -- enable general log
-- SET GLOBAL general_log = 0; -- disable general log
-- SET GLOBAL log_output = 'TABLE'; -- sets general log to table mysql.general_log
-- SET GLOBAL log_output = 'FILE'; -- sets general log to file specified by "general_log_file"
-- select general logs, and display argument as text (stored as blob)
SELECT
@nikolai-wolterstorff
nikolai-wolterstorff / MySQL8_events.sql
Last active February 4, 2021 20:50
MySQL 8 Events Notes
SHOW events; -- show events on current schema (https://stackoverflow.com/questions/9057525/how-do-i-see-all-mysql-events-that-are-running-on-my-database)
-- SHOW CREATE EVENT event_name; -- This statement displays the CREATE EVENT statement needed to re-create a given event
-- DROP EVENT event_name; -- Drop (delete) the target event
---- EXAMPLE EVENT CREATION ---- https://stackoverflow.com/questions/9343001/is-my-mysql-general-log-table-getting-too-big
delimiter | -- needed for multiple statements after DO BEGIN
CREATE EVENT `prune_general_log` ON SCHEDULE
EVERY 1 DAY STARTS '2021-02-05 08:00:00'
ON COMPLETION PRESERVE -- preserve event after expiration
@nikolai-wolterstorff
nikolai-wolterstorff / python3_venv.sh
Created January 29, 2021 03:56
Typical install of a Python 3 venv Virtual Enviroment
sudo apt-get install python3-venv # install venv for system Python
python3 -m venv <venv_name> # create venv directory at <venv_name>
. <venv_name>/bin/activate # activate the enviroment
# or (if not in bash and in terminal):
# source <venv_name>/bin/activate
pip install --upgrade pip
@nikolai-wolterstorff
nikolai-wolterstorff / compile_run_cpp.txt
Last active March 29, 2021 15:36
Compile and run C++
Compile:
- $ g++ <file.cpp> -o <binary_file>
- Ex: $ g++ hello_world.cpp -o hello_world
- Ex Windows: >C:\MinGW\bin\g++ hello_world.cpp -o hello_world.exe
- OpenCV included: $ g++ <file.cpp> -o <binary_file> `pkg-config --cflags --libs opencv`
Run:
- $ ./<binary_file>