Skip to content

Instantly share code, notes, and snippets.

@nufeng1999
nufeng1999 / startjupyter-lab.js
Last active September 5, 2021 14:31
[WSL2 startjupyter-lab] 自动映射 jupyter-lab 端口 #WSL2 #jupyter #WSL2端口映射
#!/bin/bash
cd ~/Jupyter
PROC_NAME=jupyter-lab
ProcNumber=`ps -ef |grep -w $PROC_NAME|grep -v grep|wc -l`
#echo $ProcNumber
if [ $ProcNumber -le 0 ];then
echo "--->run jupyter-lab<---"
/usr/local/bin/jupyter-lab --ip=0.0.0.0 --allow-root > /dev/null 2>&1 &
fi
export localhost_ip=`ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d addr:`
@nufeng1999
nufeng1999 / Win11_taskbar_chg2_Win10_taskbar.md
Last active May 19, 2024 06:27
[Windows 11 taskbar change to Windows 10 taskbar] #Windows 11 #Windows 10 #taskbar

Win11_taskbar_chg2_Win10_taskbar.reg

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced]

"Start_ShowClassicMode"=dword:00000001

@nufeng1999
nufeng1999 / setwsl2bridge.sh
Last active September 27, 2021 09:07
[Change WSL2 to bridge mode & Set fixed ip for wsl2 (Default use host WLAN)] #WSL2 #bridge #fix #ip
#!/bin/sh
################################################
# 设置 WSL2 网络为桥接模式 (Default use host WLAN)
# Change WSL to bridge mode (Default use host WLAN)
################################################
#export PATH=$PATH:/mnt/c/Windows/System32
#export PATH=$PATH:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/
#让WSL改变为网桥模式(无线使用 WLAN,有线使用 以太网 ,powershell 下使用 NetAdapter 命令查看)
#Change WSL to bridge mode (Default use host WLAN)
/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/powershell.exe -command "Set-VMSwitch WSL -NetAdapterName WLAN"
@nufeng1999
nufeng1999 / hostipinwsl2.md
Last active September 5, 2021 14:29
[In wsl2, the network address of the host ] #WSL2 #host #ip

/etc/resolv.conf nameserver xxx.xxx.xxx.xxx ---It's host IP

export HOSTIP=`cat /etc/resolv.conf|grep nameserver| head -n 1|cut -d" " -f 2`
echo $HOSTIP
@nufeng1999
nufeng1999 / QListWidget.md
Created June 24, 2021 11:52
[QListWidget如何绘制圆角] #QListWidget #圆角

QListWidget如何绘制圆角

CusListwidget::CusListwidget(Qwidget *parent) : QListwidget (parent){
	Qwidget: :setwindowFlag(Qt: :FramelessWindowHint);
	Qwidget::setAttribute(Qt: :wA_ TranslucentBackground);QPalette p(Qwidget: :palette();
	p.setColor(QPalette: : Base, Qt: :transparent);Qwidget: :setAutoFillBackground(true);
	Qwidget::setPalette(p)3
	QListwidget: : setFramestyle(QF rame : :NoFrame);
}
void CusListWidget: :paintEvent(QPaintEvent *e){
@nufeng1999
nufeng1999 / daemon.c
Last active June 24, 2021 07:59
[daemon函数] #gcc #daemon
// vim: syntax=c
int daemon( int nochdir, int noclose )
{
pid_t pid;
if ( !nochdir && chdir("/") != 0 ) //if nochdir=0,change dir to "/"
return -1;
if ( !noclose ) //if noclose is 0
{
int fd = open("/dev/null", O_RDWR);
if ( fd < 0 )
@nufeng1999
nufeng1999 / vscode_cygwin.md
Last active June 23, 2021 01:22
[轻松搞定vscode 编译cygwin gcc 项目的配置]

1.请在 cygwin 里的/etc/profile文件的开头部位加上 export WORKDIR=$PWD ,末尾部位加上 cd $WORKDIR

因为执行类似 I:\cygwin64\bin\bash.exe --login -c "echo $PWD" 这样的命令时,工作目录才不会改变成 /home/Administrator

2.cygwin gcc 编译时可能需要配置一些环境变量等,可以在.vscode/settings.json里加上下面的配置 bash 无 --login 参数时,将执行BASH_ENV配置的文件

	"terminal.integrated.env.windows": {
		"Path":"",
 "OSTYPE":"cygwin",
@nufeng1999
nufeng1999 / closewinimm.cpp
Last active June 22, 2021 00:52
[关闭输入法] #CloseIMM #CloseWinImm #ImmReleaseContext #ImmSetOpenStatus #ImmAssociateContext #ImmGetContext #输入法
// vim: syntax=c++
#include <windows.h>
#include <tchar.h>
#include <iostream>
#include <strsafe.h>
#include <io.h>
#include <list>
#include <algorithm>
#include <fcntl.h>
@nufeng1999
nufeng1999 / build_arm_openssl.md
Last active June 21, 2021 05:51
[编译arm版本的openssl] #编译 #arm #openssl
GCC_ARCH="-m32" AR="arm-linux-ar" RANLIB=arm-linux-ranlib  CC=arm-linux-gcc LD=arm-linux-ld  AS=arm-linux-as PROCESSOR=ARM ./Configure linux-armv4 no-asm shared  -DL_ENDIAN -D_GNU_SOURCE --prefix=/arm-linux  --openssldir=/arm-linux/etc/ssl

error: PTHREAD_MUTEX_RECURSIVE undeclared 添加 -D_GNU_SOURCE 然后删除Makefile里两处 -m64 --------------------------------完美成功 openssh --------------------------------完美成功

@nufeng1999
nufeng1999 / build_arm_tcc.md
Created June 21, 2021 05:47
[编译arm版本的tcc] #编译 #arm #tcc

gcc------------------------------------ tcc-0.9.27----------------------

 GCC_ARCH="-m32" AR="arm-linux-ar" RANLIB=arm-linux-ranlib  CC=arm-linux-gcc LD=arm-linux-ld  AS=arm-linux-a PROCESSOR=ARM 
 
 ./configure --prefix=/arm-linux/opt/tcc \
 --sysroot=/arm-linux \
 --cross-prefix=arm-linux- \
 --libpaths=/arm-linux/lib \
 --crtprefix=/arm-linux/sysroot/usr/lib \