滚熊博客

滚熊博客

Thoughts, rants and discoveries on software development and related stuff.

如何升级Golang依赖项

·Golang

无论您是否使用Go modules,通过使用go get 命令升级Go 依赖项都是一项基本的工作。 下面是几个如何升级Go modules的示例。 如何将依赖项升级到最新版本 该命令最终将更新您的go.mod和go.sum文件 go get example.com/pkg 如何将依赖项及其所有依赖项升级到最新版本 类似地,如果需要将单个依赖项及其所有子依赖项升级到最新版本 go get -u example.com/pkg 如何查看可用的依赖项升级 查看所有直接和间接依赖项的可用次要升级和修补程序升级 go list -u

Read More →
#golang

FIX - gpg failed to sign the data fatal: failed to write commit object

·Macos

For MacOS | Mojave | High Sierra | BigSur | Monterey Step 1 - Upgrade current gpg brew upgrade gnupg Step 2 - Install pinentry-mac brew install pinentry-mac Step 3 - Update gpg-agent.conf echo "pinentry-program /usr/local/bin/pinentry-mac" >> ~/.gnupg/gpg-agent.conf Step 4 - Restart gpg-agent killall gpg-agent && gpg-agent --daemon Step 5 - Configure git to use GPG git config --global gpg.program gpg git config --global commit.gpgsign true

Read More →
#linux#gpg

golang中var、make、new的使用[转]

·Golang

一、var、make、new、:=的使用习惯: 1.使用make(),来初始化slice,map 和channel 。 2.大多数场合,类型明确的场合下,使用短变量声明方式:=。 3.当使用文字方式初始化一个变量,并且需要指明类型时,使用var变量声明方式。 4.避免使用new(),除非你需要一个指针变量。 注意点: make 返回值是: 引用类型本身。 new 返回值: 指向类型的指针。 二、详细对比: new 定义: func new(Type) *Type 特点: 分配内存、

Read More →
#golang#学习笔记

Uninstall nix on MacOS

·Linux

要在 Mac OS 上卸载 nix,请完成以下步骤:: Step 1: 编辑 /etc/zshrc 和/etc/bashrc 并删除以下行 sourcing nix-daemon.sh #Nix if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then . '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' fi # End Nix 如果 zshrc 和 bashrc 这两个文件在安装 Nix 后没有改变,你可以简单地将它们作为备份。 最新的安装程序还会运行初步检查以进行验证。 sudo mv /etc/zshrc.backup-before-nix /etc/zshrc sudo mv etc/bashrc.backup-before-nix /etc/bashrc Step 2: 使用 sudo vifs 编辑 fstab 以删除在 /nix 上安装 Nix 存储卷的行,如下所示,LABEL=Nix\040stORE /nix apfs rw,nobrowse。 这将防止自动挂载 Nix 存储卷 Step 3: 编辑 /etc/synthetic.conf 以

Read More →
#macos#nginx#uninstall

How to look at the stack with gdb

·Linux

I was chatting with someone yesterday and they mentioned that they don’t really understand exactly how the stack works or how to look at it. So here’s a quick walkthrough of how you can use gdb to look at the stack of a C program. I think this would be similar for a Rust program, but I’m going to use C because I find it a little simpler for a toy example and also you can do Terrible Things in C more easily. our test program Here’s a simple C program that declares a few variables and reads two strings from standard input. One of the strings is on the heap, and one is on the stack. #include <stdio.h> #include <stdlib.h> int main() { char stack_string[10] = "stack"; int x = 10; char *heap_string; heap_string = malloc(50); printf("Enter a string for the stack: "); gets(stack_string); printf("Enter a string for the heap: "); gets(heap_string); printf("Stack string is: %s\n", stack_string); printf("Heap string is: %s\n", heap_string); printf("x is: %d\n", x); } This program uses the extremely unsafe function gets which you should never use, but that’s on purpose – we learn more when things go wrong. step 0: compile the program. We can compile it with gcc -g -O0 test.

Read More →
#gdb#stack

Building cgit on macOS

·Linux

Checkout and init the submodule. git clone git://git.zx2c4.com/cgit cd cgit git submodule init git submodule update Install gettext through brew. brew install gettext Then create a cgit.conf file and set complier/linker flags to use the gettext library installed before. CFLAGS = -g -O2 -Wall -I/usr/local/opt/gettext/include LDFLAGS = -L/usr/local/opt/gettext/lib Finish up with a simple make command. make

Read More →
#cgit#macos

Vim Cheat Sheet

·Linux

A Great Vim Cheat Sheet Essentials Cursor movement (Normal/Visual Mode) h j k l - Arrow keys w / b - Next/previous word W / B - Next/previous word (space seperated) e / ge - Next/previous end of word 0 / $ - Start/End of line ^ - First non-blank character of line (same as 0w) Editing text i / a - Start insert mode at/after cursor I / A - Start insert mode at the beginning/end of the line o / O - Add blank line below/above current line Esc or Ctrl+[ - Exit insert mode d - Delete dd - Delete line c - Delete, then start insert mode cc - Delete line, then start insert mode Operators Operators also work in Visual Mode d - Deletes from the cursor to the movement location c - Deletes from the cursor to the movement location, then starts insert mode y - Copy from the cursor to the movement location > - Indent one level < - Unindent one level You can also combine operators with motions. Ex: d$ deletes from the cursor to the end of the line. Marking text (visual mode) v - Start visual mode V - Start linewise visual mode Ctrl+v - Start visual block mode Esc or Ctrl+[ - Exit visual mode Clipboard yy - Yank (copy) a line p - Paste after cursor P - Paste before cursor dd - Delete (cut) a line x - Delete (cut) current character X - Delete (cut) previous character d / c - By default, these copy the deleted text Exiting :w - Write (save) the file, but don’t quit :wq - Write (save) and quit :q - Quit (fails if anything has changed) :q!

Read More →
#vim

去掉doc88,360doc,csdn和sfgg的登陆后复制限制

·Linux

各大站都搞这个登陆复制,真的恶心, 尤其是csdn,各种和谐, 虽然有命令,但是每次敲都贼麻烦, 来个油猴脚本吧~~ /* eslint-disable no-undef */ /* eslint-disable no-eval */ // ==UserScript== // @name 去掉doc88,360doc,csdn和segmentfault的登陆后复制限制 // @author ALEX.XU // @version 1.0.0 // @match *://*/* // @require https://cdn.bootcdn.net/ajax/libs/jquery/1.9.1/jquery.min.js // @run-at document-start // @grant unsafeWindow // ==/UserScript== (function() { 'use strict'; $(function(){ if (/www.doc88.com/.test(location.href) || /www.360doc.com/.test(location.href)){ function oncopy() { return true; } setInterval(function(){ try{ unsafeWindow.logined = 1 unsafeWindow.u_v = 1 document.body.oncopy = oncopy //360doc }catch(e){ console.log(e)} }, 1000) }else if(/blog.csdn.net/.test(location.host)){ console.log(mdcp, hljs); if (typeof(mdcp)!="undefined" && 'copyCode' in mdcp){ // $("code").attr("onclick","mdcp.copyCode(event)") // 直接来个狠的 document.body.contentEditable = true; }else if (typeof(hljs)!="undefined" && 'copyCode' in hljs){ $("*").one("mousemove", function(){ $(".hljs-button").attr("onclick","hljs.copyCode(event)") }) } } else if(/segmentfault.com/.test(location.host)){ $("<div></div>").attr("id","SFUserId").appendTo("body") } }) }())

Read More →
#csdn

win10 笔记本 同时接入无线(外网)和有线(内网)

·Linux

连接内网和无线网络 内网和外网都不要禁止,win10系统,以管理员身份运行CMD,在CMD中输入route print IPv4 路由表 上面一行是外网,下面一行是内网。 内网的跃点数高,要手动修改外网的跃点数,打开无线网(外网)IP4属性框中的高级,接口跃点数设置为1。 进入cmd通过route命令来重新设置网络 执行:route delete 0.0.0.0 (删除对所有ip的默认路由设置) 执行:route add 0.0.0.0 mask 0.0.0.0 192.168.0.1(将所有ip路

Read More →
#linux#windows

网络字体包压缩优化方案

·Linux

本文将介绍如何缩小网络字体包大小及优化其加载过程。 优化思路 将字体包转换为 woff2 格式。它具有更小的体积,对现代浏览器非常友好,且无需再 gzip 压缩。 使字体包中仅保留英文、数字、常用字符和常用汉字。 使用非堵塞方式加载字体包。 QA 1、TTF 如何转换为 WOFF2? 使用fonttools转换格式。它是一个依赖于 python 的工具。(若转换时候报错,需要根据提示安装对应依赖的库。) (1)安装: pip install fonttools (2)转换例子: pyftsubset example.ttf --layout-features="" --unicodes=U+0020-007E,U+4E00-9FA5 --flavor=woff2 --output-file=example.woff2 注意

Read More →
#字体包#压缩优化方案