Skip to content

Instantly share code, notes, and snippets.

  • vertical scroll bar的行为,选Use bar mode
  • preview features,不要开Use new dark theme
  • font,调[All Text Tool Windows]
  • nuget package manager,格式选PackageReference,不清楚现在是不是默认值
  • debugging,勾上Automatically close the console when debugging stops
@imba-tjd
imba-tjd / youdao.py
Last active February 9, 2022 04:16
有道翻译2
'''fanyi.youdao.com 请求库。支持版本1和2,尽量精简,保留USER_ID且不伪装UA,自动获取新saltkey。不考虑网络异常'''
import urllib3
import time
import hashlib
import json
import logging
logger = logging.Logger(__name__)
logger.addHandler(logging.NullHandler())
__all__ = ['fanyi_v2', 'fanyi_v1']
@imba-tjd
imba-tjd / Entries.md
Last active October 23, 2022 11:33
那些被错误使用的词语

起因

用错词语其实是很普遍的事,但是有的人一直不愿意改成正确的,甚至还引以为傲?

一些我能接受的不改的理由:

  • 语言是会慢慢演变的,用的人多了就变成正确的用法了,比如“空穴来风”
  • 语言是用于交流的工具,双方能理解就足够了

我虽然也同意这几点,但是总是觉得不爽。

@imba-tjd
imba-tjd / Update-Golang.psm1
Last active December 3, 2022 06:11
Update Node.js and Golang for Windows
function Get-GolangVer {
$ProgressPreference = 'SilentlyContinue'
$info = iwr 'https://golang.google.cn/dl/'
if (-not $?) { return }
$info -match '"toggleVisible" id="go(.+?)">' | Out-Null
$ver = $Matches[1]
$ProgressPreference = 'Continue'
return $ver
}
@imba-tjd
imba-tjd / cmdw.cs
Last active December 3, 2022 06:11
我也忘记这代码是做什么的了
using System.Diagnostics;
class CMDW {
static void Main(string[] args) {
Process.Start(new ProcessStartInfo("cmd") {
Arguments = string.Join(" ", args),
UseShellExecute = false,
CreateNoWindow = true
}).WaitForExit();
}
}
@imba-tjd
imba-tjd / check.c
Created January 11, 2023 10:45
SQLite Device Characteristics Check
/* SQLite Device Characteristics Check
Goal:
Tell you whether -DSQLITE_ENABLE_ATOMIC_WRITE has benefits on your filesystem.
However I don't konw much about sqlite so the logic may not be right.
Usage:
Download sqlite3 source code.
gcc check.c sqlite3.c -DSQLITE_THREADSAFE=0 -DSQLITE_ENABLE_ATOMIC_WRITE -DSQLITE_OMIT_LOAD_EXTENSION
// KP Backuper:帮助解决卡琳典狱长在非最低难度下强制覆盖自动保存的特性。
// 放到与nw.exe同一目录下。运行后每隔一分钟会检测存档有没有发生变化,如果变了,就备份到www/save_bak目录下。
// 并发安全性:读取时会加读锁,因此不会读到一半游戏自动保存导致读取内容错误,副作用是此次游戏的自动保存会不生效(静默失败);但本游戏保存很频繁,因此无影响。对于游戏保存到一半时本程序触发读,本程序会过一秒钟重试。
// 编译:C:\tools\bflat-7.0.1-windows-x64\bflat.exe build KPBackuper.cs -Os --no-globalization --no-reflection --no-stacktrace-data && upx --lzma KPBackuper.exe
using System;
using System.IO;
using System.Threading;
using System.Runtime.InteropServices;
[DllImport("user32")]
@imba-tjd
imba-tjd / realpath.go
Last active February 2, 2023 03:21
realpath.exe for windows
// Git for Windows or git-bash contains a realpath.exe which is required by git code.editor
// However I'm using Git distribution from VS, which doesn't have it.
// Copying from Git for Windows isn't a good choice because it needs msys-2.0.dll
// This program offers similar function, which is enough for me.
// It won't resolve '~'. It works when path contains whitespaces.
package main
import (
"fmt"
@imba-tjd
imba-tjd / Readme.md
Last active February 14, 2023 01:50
Call UWP / WinRT API from Win32 without installing Windows SDK
@imba-tjd
imba-tjd / ngenize.cs
Last active February 22, 2023 12:31
A wrapper for ngen.exe
// LICENSE: MIT
using System;
using System.IO;
using System.Diagnostics;
using System.Reflection;
class Ngenize
{
const string NgenX86Path = @"C:\Windows\Microsoft.NET\Framework\v4.0.30319\ngen.exe";
const string NgenX64Path = @"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\ngen.exe";