regular backup

This commit is contained in:
arielherself 2024-12-10 14:53:12 +08:00
parent c7eec5c7a9
commit b5945b86b0
Signed by: arielherself
SSH Key Fingerprint: SHA256:AK3cyo9tFsp7Mox7K0sYphleC8hReXhnRKxwuDT5LBc
5 changed files with 112 additions and 43 deletions

View File

@ -201,7 +201,7 @@ in {
pkgs.samba
# Java
pkgs.jdk22
pkgs.jdk23
pkgs.jdt-language-server
# Python
@ -236,6 +236,7 @@ in {
pkgs.jellyfin-ffmpeg
# pkgs.spotify
# unstable.spotify-player
pkgs.spotdl
# Streaming
# pkgs.obs-studio
@ -263,7 +264,7 @@ in {
# pkgs.pavucontrol # Volume control
# pkgs.pasystray # Volume tray icon
pkgs.yaru-theme
unstable.adwaita-icon-theme
# unstable.adwaita-icon-theme
pkgs.adwaita-qt
pkgs.adwaita-qt6
pkgs.wiki-tui
@ -271,6 +272,7 @@ in {
pkgs.starship # Prompt bar
pkgs.patchelf
# pkgs.screenkey
pkgs.ipatool # Search and download IPAs
# My version of BerkeleyMono NF is incomplete. Should add some fallback fonts.
# (pkgs.nerdfonts.override { fonts = [

View File

@ -139,19 +139,19 @@ local plugins = {
opts = {},
config = function(_, opts) require'lsp_signature'.setup(opts) end
},
-- {
-- "folke/which-key.nvim",
-- event = "VeryLazy",
-- init = function()
-- vim.o.timeout = true
-- vim.o.timeoutlen = 300
-- end,
-- opts = {
-- -- your configuration comes here
-- -- or leave it empty to use the default settings
-- -- refer to the configuration section below
-- }
-- },
{
"folke/which-key.nvim",
event = "VeryLazy",
init = function()
vim.o.timeout = true
vim.o.timeoutlen = 300
end,
opts = {
-- your configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
}
},
{
'jdhao/better-escape.vim' -- `jk` without causing `j` to have delay
},
@ -487,7 +487,10 @@ local plugins = {
require("fzf-lua").setup({})
end
},
{ 'NStefan002/screenkey.nvim' },
-- {
-- 'NStefan002/screenkey.nvim',
-- branch = "dev",
-- },
{ 'kosayoda/nvim-lightbulb' },
{ 'mfussenegger/nvim-jdtls' }, -- Java LS
}
@ -1184,7 +1187,7 @@ require("telescope").setup {
require('mini.trailspace').setup {}
require('lsp_lines').setup {}
require('lsp_lines').setup()
require("nvim-lightbulb").setup {
autocmd = { enabled = true }

View File

@ -1,50 +1,52 @@
return [[
static vector<MLL<MDL1>> power1;
static vector<MLL<MDL2>> power2;
static const ll b = rd();
static vector<ll> power1;
static vector<ll> power2;
static const ll b = rd() % INF;
static const ll b1 = inverse(b, MDL1);
static const ll b2 = inverse(b, MDL2);
template <typename _Tp>
struct hash_vec {
using hash_type = pll;
MLL<MDL1> hash1;
MLL<MDL2> hash2;
ll hash1;
ll hash2;
vector<_Tp> seq;
size_t size() {
return seq.size();
}
void push_back(const _Tp& x) {
hash1 = hash1 * b + x;
hash2 = hash2 * b + x;
hash1 = (hash1 * b % MDL1 + x) % MDL1;
hash2 = (hash2 * b % MDL2 + x) % MDL2;
seq.push_back(x);
}
void push_front(const _Tp& x) {
size_t length = size();
hash1 += x * power1[length];
hash2 += x * power2[length];
hash1 = (hash1 + x * power1[length] % MDL1) % MDL1;
hash2 = (hash2 + x * power2[length] % MDL2) % MDL2;
seq.push_front(x);
}
void pop_back() {
_Tp e = seq.back(); seq.pop_back();
hash1 = (hash1 - e) / b;
hash2 = (hash2 - e) / b;
hash1 = mod(hash1 - e, MDL1) * b1 % MDL1;
hash2 = mod(hash2 - e, MDL2) * b2 % MDL2;
}
void pop_front() {
_Tp e = seq.front(); seq.pop_front();
int length = seq.size();
hash1 -= e * power1[length];
hash2 -= e * power2[length];
hash1 = mod(hash1 - e * power1[length] % MDL1, MDL1);
hash2 = mod(hash2 - e * power2[length] % MDL2, MDL2);
}
void set(size_t pos, const _Tp& value) {
int length = seq.size();
int old_value = seq[pos];
hash1 += (value - old_value) * power1[length - 1 - pos];
hash2 += (value - old_value) * power2[length - 1 - pos];
hash1 = (hash1 + (value - old_value) * power1[length - 1 - pos] % MDL1) % MDL1;
hash2 = (hash2 + (value - old_value) * power2[length - 2 - pos] % MDL2) % MDL2;
seq[pos] = value;
}
const _Tp& operator[](size_t pos) {
return seq[pos];
}
hash_type hash() {
return {hash1.val, hash2.val};
return { hash1, hash2 };
}
void clear() {
hash1 = 0;
@ -53,13 +55,13 @@ struct hash_vec {
}
hash_vec(size_t maxn) {
clear();
MLL<MDL1> c1 = power1.size() ? power1.back() * b : 1;
MLL<MDL2> c2 = power2.size() ? power2.back() * b : 1;
ll c1 = power1.size() ? power1.back() * b % MDL1 : 1;
ll c2 = power2.size() ? power2.back() * b % MDL2 : 1;
for (int i = power1.size(); i < maxn; ++i) {
power1.push_back(c1);
power2.push_back(c2);
c1 *= b;
c2 *= b;
c1 = c1 * b % MDL1;
c2 = c2 * b % MDL2;
}
}
hash_vec(size_t maxn, const _Tp& init_value) : hash_vec(maxn) {
@ -68,9 +70,8 @@ struct hash_vec {
}
}
};
struct range_hash {
vector<pair<MLL<MDL1>, MLL<MDL2>>> hp;
vector<pll> hp;
template <typename T>
range_hash(const T& vec) {
hp.emplace_back();
@ -80,12 +81,11 @@ struct range_hash {
hp.emplace_back(hs.hash());
}
}
/// query hash of subarray [l, r]. Index starts from 0.
pair<MLL<MDL1>, MLL<MDL2>> range_query(size_t l, size_t r) {
inline pll range_query(size_t l, size_t r) {
return {
(hp[r + 1].first - hp[l].first * power1[r + 1 - l]),
(hp[r + 1].second - hp[l].second * power2[r + 1 - l]),
mod(hp[r + 1].first - hp[l].first * power1[r + 1 - l] % MDL1, MDL1),
mod(hp[r + 1].second - hp[l].second * power2[r + 1 - l] % MDL2, MDL2),
};
}
};

View File

@ -405,3 +405,15 @@ ls.add_snippets(nil, {
}
})
local odt = require('snippets.odt')
ls.add_snippets(nil, {
cpp = {
snip({
trig = 'odt',
namr = 'odt',
dscr = 'Old Driver Tre',
},{
text(lines(odt))
})
}
})

52
nvim/lua/snippets/odt.lua Normal file
View File

@ -0,0 +1,52 @@
return [=[
template <typename T, typename IndexType = ll>
struct ODT {
struct Info {
IndexType l, r;
mutable T val;
Info(const IndexType& l, const IndexType& r, const T& val) : l(l), r(r), val(val) {}
friend inline bool operator<(const Info& lhs, const Info& rhs) { return lhs.l < rhs.l; }
};
set<Info> info;
ODT() = delete;
ODT(const IndexType& left, const IndexType& right, const T& val) : info {{ left, right, val }} {}
typename set<Info>::iterator split(const IndexType& x) {
auto it = info.lower_bound({ x, {}, {} });
if (it != info.end() and it->l == x) {
return it;
}
--it;
auto [l, r, val] = *it;
info.erase(it);
info.emplace(l, x - 1, val);
return info.emplace(x, r, val).first;
}
void assign(const IndexType& l, const IndexType& r, const T& val) {
auto ri = split(r + 1), li = split(l);
info.erase(li, ri);
info.emplace(l, r, val);
}
void transform(const IndexType& l, const IndexType& r, const function<T(const Info&)>& operation) {
auto ri = split(r + 1), li = split(l);
for (; li != ri; ++li) {
li->val = operation(*li);
}
}
template <typename U>
U accumulate(const IndexType& l, const IndexType& r, U&& init, const function<U(const U&, const Info&)>& operation = std::plus()) {
auto ri = split(r + 1), li = split(l);
U res = init;
for (; li != ri; ++li) {
res = operation(res, *li);
}
return res;
}
};
]=]