2025-01-06

image

 

imagemagick

  convert in.image -unique-colors -depth 8 out.txt


exiftool -G1 -a -s -Preview:all /path/to/files/

raw/dng

dcraw

  raw-identify

  dcraw -e 

  dcraw -i -v 

  dcarw -D

  dcraw -d

  dcraw -s 0 -q 0 -T -o 0 -6 -g 1 1 -W -w 

libraw

  unprocessed_raw


gimp

krita - dng

darktable - dng

rawtherapee - dng

digikam

Multi-pointer_X

 https://wiki.archlinux.org/title/Multi-pointer_X



xinput create-master [name]


xinput list


xinput reattach [slave device name or id] [master device name or id]


mouse to <new>


keyboard to <new>

alsa both hdmi & internal/3.5mm

 ~/.asoundrc



# /proc/asound/cards


# default - plug

#   asymed - asym

#     all - route - multi

#       intdmix - dmix

#         int - hw

#       hdmidmix3 - dmix

#         hdmi3 - hw

#     capture




pcm.int {

type hw

card PCH

# device 0

}

ctl.int {

type hw

card PCH

# device 0

}



pcm.hdmi3 {

type hw

card HDMI

device 3

}

ctl.hdmi3 {

type hw

card HDMI

device 3

}


pcm.hdmi7 {

type hw

card HDMI

device 7

}

ctl.hdmi7 {

type hw

card HDMI

device 7

}




pcm.intdmix {

type dmix

ipc_key 1024

slave {

pcm "int"

channels 2


period_time 0

period_size 1024

buffer_size 4096

rate 44100

}

bindings {

0 0

1 1

}


}



pcm.hdmidmix3 {

type dmix

ipc_key 4096

slave {

pcm "hdmi3"

channels 2


period_time 0

period_size 1024

buffer_size 4096

rate 44100

}

bindings {

0 0

1 1

}


}


pcm.hdmidmix7 {

type dmix

ipc_key 8192

slave {

pcm "hdmi7"

channels 2


period_time 0

period_size 1024

buffer_size 4096

rate 44100

}

bindings {

0 0

1 1

}


}


pcm.all {

type route

slave.pcm {

type multi


slaves.a.pcm "intdmix"

slaves.a.channels 2

bindings.0.slave a

bindings.0.channel 0

bindings.1.slave a

bindings.1.channel 1



slaves.b.pcm "hdmidmix3"

slaves.b.channels 2

bindings.2.slave b

bindings.2.channel 0

bindings.3.slave b

bindings.3.channel 1


slaves.c.pcm "hdmidmix7"

slaves.c.channels 2

bindings.4.slave c

bindings.4.channel 0

bindings.5.slave c

bindings.5.channel 1

}


ttable.0.0 1

ttable.1.1 1


ttable.0.2 1

ttable.1.3 1


ttable.0.4 1

ttable.1.5 1


}


ctl.all {

type hw

card PCH

}



pcm.!default {

type plug

# slave.pcm "dmixer"

slave.pcm "asymed"

  # slave.pcm "all"

    # slave.pcm "hdmidmix"

    # slave.pcm "hdmidmix3"

    # slave.pcm "hdmidmix7"

# slave.pcm "intdmix"

}





pcm.dmixer  {

  type dmix

  ipc_key 1024

  slave {


# HDMI

# pcm "hw:0,0"

# Analog

pcm "hw:0,3"



period_time 0

period_size 1024

buffer_size 4096

rate 44100

}

bindings {

0 0

1 1

}

}


pcm.asymed { 

        type asym 

        # playback.pcm "dmixer" 

        playback.pcm "all" 


        capture.pcm "hw:PCH" 

        # capture.pcm "hw:0,2" 


pcm.dsp0 { 

    type plug 

    slave.pcm "asymed" 



ctl.mixer0 {

type hw

card 0

}



Apache reverse proxy HTTPS to HTTP

 Listen a.b.c.d:443

<VirtualHost a.b.c.d:443>

    ServerName example.org

    # …SSL configuration…

    ProxyRequests off

    ProxyPass / http://localhost:3000/

    ProxyPassReverse / http://localhost:3000/

    RequestHeader set X-Forwarded-Protocol "https"

    Header edit Location ^http://(.*)$ https://$1

</VirtualHost>

ffmpeg

 

jpg -> mp4

ffmpeg -framerate 1 -pattern_type glob -i '*.jpg' -c:v libx264 video.mp4


ffmpeg -framerate 0.3 -pattern_type glob -i '*.jpg' -vf "scale=-1:3072,pad=4096:ih:(ow-iw)/2" -c:v libx264 video.mp4


video -> png

ffmpeg -skip_frame nokey -i file.avi -vf 'scale=128:72,tile=8x8' -an -vsync 0 keyframes%03d.png


change framerate

ffmpeg -i in.mp4 -filter:v "setpts=PTS*8" -an -vcodec copy -r 30 out.mp4

ffmpeg -i  in.mp4 -filter:v "setpts=0.1*PTS" -an  -r 60 out.mp4

ffmpeg -i  in.mp4 -vf "select='not(mod(n\,60))',setpts=N/FRAME_RATE/TB" -an -r 60  out.mp4

ffmpeg -i  in.mp4 -vf framestep=90,setpts=N/FRAME_RATE/TB -an -r 60 out.mp4

ffmpeg -i in.mp4 -c copy -f h264 - | ffmpeg -r 120 -i - -c copy out.mp4



ffmpeg -i i.mp4 -i 1.jpg -filter_complex "[1:v] fade=out:125:25:alpha=1 [intro]; [0:v][intro] overlay [v]" -map "[v]" -map 0:a -acodec copy  o5.mp4


ffmpeg -y -i i.mp4 -i 1.jpg -filter_complex "[1:v] fade=out [intro]; [0:v][intro] overlay=x=100:y=800 [v]" -map "[v]" -map 0:a -acodec copy  o9.mp4


ffmpeg -i i.mp4 -i 1.jpg -i a.svg -filter_complex "[0:v][1:v]overlay=100:600[v0];  [v0][2:v]overlay=W-200:30" -c:a copy -y o6.mp4


ffmpeg -i i.mp4 -i 1.jpg -i a.svg -filter_complex "[0:v][1:v]overlay=100:H-300[VV];  [VV][2:v]overlay=W-200:30" -c:a copy -y o6.mp4


ffmpeg -i i.mp4 -i s.svg -i l.svg -filter_complex "[0:v][1:v]overlay=100:H-150:enable='between(t,3,4)' [VV];  [VV][2:v]overlay=W-200:30:enable='between(t,1,2)'" -c:a copy -y o6.mp4



ffmpeg -ss $a -to $b -i $I -i $Logo -i ba0.svg -i ba2.svg -filter_complex

  "[0:v][1:v]overlay=W-160:30 [VV]; [VV][2:v]overlay=100:H-150 [VVV]; [VVV][3:v]overlay=100:H-150:enable='between(t,$T2,30)'" -y $OPT $N

ffmpeg cam

 

ffmpeg /dev/video0


ffmpeg -f v4l2 -list_formats all -i /dev/video0

ffplay -f v4l2 -list_formats all /dev/video0


arecord -l

cat /proc/asound/cards

hw:1,0

lsusb -v | grep 'tSamFreq'


arecord -f S16_LE -c 2  -D "hw:1,0" a-001

ffplay -f alsa -i hw:1,0


ffplay -f v4l2 -video_size 1920x1080 -framerate 30 /dev/video0

ffplay -f v4l2 -video_size 1280x720 -framerate 30 /dev/video0

ffplay -f v4l2 -video_size 1366x768 -framerate 30 /dev/video0


ffmpeg -f v4l2 -framerate 30 -video_size 1920x1080 -c:v mjpeg -i /dev/video0 -c:v copy output.mov


ffmpeg -f v4l2 -framerate 30 -c:v mjpeg -i /dev/video0 -c:v copy output.mkv

ffmpeg -f v4l2 -framerate 30 -c:v mjpeg -i /dev/video0 -f alsa -i hw:1,0 -c:v copy -c:a copy  output.mkv

ffmpeg -f v4l2 -framerate 30 -c:v mjpeg -i /dev/video0 -f alsa -i hw:1,0 -c copy  output.mkv

ffmpeg -f v4l2 -framerate 30 -c:v mjpeg -i /dev/video0 -f alsa -i hw:1,0 -c copy -f rawvideo  - | ffplay -

ffmpeg -f v4l2 -framerate 30 -c:v mjpeg -i /dev/video0 -f alsa -i hw:1,0 -c copy -f avi  - | ffplay -

ffplay -f v4l2 -framerate 30   /dev/video0 

vlc v4l2:///dev/video0 --input-slave=alsa://hw1,0 --alsa-samplerate=96000




bluetooth

 

/usr/local/etc/init.d/bluez status


pulseaudio

bluetoothctl power on
bluetoothctl agent on

bluetoothctl
  scan on
  scan off

bluetoothctl devices
bluetoothctl info

bluetoothctl remove xx:xx:xx:xx:xx:xx
bluetoothctl trust      xx:xx:xx:xx:xx:xx
bluetoothctl pair        xx:xx:xx:xx:xx:xx
bluetoothctl connect xx:xx:xx:xx:xx:xx
bluetoothctl info        xx:xx:xx:xx:xx:xx

pactl list sinks | grep Name:
pactl set-default-sink bluez_sink.xx_xx_xx_xx_xx_xx.a2dp_sink

pactl -- set-sink-volume 1 -10%
pactl -- set-sink-volume 1 +10%

pactl -- set-sink-volume 1 10%
pactl -- set-sink-volume 1 50%

2023-01-10

jdk ssl/tls

1.7 default tls1


-Dhttps.protocols=SSLv3,TLSv1,TLSv1.1,TLSv1.2

-Djavax.net.debug=ssl


1.8 default tls1.2

mobile browser request retry - idempotent requests

https://groups.google.com/a/chromium.org/g/chromium-dev/c/urswDsm6Pe0


https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html


https://aws.amazon.com/builders-library/making-retries-safe-with-idempotent-APIs/


https://answers.sap.com/questions/13359226/preventing-http-retry-requests-eg-via-approuter.html


zip filename encode (non-UTF8)

LC_CTYPE=zh_TW.big5 7z x file.zip


LC_CTYPE=zh_TW.big5 busybox unzip file.zip


TODO: filename in big5



ls -i 


find . -inum 12321475 -exec mv {} new-filename \;


find . -inum 12321475 -print0 | xargs -0 mv -t new-filename


wmctrl / xdotool - XWindow move resize

 

wmctrl


wmctrl -d


wmctrl -l


wmctrl -i -a <win id>


wmctrl -i -r <win id> 0,x,y,w,h




wmctrl -lx

0x00a00002  1 aterm.XTerm           box Terminal

0x01000002  1 google-chrome.Google-chrome  box WeChat/Weixin for Web - Google Chrome

0x01000005  1 google-chrome.Google-chrome  box about:blank - Google Chrome

0x01000006  1 google-chrome.Google-chrome  box QR-slot.png (500×500) - Google Chrome



google

wmctrl -i -r 0x01000005 -e 0,150,40,1000,800


wechat

wmctrl -i -r 0x01000002 -e 0,0,140,900,800


xdotool


xdotool search wechat

xdotool search ""


2022-10-10

Linux traffic control

 sudo tc qdisc add dev eth0 root netem delay 200ms

sudo tc qdisc del dev eth0 root netem delay 200ms


sudo tc qdisc add dev eth0 root netem delay 1000ms

sudo tc qdisc del dev eth0 root netem delay 1000ms


sudo tc qdisc del dev eth0 root netem delay 2000ms


RC522 with raspberry pi

M1

S50

UID

UFUID

FUID

CUID


rc522

pn532


https://github.com/ikarus23/MifareClassicTool


https://github.com/ondryaso/pi-rc522


https://github.com/mxgxw/MFRC522-python


https://stackoverflow.com/questions/41326384/re-writing-uid-and-block-0-on-chinese-supposed-to-be-writable-mifare-1k-card-i


There are 2 types of UID writeble cards:


Block 0 writable cards: you can write block 0 at any moment

Backdoored cards

If writing block 0 does not work, you probably have a backdoored card: To enable the backdoor, you need to send the following sequence to the card: (everything in hexadecimal)


RC522 > Card: 50 00 57 cd (HLTA + CRC)

RC522 > Card: 40 (7 bits only)

Card > RC522: A (4 bits only)

RC522 > Card: 43

Card > RC522: A (4 bits only)

Then you can write to block 0 without authentication. If it still does not work, your card is probably not UID changeable.



芢聆湮苤: 褫夔岆 1024-byte 湮苤腔縐

楷冞:     50  00  57  cd  

楷冞:     40 (7 bits)

彶善: a (4 bits)

楷冞:     43  

彶善: 0a  




Name Pin # Pin name

SDA 24 GPIO8

SCK 23 GPIO11

MOSI 19 GPIO10

MISO 21 GPIO9

IRQ None None

GND Any Any Ground

RST 22 GPIO25

3.3V 1 3V3



sudo raspi-config

spi

remote-gpio



sudo apt-get update

sudo apt-get upgrade


sudo apt-get install python3-dev python3-pip


sudo apt-get install python-spidev python3-spidev


???

sudo pip3 install spidev

sudo pip3 install mfrc522


git clone https://github.com/lthiery/SPI-Py.git


cd SPI-Py/

git checkout 8cce26b9ee6e69eb041e9d5665944b88688fca68

git checkout 8cce26b9ee6e69eb041e9d5665944b88688fca68

git checkout -b 8cce26b9ee6e69eb041e9d5665944b88688fca68

sudo python setup.py install

sudo python3 setup.py install


git clone https://github.com/mxgxw/MFRC522-python.git

cd MFRC522-python

python Read.py




注意:0扇区不能随意乱写,0扇区写不符合算法规则的数据会导致卡片锁死。


byte0-byte3 为UID


byte4 为check byte 算法 byte4 = byte0 ^ byte1 ^ byte2 ^ byte3


byte5为0x08


byte6 为0x04,


byte7 为0x00,Byte5,Byte6和byte7是m1卡片类型不可随意更改。

https://www.gushiciku.cn/pl/pi9z/zh-tw


https://www.tspweb.com/key/%E6%89%8B%E6%9C%BAnfc%E6%9A%B4%E5%8A%9B%E7%A0%B4%E8%A7%A3ic%E5%8D%A1%E5%AF%86%E9%92%A5.html


X11 Forwarding


xauth list

xxx


echo $DISPLAY

YYY


another user:

xauth add "xxx"


export DISPLAY="YYY"

Linux disable touchpad mid-click

xinput list

 

xinput get-button-map 10

#   1 2 3 4 5 6 7 


xinput list --long 10

    Button labels: "Button Left" "Button Middle" "Button Right" "Button Wheel Up" "Button Wheel Down" "Button Horiz Wheel Left" "Button Horiz Wheel Right"

 

# disable mid-click

xinput set-button-map 10 1 0 3 4 5 6 7


# mid-click -> left

xinput set-button-map 10 1 1 3 4 5 6 7


2022-02-10

Oracle select multi rows random

 

select B.*, to_char(B.Rand, '0XXXXX') Str from

(

 select A.*, trunc(DBMS_RANDOM.value(A.L, A.H)) Rand from

 (

   select level no,

      200000+level*100000 L,

      200000+level*100000+50000 H

   from dual connect by level <= 100

 ) A

) B

;


NO     L        H       RAND STR
---------- ---------- ---------- ---------- -------
1     300000   350000     317314  04D782
2     400000   450000     408319  063AFF
3     500000   550000     538362  0836FA
4     600000   650000     633656  09AB38
5     700000   750000     724852  0B0F74
6     800000   850000     823489  0C90C1
7     900000   950000     948578  0E7962
8    1000000 1050000    1026192  0FA890
9    1100000 1150000    1107769  10E739
10    1200000 1250000    1221980  12A55C
11    1300000 1350000    1338767  146D8F
12    1400000 1450000    1418473  15A4E9
13    1500000 1550000    1522499  173B43
14    1600000 1650000    1646482  191F92
15    1700000 1750000    1746193  1AA511
16    1800000 1850000    1815369  1BB349
17    1900000 1950000    1923534  1D59CE
18    2000000 2050000    2030796  1EFCCC
19    2100000 2150000    2149042  20CAB2
20    2200000 2250000    2202140  219A1C


2022-01-28

Tiny Core Linux - sftp

 

/usr/local/etc/ssh/sshd_config

Match User ftp1

        ChrootDirectory /ftp

        X11Forwarding no

        AllowTcpForwarding no

        ForceCommand internal-sftp 


/etc/passwd
ftp1:x:1000:1000:Linux User,,,:/upload:/bin/false


drwxr-xr-x 3 root root 60 Jan 28 11:02 /ftp
drwxrwxr-x 2 root ftp1 60 Jan 28 11:03 /ftp/upload


2021-02-11

Windows 10 file explorer border / title bar color


[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\DWM]

"Composition"=dword:00000001

"ColorizationColor"=dword:c40078d7

"ColorizationColorBalance"=dword:00000059

"ColorizationAfterglow"=dword:c40078d7

"ColorizationAfterglowBalance"=dword:0000000a

"ColorizationBlurBalance"=dword:00000001

"EnableWindowColorization"=dword:00000001

"ColorizationGlassAttribute"=dword:00000001

"AccentColor"=dword:ffd77800

"ColorPrevalence"=dword:00000001

"EnableAeroPeek"=dword:00000000


[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize]

"ColorPrevalence"=dword:00000000

"EnableTransparency"=dword:00000001

"AppsUseLightTheme"=dword:00000001

"SystemUsesLightTheme"=dword:00000000



[HKEY_CURRENT_USER\Control Panel\Colors]

"ActiveBorder"="180 180 180"

"ActiveTitle"="153 180 209"

"AppWorkspace"="171 171 171"

"Background"="0 0 0"

"ButtonAlternateFace"="0 0 0"

"ButtonDkShadow"="105 105 105"

"ButtonFace"="240 240 240"

"ButtonHilight"="255 255 255"

"ButtonLight"="227 227 227"

"ButtonShadow"="160 160 160"

"ButtonText"="0 0 0"

"GradientActiveTitle"="185 209 234"

"GradientInactiveTitle"="215 228 242"

"GrayText"="109 109 109"

"HilightText"="255 255 255"

"HotTrackingColor"="0 102 204"

"InactiveBorder"="244 247 252"

"InactiveTitle"="191 205 219"

"InactiveTitleText"="0 0 0"

"InfoText"="0 0 0"

"InfoWindow"="255 255 225"

"Menu"="240 240 240"

"MenuBar"="240 240 240"

"MenuText"="0 0 0"

"Scrollbar"="200 200 200"

"TitleText"="0 0 0"

"Window"="255 255 255"

"WindowFrame"="100 100 100"

"WindowText"="0 0 0"

"Hilight"="0 120 215"

"MenuHilight"="0 120 215"



[HKEY_CURRENT_USER\Control Panel\Desktop\Colors]

"ActiveBorder"="212 208 200"

"ActiveTitle"="10 36 106"

"AppWorkSpace"="128 128 128"

"ButtonAlternateFace"="181 181 181"

"ButtonDkShadow"="64 64 64"

"ButtonFace"="212 208 200"

"ButtonHiLight"="255 255 255"

"ButtonLight"="212 208 200"

"ButtonShadow"="128 128 128"

"ButtonText"="0 0 0"

"GradientActiveTitle"="166 202 240"

"GradientInactiveTitle"="192 192 192"

"GrayText"="128 128 128"

"Hilight"="10 36 106"

"HilightText"="255 255 255"

"HotTrackingColor"="0 0 128"

"InactiveBorder"="212 208 200"

"InactiveTitle"="128 128 128"

"InactiveTitleText"="212 208 200"

"InfoText"="0 0 0"

"InfoWindow"="255 255 255"

"Menu"="212 208 200"

"MenuText"="0 0 0"

"Scrollbar"="212 208 200"

"TitleText"="255 255 255"

"Window"="255 255 255"

"WindowFrame"="0 0 0"

"WindowText"="0 0 0"


[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Accent]

"AccentPalette"=hex:a6,d8,ff,00,76,b9,ed,00,42,9c,e3,00,00,78,d7,00,00,5a,9e,\

  00,00,42,75,00,00,26,42,00,f7,63,0c,00

"StartColorMenu"=dword:ff9e5a00

"AccentColorMenu"=dword:ffd77800


2020-09-09

Windows 7 ad hoc share wifi internet

 

https://www.pcninja.us/turn-your-windows-7-laptop-into-a-wifi-hotspot/


netsh wlan set hostednetwork mode=allow ssid=MyNetworkhere key=Password

netsh wlan start hostednetwork

select the network adapter to share enable "Allow other network users to connect…"

netsh wlan stop hostednetwork