2022-10-10

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

2020-08-13

Raspberry Pi

Download image

https://www.raspberrypi.org/downloads/

unzip xxx.zip

dd if=xxx.img of=/dev/sdx bs=100M

-- or --

unzip -p xxx.zip  | sudo dd of=/dev/sdx bs=100M

* first time boot will resize root partition

  cmdline.txt:

   init=/usr/lib/raspi-config/init_resize.sh   


config:

raspi-config


/boot/config.txt

https://www.raspberrypi.org/documentation/configuration/config-txt/boot.md

# GPU Memory
gpu_mem=512

disable_overscan=1

# Disable rainbow image at boot
disable_splash=1

/boot/cmdline.txt
logo.nologo

# change boot message to tty3 (no boot message)
console=tty3



Boot splash:
/usr/share/plymouth/themes/pix/splash.png

default user/password: pi/raspberry

No Mouse Pointer / no screensaver:
/etc/lightdm/lightdm.conf
[SeatDefaults]
xserver-command=X -s 0 -dpms -nocursor

change background:
DISPLAY=:0.0 pcmanfm --set-wallpaper xxx.jpg

Error: desktop manager is not active
run from cron:
export DISPLAY=:0.0
export XAUTHORITY=/home/pi/.Xauthority # ???
export XDG_RUNTIME_DIR='/run/user/1000'

pcmanfm --set-wallpaper xxx.jpg

pcmanfm --reconfigure --display=:0.0


change IP:

/etc/dhcpcd.conf
interface eth0
static ip_address=192.168.0.4/24    
static routers=192.168.0.254
static domain_name_servers=192.168.0.254 8.8.8.8

profile ssid_xxx
    ipv4only
    static ip_address=192.168.4.2/24

ssid xxx
   fallback ssid_xxx

ssid yyy
   static ip_address=192.168.4.3/24


Wifi:
/etc/wpa_supplicant/wpa_supplicant.conf
network={
   ssid="xxx"
   psk="XXX"
   key_mgmt=WPA-PSK
   priority=5
}
network={
   ssid="yyy"
   psk="yyy"
   key_mgmt=WPA-PSK
   scan_ssid=1
   priority=3
}
network={
   ssid="zzz"
   key_mgmt=NONE
   priority=7
}

Disable service:
sudo update-rc.d boa disable

sudo apt update
sudo apt-get install apache2


/etc/apache2/mods-enabled
sudo ln -s ../mods-available/auth_basic.load
sudo ln -s ../mods-available/cgi.load

/etc/apache2/apache2.conf
<Directory "/usr/local/apache2/htdocs/somedir">
    Options +ExecCGI
</Directory>

AddHandler cgi-script .cgi .pl

/etc/apache2/sites-enabled/999-my.conf
<Location "/">
    AuthType basic
    AuthName "private area"
    AuthBasicProvider  file
    AuthUserFile    "/etc/apache2/password/htpasswd"
    Require            valid-user
</Location>

sudo systemctl restart apache2
sudo systemctl status apache2

virtual wlan interface
https://www.suse.com/c/creating-virtual-wlan-interfaces/

modprobe mac80211_hwsim
# wlan1 & wlan2 will be created

/etc/modules
mac80211_hwsim
* auto load

routed wireless access point

sudo apt install hostapd

sudo systemctl unmask hostapd
sudo systemctl enable hostapd

sudo apt install dnsmasq

sudo DEBIAN_FRONTEND=noninteractive apt install -y netfilter-persistent iptables-persistent

/etc/dhcpcd.conf
profile static_wlan0
static ip_address=192.168.4.1/24

interface wlan0
    env ifwireless=0
    fallback static_wlan0
    static ip_address=192.168.4.1/24
    nohook wpa_supplicant

* fix static ip/nohook not work

/etc/sysctl.d/routed-ap.conf
net.ipv4.ip_forward=1

sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo netfilter-persistent save

sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig

/etc/dnsmasq.conf
# Listening interface
interface=wlan0

dhcp-range=192.168.4.2,192.168.4.20,255.255.255.0,24h
# Pool of IP addresses served via DHCP
# Local wireless DNS domain
domain=wlan
address=/gw.wlan/192.168.4.1
# Alias for this router

sudo rfkill unblock wlan

/etc/hostapd/hostapd.conf
country_code=GB
interface=wlan0
ssid=NameOfNetwork
hw_mode=g
channel=7
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=AardvarkBadgerHedgehog
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP


*** dnsmasq make resolv.conf nameserver -> 127.0.0.1

resolvconf -i
resolvconf -d lo.dnsmasq


Captive Portal
https://captivebehavior.wballiance.com/

android:
http://connectivitycheck.gstatic.com/generate_204
ios:
http://captive.apple.com/hotspot-detect.html
mi:
http://connect.rom.miui.com/generate_204
http://developers.google.cn/generate_204
samsung:
?

Web Server:
ln -s index.html generate_204
ln -s index.html hotspot-detect.html

/etc/dnsmasq.conf
# ALL domain -> 192.168.4.243
address=/#/192.168.4.243

redirect any tcp port 80/443 from interface wlan0 to 192.168.4.243
iptables -t nat -I PREROUTING -i wlan0 -p tcp --dport 80 -j DNAT --to 192.168.4.243:80
iptables -t nat -I PREROUTING -i wlan0 -p tcp --dport 443 -j DNAT --to 192.168.4.243:443




Video player: OpenMAX H.264 GPU decode (pi 3 test youtube 1080@60) 
omxplayer
    -o both    audio 3.5mm & hdmi
    -o local    audio 3.5mm
    -o hdmi    audio hdmi
    -o alsa[:device]    bluetooth, etc
    --timeout 0    (fix m3u8 live stream stop)
    --win x1,y1,x2,y2    geometry
    --crop x1,y1,x2,y2
    --layer n    Set video render layer number (higher numbers are on top) (multi omxplayer)

web server: boa
sudo apt-get install boa

# add video/audio play permission to web cgi (user: www-data)
sudo usermod -a -G video www-data
sudo usermod -a -G audio www-data

/etc/boa/boa.conf
AddType application/x-httpd-cgi cgi

/etc/sudoers.d/power
# cgi to reboot/poweroff
www-data ALL = NOPASSWD:/sbin/reboot, /sbin/poweroff

sudo service boa start


Photo Viewer: feh

Launch bar logo
sudo cp xxx.png /usr/share/icons/PiX/16x16/places/rpi-logo.png
sudo cp xxx.png /usr/share/icons/PiX/24x24/places/rpi-logo.png
sudo cp xxx.png /usr/share/icons/PiX/32x32/places/rpi-logo.png
sudo cp xxx.png /usr/share/icons/PiX/48x48/places/rpi-logo.png

Raspberry logo
sudo cp yyy.png /usr/share/icons/hicolor/32x32/apps/rpi.png
sudo cp yyy.png /usr/share/icons/PiX/16x16/apps/rpi.png
sudo cp yyy.png /usr/share/icons/PiX/24x24/apps/rpi.png
sudo cp yyy.png /usr/share/icons/PiX/32x32/apps/rpi.png
sudo cp yyy.png /usr/share/icons/PiX/48x48/apps/rpi.png


/etc/rc.local not execute at first time power on
rc.local run before dependency service & got error
 -> check & wait for the service ready

systemctl list-units --no-pager

$ systemctl status rc.local

Warning: The unit file, source configuration file or drop-ins of rc-local.service changed on disk. Run 'systemctl daemon-reload' to reload units.

sudo systemctl daemon-reload


poweroff / reboot slow
/etc/systemd/system.conf
   DefaultTimeoutStopSec=5s