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
from flask_sqlalchemy import Model, SQLAlchemy | |
from sqlalchemy import inspect | |
# Extend the base Model, for more details see: | |
# https://flask-sqlalchemy.palletsprojects.com/en/2.x/customizing/#model-class | |
class ExtendedModel(Model): | |
@classmethod | |
def required_fields(cls) -> list: | |
'''Returns column names for the Model where nullable=False''' | |
mapper = inspect(cls) |
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
# Setup | |
sudo apt update && sudo apt upgrade -y | |
sudo apt install software-properties-common -y | |
sudo add-apt-repository ppa:deadsnakes/ppa -y | |
# Python 3.10 | |
sudo apt install python3.10 | |
sudo apt install python3.10-dev | |
sudo apt install python3.10-distutils | |
sudo apt install python3.10-venv |
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
sudo apt update | |
sudo apt upgrade | |
# Install and start postgres server | |
sudo apt install postgresql | |
sudo service postgresql start | |
# Create new (super) user | |
sudo -u postgres createuser --interactive | |
# Create db for the new user | |
sudo -u postgres createdb <USER> | |
# Test |
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
psql <database> | |
\COPY <table> (<optional list of columns>,) FROM <relative path to .csv> WITH CSV HEADER; |
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
cd | |
sudo apt-get install ninja-build gettext cmake unzip curl | |
git clone https://github.com/neovim/neovim.git | |
cd neovim | |
git checkout v0.9.1 | |
make CMAKE_BUILD_TYPE=Release | |
sudo make install | |
sudo cp ./build/bin/* /usr/bin/ |
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
// Zig 0.12.0 | |
// Vulkan 1.3.280.0 | |
// Get the number of extensions | |
var extension_count: u32 = 0; | |
if (vk.vkEnumerateInstanceExtensionProperties(null, &extension_count, null) != vk.VK_SUCCESS) { | |
std.debug.panic("Failed to retrieve instance extension count.", .{}); | |
} | |
// Allocate array to hold enumerated extension properties |
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
// Zig 0.12.0 | |
// Vulkan 1.3.280.0 | |
// Get device count | |
var physical_device_count: u32 = 0; | |
if (vk.vkEnumeratePhysicalDevices(instance, &physical_device_count, null) != vk.VK_SUCCESS) { | |
std.debug.panic("Failed to get number of physical devices.", .{}); | |
} | |
// Populate physical devices array |
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
const std = @import("std"); | |
/// Try to get the last line of a text file. The returned line will be trimmed of any new line characters. | |
/// If the file is empty, or if the file only contains new lines, the returned slice will be empty. | |
pub fn getTail(allocator: std.mem.Allocator, file: *std.fs.File) ![]const u8 { | |
var result = std.ArrayList(u8).init(allocator); | |
const step_size: i64 = 4096; // Same as default BufferedReader | |
var read_buffer: [step_size]u8 = undefined; | |
var reader = file.reader(); |