mkdir /mnt/gentoo mount /dev/sdx? /mnt/gentoo mkdir /mnt/gentoo/home mount /dev/sdx? /mnt/gentoo/home mkdir /mnt/gentoo/boot mount /dev/sdx? /mnt/gentoo/boot mkdir /mnt/gentoo/boot/efi mount /dev/sdx? /mnt/gentoo/boot/efi
# These settings were set by the catalyst build script that automatically # built this stage. # Please consult /usr/share/portage/config/make.conf.example for a more # detailed example. # GCC编译配置 -O3代表优化级别,如果采用更高的-Ofast可能会导致部分软件包编译错误, # -march=native代表为本机cpu进行编译,如果是交叉编译需要去掉 COMMON_FLAGS="-march=skylake -O2 -pipe" CFLAGS="${COMMON_FLAGS}" CXXFLAGS="${COMMON_FLAGS}" FCFLAGS="${COMMON_FLAGS}" FFLAGS="${COMMON_FLAGS}"
Device Drivers ---> Generic Driver Options ---> [*] Maintain a devtmpfs filesystem to mount at /dev [*] Automount devtmpfs at /dev, after the kernel mounted the rootfs
SCSI磁盘支持。
1 2 3
Device Drivers ---> SCSI device support ---> <*> SCSI disk support
File systems ---> < > Second extended fs support < > The Extended 3 (ext3) filesystem <*> The Extended 4 (ext4) filesystem < > Reiserfs support < > JFS filesystem support < > XFS filesystem support < > Btrfs filesystem support DOS/FAT/NT Filesystems ---> <*> MSDOS fs support <*> VFAT (Windows-95) fs support Pseudo Filesystems ---> [*] /proc file system support [*] Tmpfs virtual memory file system support (former shm fs)
如果处理器是多核的,还需要开启SMP(对称多处理器支持)。
1 2
Processor type and features ---> [*] Symmetric multi-processing support
USB也必须启用
1 2 3 4 5 6 7 8 9 10 11
Device Drivers ---> HID support ---> -*- HID bus support <*> Generic HID driver [*] Battery level reporting for HID devices USB HID support ---> <*> USB HID transport layer [*] USB support ---> <*> xHCI HCD (USB 3.0) support <*> EHCI HCD (USB 2.0) support <*> OHCI HCD (USB 1.1) support
Processor type and features ---> [*] Machine Check / overheating reporting [*] Intel MCE Features [*] AMD MCE Features Processor family (AMD-Opteron/Athlon64) ---> ( ) Opteron/Athlon64/Hammer/K8 ( ) Intel P4 / older Netburst based Xeon ( ) Core 2/newer Xeon ( ) Intel Atom (*) Generic-x86-64 Binary Emulations ---> [*] IA32 Emulation
启用GPT支持,因为前面我用的GPT分区表,EFI启动方式,所以这两项也必须启用。
1 2 3 4
-*- Enable the block layer ---> Partition Types ---> [*] Advanced partition selection [*] EFI GUID Partition support
EFI的支持。
1 2 3 4 5 6 7 8
Processor type and features ---> [*] EFI runtime service support [*] EFI stub support [*] EFI mixed-mode support Firmware Drivers ---> EFI (Extensible Firmware Interface) Support ---> <*> EFI Variable Support via sysfs
1 2 3 4
# 编译内核 make -j12 #(CPU核心数根据机器cpu调整) make modules_install make install
[HttpPost("~/login")] public IActionResult Login(LoginViewModel model) { if (ModelState.IsValid) { var user = await _userManager.FindByNameAsync(model.Username); if (user == null) { ModelState.AddModelError("Username", "Username or password is incorrect."); } elseif (!await _userManager.IsEmailConfirmedAsync(user)) { ModelState.AddModelError("Email", "You must have a confirmed email to log in."); } elseif (!await _userManager.CheckPasswordAsync(user, model.Password)) { ModelState.AddModelError("Username", "Username or password is incorrect."); } else { // 创建一个新的身份验证票据. var ticket = await CreateTicketAsync(user);
[HttpGet("~/register")] public IActionResult Register() { return View(); }
[HttpPost("~/register")] publicasync Task<IActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.Email, Email = model.Email, FirstName = model.FirstName, LastName = model.LastName, };
var result = await _userManager.CreateAsync(user, model.Password); if (result.Succeeded) { var code = await _userManager.GenerateEmailConfirmationAsync(user); var callbackUrl= Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: HttpContext.Request.Scheme); await _emailSender.SendEmailAsync(model.Email, "Confirm your email", $"Please confirm your account by clicking this link: {callbackUrl}");
[HttpPost("~/api/token/refresh")] publicasync Task<IActionResult> Refresh([FromForm]string refreshToken) { var info = await HttpContext.AuthenticateAsync(OpenIddictServerDefaults.AuthenticationScheme);
if (info == null) { return BadRequest(new { error = OpenIddictConstants.Errors.InvalidRequest, error_description = "The refresh token is no longer valid." }); }
var principal = info.Principal;
var user = await _userManager.GetUserAsync(principal); if (user == null) { return BadRequest(new { error = OpenIddictConstants.Errors.InvalidRequest, error_description = "The refresh token is no longer valid." }); }
// 确保刷新令牌没有被撤销. if (!await _tokenManager.ValidateAsync( principal.GetId(), principal.GetClaim(OpenIddictConstants.Claims.JwtId))) { return BadRequest(new { error = OpenIddictConstants.Errors.InvalidRequest, error_description = "The refresh token is no longer valid." }); }
// 从数据库得到客户端应用程序详细信息 var application = await _applicationManager.FindByClientIdAsync( principal.GetClaim(OpenIddictConstants.Claims.ClientId)); if (application == null) { return BadRequest(new { error = OpenIddictConstants.Errors.InvalidRequest, error_description = "The client application associated with this token is no longer valid." }); }
var identity = await _userManager.CreateIdentityAsync(user, principal.GetScopes());
var ticket = await CreateTicketAsync(application, identity, principal);
var user = await _userManager.FindByIdAsync(model.UserId); if (user == null) { // 不要显示用户不存在 return View("ResetPasswordConfirmation"); }
var decodedCode = Encoding.UTF8.GetString(WebEncoders.Base64UrlDecode(model.Code)); var result = await _userManager.ResetPasswordAsync(user, decodedCode, model.Password); if (result.Succeeded) { return RedirectToAction(nameof(ResetPasswordConfirmation)); }
foreach (var error in result.Errors) { ModelState.AddModelError(string.Empty, error.Description); }
return View(model); }
[HttpGet("~/reset-password-confirmation")] [AllowAnonymous] public IActionResult ResetPasswordConfirmation() { return View(); }
// 从数据库检索客户机应用程序. var application = await context.HttpContext.GetOpenIddictServerApplicationAsync(); if (application == null) { thrownew InvalidOperationException("The client application cannot be retrieved."); }
// 从授权服务器设置检索用户主体. var principal = context.HttpContext.User;
// 确保允许应用程序使用指定的授权类型。 if (!await ValidateClientRedirectUriAsync(application, context.Request)) { thrownew InvalidOperationException("The grant type is not allowed for this application."); }
//注意:这个自定义令牌终端点总是忽略“scopes”参数,并根据授予的scopes/roles自动定义声明。 var ticket = new AuthenticationTicket(principal, new AuthenticationProperties(), OpenIddictServerDefaults.AuthenticationScheme); // 根据请求的自定义授权类型自定义令牌生命周期. if (string.Equals(context.Request.GrantType, "urn:custom_grant", StringComparison.OrdinalIgnoreCase)) { // Set the token expiration to 1 hour. ticket.Properties.ExpiresUtc = context.Options.SystemClock.UtcNow.AddHours(1); } else { // 将令牌过期时间设置为默认持续时间(5分钟) ticket.Properties.ExpiresUtc = context.Options.SystemClock.UtcNow.Add( context.Options.AccessTokenLifetime ?? TimeSpan.FromMinutes(5)); }
context.Logger.LogInformation("The custom token request was successfully processed.");
local colorscheme = "tokyonight" local status_ok, _ = pcall(vim.cmd, "colorscheme " .. colorscheme) if not status_ok then vim.notify("colorscheme " .. colorscheme .. " 没有找到!") return end
local status, bufferline = pcall(require, "bufferline") if not status thenreturn end
bufferline.setup({ options = { close_command = "Bdelete! %d", right_mouse_command = "Bdelete! %d", offsets = { { filetype = "NvimTree", text = "File Explorer", highlight = "Directory" } }, diagnostics = "nvim_lsp", diagnostics_indicator = function(count, level, diagnostics_dict, context) local s = " " for e, n in pairs(diagnostics_dict) do local sym = e == "error" and " " or (e == "warning" and " " or "") s = s .. n .. sym end return s end, }, })
local cmp_autopairs = require("nvim-autopairs.completion.cmp") local cmp = require("cmp") cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done())
9.7 comment.lua
lua/plugin-config/comment.lua:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
local status, comment = pcall(require, "Comment") if not status thenreturn end
local lspconfig = require("lspconfig") local protocol = require("vim.lsp.protocol") local protocol_callbacks = protocol.callbacks local method_is_available = vim.lsp.handlers["textDocument/hover"]
vim.lsp.handlers["textDocument/hover"] = function(_, result, method, ...) if vim.tbl_isempty(result or {}) then return method_is_available(_, result, method, ...) end return protocol_callbacks.hover(_, result, method, ...) end
local lsp_status_ok, cmp_config = pcall(require, "copilot_cmp.config") if not lsp_status_ok then local status_cmp, cmp = pcall(require, "cmp") if not status_cmp then return end
local status_cmp_lsp, cmp_lsp = pcall(require, "cmp_nvim_lsp") if not status_cmp_lsp then return end
local snip_status_ok, luasnip = pcall(require, "luasnip") if not snip_status_ok then return end
publicIdWorker(finallong workerId) { super(); if (workerId > this.maxWorkerId || workerId < 0) { thrownewIllegalArgumentException(String.format( "worker Id can't be greater than %d or less than 0", this.maxWorkerId)); } this.workerId = workerId; }
这个特性在SQL Server 2012、Oracle中可用。这个特性是数据库级别的,允许在多个表之间共享序列号。它可以解决分表在同一个数据库的情况,但倘若分表放在不同数据库,那将共享不到此序列号。(eg:Sequence使用场景:你需要在多个表之间公用一个流水号。以往的做法是额外建立一个表,然后存储流水号)