Skip to content

Instantly share code, notes, and snippets.

@godoway
godoway / GetDownloadDir.cs
Last active December 3, 2024 11:41
get window download dirctory example
using System.Runtime.InteropServices;
[DllImport("shell32.dll", CharSet = CharSet.Unicode)]
static extern int SHGetKnownFolderPath(ref Guid rfid, uint dwFlags, IntPtr hToken, out IntPtr ppszPath);
Guid downloadsFolder = new Guid("374DE290-123F-4565-9164-39C4925E467B");
int hr = SHGetKnownFolderPath(ref downloadsFolder, 0, IntPtr.Zero, out var pPath);
if (hr == 0) // S_OK
{

生成ca:

#!/bin/sh
IP=$(echo $1)
echo "[req]
default_bits  = 2048
distinguished_name = req_distinguished_name
x509_extensions = v3_req
prompt = no
@godoway
godoway / easing.js
Created April 24, 2024 11:39
Easing Function 笔记
const easingFuncs = {
linear: function (k) {
return k;
},
quadraticIn: function (k) {
return k * k;
},
quadraticOut: function (k) {
return k * (2 - k);
},
@godoway
godoway / note.sh
Created December 12, 2019 02:16
conEmu 笔记
set MSYS2_PATH_TYPE=inherit & set MSYSTEM=MINGW64 & %MSYS2_ROOT%\usr\bin\bash.exe --login -i -new_console:C:"%MSYS2_ROOT%\msys2.ico"
@godoway
godoway / task.kts
Created November 6, 2019 10:50
vertx codegen kts task
val annotationProcessing by tasks.creating(JavaCompile::class) {
source = sourceSets["main"].java
destinationDir = project.file("src/main/generated")
classpath = configurations.compileClasspath.get()
options.annotationProcessorPath = configurations.compileClasspath.get()
options.compilerArgs = listOf(
"-proc:only",
"-processor", "io.vertx.codegen.CodeGenProcessor",
"-Acodegen.output=${project.projectDir}/src/main"
)
@godoway
godoway / backward-guard.ts
Created July 12, 2019 00:44
prevent backward
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, CanDeactivate, RouterStateSnapshot, UrlTree } from '@angular/router';
import { Observable } from 'rxjs';
import { tap } from 'rxjs/operators';
export interface CanComponentDeactivate {
canDeactivate: () => Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree;
}
@Injectable({
@godoway
godoway / refuse-tieba-app.js
Last active September 26, 2019 09:47
显示手机百度贴吧的翻页按钮和楼层回复按钮
// ==UserScript==
// @name tieba page
// @namespace http://tampermonkey.net/
// @version 0.1
// @author gwsl
// @match https://tieba.baidu.com/*
// @grant unsafeWindow
// ==/UserScript==
function t(){
@godoway
godoway / ExternalResourcesConfig.java
Last active September 30, 2018 12:23
遍历 static locations 寻找资源,对不存在的资源则进行Angular的宿主页(index.html)的遍历。缺点:无法对不存在的请求返回404
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.web.ResourceProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.Resource;
import org.springframework.web.reactive.config.ResourceHandlerRegistry;
import org.springframework.web.reactive.config.WebFluxConfigurer;
import org.springframework.web.reactive.resource.PathResourceResolver;
import org.springframework.web.reactive.resource.ResourceResolverChain;
@godoway
godoway / SPAConfig_Angular.java
Last active September 21, 2018 09:23
解决angular在springboot中刷新导致404的问题,其根源在于需要将所有error page都重定向到angular的路由
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.web.ResourceProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.Resource;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.resource.PathResourceResolver;
import java.io.IOException;
import java.util.Arrays;
@godoway
godoway / SPAConfig.java
Last active May 6, 2018 05:50
the config of external static resources(single page application)
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration