From 7b4fe8e93c335610bbe09c657cfcdd64676f4818 Mon Sep 17 00:00:00 2001 From: arielherself Date: Mon, 2 Sep 2024 21:10:02 +0800 Subject: [PATCH] regular backup --- home-manager/home.nix | 25 ++++++++------- nixos/configuration.nix | 3 ++ nvim/lua/config.lua | 5 +++ nvim/lua/snippets/fft.lua | 51 ++++++++++++++++++++++++++++++ nvim/lua/snippets/init.lua | 26 ++++++++++++++++ nvim/lua/snippets/ntt.lua | 64 ++++++++++++++++++++++++++++++++++++++ xournalpp/settings.xml | 2 +- 7 files changed, 164 insertions(+), 12 deletions(-) create mode 100644 nvim/lua/snippets/fft.lua create mode 100644 nvim/lua/snippets/ntt.lua diff --git a/home-manager/home.nix b/home-manager/home.nix index 926d43c..e3b885f 100644 --- a/home-manager/home.nix +++ b/home-manager/home.nix @@ -7,8 +7,8 @@ let mypkgs = import (pkgs.fetchFromGitHub { owner = "arielherself"; repo = "mypkgs"; - rev = "75f9b72"; - hash = "sha256-vlfIPxOJ/wxlpLrOIUrxISzysFZ+kZ2nE/ELU2IaJqg="; + rev = "dc9d9be"; + hash = "sha256-+SdZ8H4qAcLG6baYb1WU/Sd1Dgh2eo/DHmi2Ig7NAnI="; }); in { nixpkgs.config.allowUnfree = true; @@ -132,9 +132,9 @@ in { pkgs.clang-tools pkgs.lua-language-server pkgs.cmake-language-server - pkgs.nil # Nix language server + pkgs.nil # Nix language server pkgs.nodePackages.typescript-language-server - pkgs.nodePackages.vls # Vue language server + pkgs.nodePackages.vls # Vue language server pkgs.nodePackages.prettier unstable.markdown-oxide pkgs.helix @@ -152,20 +152,19 @@ in { pkgs.autoconf pkgs.automake pkgs.btop - pkgs.fx + pkgs.fx # JSON pager pkgs.mtr pkgs.htop pkgs.gdb pkgs.dropbox pkgs.brightnessctl pkgs.psmisc - pkgs.xclip # Clipboard support + pkgs.xclip # Clipboard support pkgs.vulkan-tools - pkgs.lshw + pkgs.lshw # Hardware info unstable._1password unstable._1password-gui pkgs.nix-index - pkgs.dua pkgs.rclone # Pwn @@ -189,6 +188,7 @@ in { # Desktop management pkgs.xfce.thunar pkgs.baobab + pkgs.dua # CLI disk usage pkgs.i3lock pkgs.flameshot @@ -198,7 +198,7 @@ in { pkgs.sioyek # Multimedia - pkgs.kdePackages.gwenview + pkgs.kdePackages.gwenview # Image viewer pkgs.vlc pkgs.playerctl pkgs.ffmpeg @@ -212,6 +212,11 @@ in { pkgs.telegram-desktop pkgs.discord + # Browser + pkgs.firefox-devedition + pkgs.chromium + mypkgs.thorium + # Misc pkgs.fastfetch pkgs.onefetch @@ -228,8 +233,6 @@ in { unstable.adwaita-icon-theme pkgs.adwaita-qt pkgs.adwaita-qt6 - pkgs.firefox-devedition - mypkgs.thorium pkgs.wiki-tui pkgs.asciiquarium # Interesting pkgs.starship # Prompt bar diff --git a/nixos/configuration.nix b/nixos/configuration.nix index 348d506..36b0e74 100644 --- a/nixos/configuration.nix +++ b/nixos/configuration.nix @@ -167,6 +167,7 @@ in { "wheel" "wireshark" "vboxusers" + "networkmanager" ]; # Enable ‘sudo’ for the user. packages = with pkgs; [ home-manager @@ -218,6 +219,8 @@ in { programs.dconf.enable = true; + programs.nix-ld.enable = true; + # List services that you want to enable: # Enable the OpenSSH daemon. diff --git a/nvim/lua/config.lua b/nvim/lua/config.lua index c62dc68..947f70a 100644 --- a/nvim/lua/config.lua +++ b/nvim/lua/config.lua @@ -484,6 +484,7 @@ local plugins = { end }, { 'NStefan002/screenkey.nvim' }, + { 'kosayoda/nvim-lightbulb' }, } require("lazy").setup(plugins, {}) @@ -1175,3 +1176,7 @@ require("telescope").setup { require('mini.trailspace').setup {} require('lsp_lines').setup {} + +require("nvim-lightbulb").setup { + autocmd = { enabled = true } +} diff --git a/nvim/lua/snippets/fft.lua b/nvim/lua/snippets/fft.lua new file mode 100644 index 0000000..69fe7dd --- /dev/null +++ b/nvim/lua/snippets/fft.lua @@ -0,0 +1,51 @@ +return [=[ +void fft(vector>& y, bool idft) { + int n = y.size(); + vector rev(n); + for (int i = 0; i < n; ++i) { + rev[i] = rev[i >> 1] >> 1; + if (i & 1) { + rev[i] |= n >> 1; + } + } + for (int i = 0; i < n; ++i) { + if (i < rev[i]) { + swap(y[i], y[rev[i]]); + } + } + for (int h = 2; h <= n; h <<= 1) { + complex wn(cos(2 * M_PI / h), sin(2 * M_PI / h)); + for (int j = 0; j < n; j += h) { + complex w(1); + for (int k = j; k < j + h / 2; ++k) { + complex u = y[k], t = w * y[k + h / 2]; + y[k] = u + t; + y[k + h / 2] = u - t; + w *= wn; + } + } + } + if (idft) { + reverse(y.begin() + 1, y.end()); + for (int i = 0; i < n; ++i) { + y[i] /= n; + } + } +} + +vector multiply(const vector& a, const vector& b) { + vector> A(a.begin(), a.end()), B(b.begin(), b.end()); + int n = 1; + while (n < a.size() + b.size()) n <<= 1; + A.resize(n), B.resize(n); + fft(A, false), fft(B, false); + for (int i = 0; i < n; ++i) { + A[i] *= B[i]; + } + fft(A, true); + vector res(n); + transform(A.begin(), A.end(), res.begin(), expr(int(round(x.real())), auto&& x)); + return res; +} + +]=] diff --git a/nvim/lua/snippets/init.lua b/nvim/lua/snippets/init.lua index bfd6f4f..c75e6fa 100644 --- a/nvim/lua/snippets/init.lua +++ b/nvim/lua/snippets/init.lua @@ -300,3 +300,29 @@ ls.add_snippets(nil, { }) } }) + +local fft = require('snippets.fft') +ls.add_snippets(nil, { + cpp = { + snip({ + trig = 'fft', + namr = 'fft', + dscr = 'FFT', + },{ + text(lines(fft)) + }) + } +}) + +local ntt = require('snippets.ntt') +ls.add_snippets(nil, { + cpp = { + snip({ + trig = 'ntt', + namr = 'ntt', + dscr = 'NTT', + },{ + text(lines(ntt)) + }) + } +}) diff --git a/nvim/lua/snippets/ntt.lua b/nvim/lua/snippets/ntt.lua new file mode 100644 index 0000000..c66cccf --- /dev/null +++ b/nvim/lua/snippets/ntt.lua @@ -0,0 +1,64 @@ +return [=[ +template +void ntt(vector>& y, bool idft) { + using mll = MLL; + + int n = y.size(); + vector rev(n); + for (int i = 0; i < n; ++i) { + rev[i] = rev[i >> 1] >> 1; + if (i & 1) { + rev[i] |= n >> 1; + } + } + for (int i = 0; i < n; ++i) { + if (i < rev[i]) { + swap(y[i], y[rev[i]]); + } + } + vector roots = { 0, 1 }; + if (roots.size() < n) { + int k = lsp(roots.size()); + roots.resize(n); + for (; (1 << k) < n; ++k) { + mll e = qpow(31, 1 << lsp(M - 1) - k - 1); + for (int i = 1 << k - 1; i < (1 << k); ++i) { + roots[2 * i] = roots[i]; + roots[2 * i + 1] = roots[i] * e; + } + } + } + for (int h = 2; h <= n; h <<= 1) { + for (int j = 0; j < n; j += h) { + for (int k = j; k < j + h / 2; ++k) { + mll u = y[k], t = roots[k - j + h / 2] * y[k + h / 2]; + y[k] = u + t; + y[k + h / 2] = u - t; + } + } + } + if (idft) { + reverse(y.begin() + 1, y.end()); + for (int i = 0; i < n; ++i) { + y[i] /= n; + } + } +} + +template +vector> multiply(const vector>& a, const vector>& b) { + using mll = MLL; + + vector A(a.begin(), a.end()), B(b.begin(), b.end()); + int n = 1; + while (n < a.size() + b.size()) n <<= 1; + A.resize(n), B.resize(n); + ntt(A, false), ntt(B, false); + for (int i = 0; i < n; ++i) { + A[i] *= B[i]; + } + ntt(A, true); + return A; +} + +]=] diff --git a/xournalpp/settings.xml b/xournalpp/settings.xml index b95f415..0359c05 100644 --- a/xournalpp/settings.xml +++ b/xournalpp/settings.xml @@ -59,7 +59,7 @@ - +