DALLASCAO.COM

Site of Cao Shouguang, English to Chinese translator

sed regular expressions

sed regular expressions
echo 'iweigh297lbs' | sed 's/.*[^0-9]\([0-9]\+\).*/\1/' The expression has to match the whole line. Greed: The expression will match the largest possible from left to right. This won’t work. echo 'iweigh297lbs' | sed 's/.*\([0-9]\+\).*/\1/' Output 7 This won’t work echo 'iweigh297lbs' | sed 's/.*[^0-9]\([0-9]*\).*/\1/' This works echo 'iweigh297lbs' | sed 's/.*[^0-9]\([0-9][0-9]*\).*/\1/' + has to be escaped. […]Read More

How to run chrome from command line

How to run chrome from command line
YOu need first add the chrome.exe directory to windows environment. [Environment]::SetEnvironmentVariable("Path", "$env:Path;C:\Program Files (x86)\Google\Chrome\Application", "User")Read More

sudo: allow non-root users run certain commands

sudo: allow non-root users run certain commands
Allow user www-data to run ps www-data ALL = NOPASSWD: /bin/psRead More

Script works under command line but not in crontab?

Script works under command line but not in crontab?
Add the following lines to crontab and then it will work: SHELL=/bin/bash PATH=/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/gamesRead More

Build a Shadowsocks server – an easier alternative to VPN

Build a Shadowsocks server – an easier alternative to VPN
WARNING: An extra port 998 is also opened for shadowsocks service. I am being lazy so that I do not have handle exceptions when writing add/remove port scripts. Edit config.json and remove the port if you are worried. Last time I wrote a tutorial on how to build an PPTP server. Now a new way […]Read More