2024-08-09

[JS宏]WPS演示中多顶点矩形

 function CreateDialog_CommandButton1_Click()

{

let nodesAdd=CreateDialog.SpinButton1.Value-4;

    let linesAdd=nodesAdd==0?0:nodesAdd/2;

let myDocument = Application.ActivePresentation.Slides.Item(1)

    let theShape=myDocument.Shapes.AddShape(msoShapeRectangle, 50, 50, 200, 20)

    theShape.TextFrame.TextRange.Text="New Shape"

    var subShapes=new Array();

    subShapes.push(theShape.Name);

    var subL=theShape.Left;

    var subT=theShape.Top;

    var subH=theShape.Height

    let subGap=theShape.Width/(linesAdd+1);

    for(i=1;i<linesAdd+1;i++){

    subL+=subGap;

    var shape1=myDocument.Shapes.AddShape(msoShapeRectangle,subL,subT,1,subH);

    shape1.Fill.Transparency=1.0;

    shape1.Line.Transparency=1.0;

    subShapes.push(shape1.Name);

    }

    if(linesAdd>0){

    myDocument.Shapes.Range(subShapes).Group();

    }

   CreateDialog.Close();

}


2024-07-01

cmd下dir递归显示文件夹路径

 dir /S /B /AD

wxWidgets项目的CMake写法示例

cmake_minimum_required(VERSION 3.10)

set(proj run2ps)

set(CMAKE_CXX_STANDARD 11)
project(${proj} CXX)

file(GLOB proj_src ${CMAKE_SOURCE_DIR}/src/*.cpp)

find_package(wxWidgets COMPONENTS core base REQUIRED)

add_executable(${proj} ${proj_src})

target_compile_definitions(${proj} PRIVATE ${wxWidgets_DEFINITIONS})
target_include_directories(${proj} PRIVATE ${wxWidgets_INCLUDE_DIRS})
target_link_directories(${proj} PRIVATE ${wxWidgets_LIBRARY_DIRS})
target_link_libraries(${proj} PRIVATE ${wxWidgets_LIBRARIES})

2024-05-21

FreeBSD作为VirtualBox虚拟机时鼠标滚轮有问题时的处理方法

 1、屏蔽掉按键8的mapping(不同人可能按键不一样)

先查看mapping(0表示屏蔽):

xmodmap -pp

There are 12 pointer buttons defined.

    Physical        Button
     Button          Code
        1              1
        2              2
        3              3
        4              4
        5              5
        6              6
        7              7
        8              0
        9              9
       10             10
       11             11
       12             12

例子中有12个按键

使用以下代码屏蔽掉按键8

xmodmap -e "pointer = 1 2 3 4 5 6 7 0 9 10 11 12"

然后再开启一个pcmanfm之类的窗口测试滚动,如果不行,换别的按键

测试成功后,将以下内容保存至~/.xmodmap

pointer = 1 2 3 4 5 6 7 0 9 10 11 12

更新.profile,加入xmodmap命令,确保每次登陆时,都会执行该动作

/usr/local/bin/xmodmap -e "pointer = 1 2 3 4 5 6 7 0 0 0 11 12"

2、Firefox滚动有问题的处理方法

输入about:config,查找mousebutton,找到mousebutton.4th.enabled,双击改为false即可

3、使用xinput和xev调整按键mapping

先通过xinput list找到对应鼠标的device Id

然后使用xinput get-button-map [devide_id]取到对应设备的mapping(0表示屏蔽),如:

1 2 3 4 5 6 7 8 9 10 11 12

使用xev打开一个窗口,在该窗口点击鼠标各按键,确认所需按键

使用xinput set-button-map [device id] [按键mapping]设置mapping,如:

xinput set-button-map 7 1 2 3 4 5 0 0 0 0 0 0 0

该操作可加入至.profile中以免下次登陆失效

4、终级方式,禁用Host/Guest鼠标平滑切换(禁用后,需使用Right Ctrl切换鼠标)

使用xinput list查看设备,找到nonamed或virtualbox相关的设备

通过xinput get-button-map [device id]查看mapping,确认为如下mapping:

1 0

使用xinput disable [device id]将该设备禁用即可

2019-06-12

Spring不使用数据库查询分页

```java
List content = your result set;
Pageable pageable= new PageRequest(int page, int size);
long total = cound found elements;
PageImpl pager = new PageImpl(content,pageable,cound );
```

Java Runtime.exec取stderr阻塞

原因:


Because some native platforms only provide limited buffer size for standard input and output streams, failure to promptly write the input stream or read the output stream of the subprocess may cause the subprocess to block, and even deadlock.
翻译:
一些平台只为标准输入输出提供有限的缓存。错误的写子进程的输入流或者错误的都子进程的输出流都有可能造成子进程的阻塞,甚至是死锁。

解决方法:

把读取stderr及stdout的操用放到单独的线程中,示例代码:

```java
Process process = Runtime.getRuntime().exec(this.command, envs);
 //System.out.println("-------------------------------------");
 BufferedReader ebr = new BufferedReader(new InputStreamReader(process.getErrorStream()));
 Thread eThread = new Thread(() -> 
 try 
 String eline;
 while (null != (eline = ebr.readLine())) 
 System.out.println("[Error]" + eline);
 
 ebr.close();
 catch (Exception e) 
 e.printStackTrace();
 
 );
 eThread.start();
 //System.out.println("-------------------------------------");
 BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream()));
 Thread oThread = new Thread(() -> 
 try 
 String line;
 while (null != (line = br.readLine())) 
 System.out.println(line);
 
 br.close();
 br.close();
 catch (Exception e) 
 e.printStackTrace();
 
 );
 oThread.start();
 process.waitFor();
 ```
 

[WEB前端]纯Javascript全选checkbox

```javascript
var cbs = document.querySelectorAll('input[type="checkbox"]');
for(var i=0; i < cbs.length; i++){
 cbs[i].checked = true;
}
```