tag:blogger.com,1999:blog-61441175086970719902024-03-12T21:11:35.680-04:00Tips, Tricks and Tools... and ThoughtsUnknownnoreply@blogger.comBlogger361125tag:blogger.com,1999:blog-6144117508697071990.post-76685158545248776922023-05-28T12:59:00.000-04:002023-05-28T12:59:37.637-04:00Golang: selenium test with Google Chrome browserpackage main import ( "errors" "fmt" "log" "os" "github.com/tebeka/selenium") const ( chromeDriverPath = `C:\WebDriver\chromedriver.exe` port = 22222) func main() { opts := []selenium.ServiceOption { selenium.Output(os.Stderr), } selenium.SetDebug(true) service, err := Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6144117508697071990.post-15801759422924079322023-03-20T20:30:00.001-04:002023-03-20T20:30:00.195-04:00golang: sftp connecting to a remote serverpackage mainimport ( "github.com/pkg/sftp" "golang.org/x/crypto/ssh" "log")func main() { // for demo purpose only. Such config is not so secure. config := &ssh.ClientConfig { User: "myusername", Auth: []ssh.AuthMethod { ssh.Password("mypassword") }, HostKeyCallback: Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6144117508697071990.post-10923730470562069852023-03-19T20:00:00.001-04:002023-03-19T20:00:00.210-04:00golang: compute PBKDF2 of a password package mainimport ( "bytes" "crypto/rand" "crypto/sha256" "encoding/hex" "fmt" "golang.org/x/crypto/pbkdf2" "golang.org/x/term" "log" "strings" "syscall")func main() { fmt.Print("Input password: ") password, err := term.ReadPassword(int(syscall.Stdin)) if err != nil { log.Fatal(err) } Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6144117508697071990.post-49891107899979782782023-03-18T20:00:00.001-04:002023-03-18T20:00:00.187-04:00golang: example of query and update with MySQL DBpackage main import { "database/sql" "log" _ "github.com/go-sql-driver/mysql"} func dbConn() *sql.DB { db, err := sql.Open("mysql", "myusername:mypassword@tcp(127.0.0.1:3306)/MYDB") if err != nil { log.Fatal(err) } return db} func DoQuery(Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6144117508697071990.post-379719648891270742023-03-17T20:00:00.001-04:002023-03-17T20:00:00.193-04:00Debug SSL connection with ssltap1. Run ssltap on port 19240: $ ssltap -s -p 19240 <remote host>:<remote port> 2. In a browser, access the remote-host:remote-port by connecting to ssltap:https://localhost:19240 3. Check the ssltap's outputUnknownnoreply@blogger.com0tag:blogger.com,1999:blog-6144117508697071990.post-8518612253601909512023-03-16T20:00:00.001-04:002023-03-16T20:00:00.210-04:00Oracle: dump stored procedureSELECT text FROM sys.all_source WHERE owner = 'schema-owner' AND name = 'package-name' AND type = 'PACKAGE BODY' ORDER BY line;Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6144117508697071990.post-71000812210064648312023-03-15T20:00:00.001-04:002023-03-15T20:00:00.189-04:00How to stop Google Chrome from automatically redirecting to HTTPS1. In a new browser tab, enter URL: chrome://net-internals/#hsts2. Scroll down to "Delete domain security policies" and enter the domain that you don't want automatic redirection. Then click the Delete button.3. If the problem still exists, try to clean the browsing data/cache by going to Settings => Privacy and security.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6144117508697071990.post-13321246198070626732023-03-14T20:00:00.001-04:002023-03-14T20:00:00.196-04:00nginx configuration example for a simple proxyBuild nginx from source code:$ ./configure --prefix=/path/to/install --with-http_ssl_module --without-http_rewrite_module --with-debug$ make; make install Configuration locates at /path/to/install/conf/nginx.conf.Example of the configuration (for demo purpose only):server { listen 443 ssl; server_name localhost; ssl_certificate ngcert.pem; ssl_certificateUnknownnoreply@blogger.com0tag:blogger.com,1999:blog-6144117508697071990.post-55014655665654767892022-11-30T20:42:00.002-05:002022-11-30T20:42:46.562-05:00Windows: Force WiFi to work only on 5GHz1. From Control Panel, open Device Manager as Administrator;2. Expand Network Adapters;3. Double click on the WiFi device you want to change;4. Click on the Advanced tab;5. Select 802.11a/b/g Wireless Mode. Change its value to: 5GHz 802.11a6. Select 802.11n/ac/ax Wireless Mode. Change its value to: 802.11ac7. Click OK to save the settings.The selected 2 modes work only on 5GHz. Select other modesUnknownnoreply@blogger.com0tag:blogger.com,1999:blog-6144117508697071990.post-64336929011230120542022-10-10T16:40:00.004-04:002022-10-10T16:40:45.599-04:00Windows VirtualBox VM DownloadsWindows (with IE8/9/10/11/Edge) Virtual Machine Download URLs:Official: https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/GitHub: https://github.com/magnetikonline/linux-microsoft-ie-virtual-machines Archive.org: https://archive.org/details/ie11.win81.virtualboxFor Speaker and Microphone:VirtualBox Settings:AudioEnable AudioHost Audio Driver: Pulse AudioAudio Controller: Intel Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6144117508697071990.post-40202135064480123782022-10-08T21:13:00.003-04:002022-10-09T10:27:09.769-04:00Google Chrome for Ubuntu/Debian LinuxRepository Manifest: http://dl.google.com/linux/chrome/deb/dists/stable/main/binary-amd64/PackagesPackages is a text file, which contains: SHA256, SHA1, MD5 checksumsDownload link: https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.debUnknownnoreply@blogger.com0tag:blogger.com,1999:blog-6144117508697071990.post-86012374817190666882022-10-02T07:30:00.001-04:002022-10-02T07:30:00.200-04:00Use curl to send 2 HTTP requests in one connection$ curl -X POST http://myserver/myapp -d 'data-1' --next http://myserver/myapp -d 'data-2'Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6144117508697071990.post-8492340938349963202022-07-08T20:00:00.001-04:002022-07-08T20:00:00.176-04:00Java: no such provider: BCProblem:java.security.NoSuchProviderException: no such provider: BCSolution:1. Download Bouncy Castle JAR, e.g.: bcprov-jdk15on-157.jar2. In the code, add: if (Security.getProvider(BouncyCastleProvider.PROVIDER_NAME) == null) { Security.addProvider(new BouncyCastleProvider()); }Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6144117508697071990.post-71841822208283210182022-07-07T20:00:00.001-04:002022-07-07T20:00:00.179-04:00Linux: build OpenSSL 32bit on a 64bit box$ setarch i386 ./config -m32 --prefix=... --openssldir=...Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6144117508697071990.post-44413221902080996772022-07-06T20:00:00.001-04:002022-07-06T20:00:00.176-04:00Tomcat: 403 access denied on managerProblem:403 Access Denied on Tomcat manager page: http://localhost/manager/html Solution:1. Go to /path/to/tomcat/webapp/manager/META-INF2. Edit file context.xml, and remove/comment-out the following lines: <Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />3. Save context.xml4.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6144117508697071990.post-2878180621303950202022-07-05T20:00:00.001-04:002022-07-05T20:00:00.193-04:00Linux: run valgrind on Apache httpdSource code must be compiled with option -gCommand:$ valgrind --leak-check=full --tool=memcheck --error-limit=no --log-file=val.log /usr/bin/httpd -f /etc/httpd.conf -DFOREGROUNDUnknownnoreply@blogger.com0tag:blogger.com,1999:blog-6144117508697071990.post-47376332428264692372022-07-04T20:00:00.001-04:002022-07-04T20:00:00.176-04:00Bash: shell script to obtain the cipher list of a server#!/bin/bash SERVER=$1 if [[ "$SERVER" == "" ]]; then echo "Usage: $0 hostname:port" exitfi DELAY=2ciphers=$(openssl ciphers 'ALL:eNULL' | sed -e 's/:/ /g') for cipher in ${ciphers[@]}do echo -n Testing $cipher ... result=$(echo -n | openssl s_client -cipher "$cipher" -connect $SERVER 2>&1) if [[ "$result" =~ "Session-ID:" ]]; then&Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6144117508697071990.post-47913082877845557382022-07-03T20:00:00.001-04:002022-07-03T20:00:00.174-04:00Windows: Change SSL Cipher Suite1. Right click on the Windows icon and select "Search".2. Input "gpedit.msc". Right click on the gpedit.msc icon and select "Run as administrator".3. The "Local Group Policy Editor" is loaded.3.1. On its left panel, expand "Computer Configuration / Administrative Templates / Network", and then select "SSL Configuration Settings".3.2. On the right panel, double click on "SSL Cipher Suite Order" toUnknownnoreply@blogger.com0tag:blogger.com,1999:blog-6144117508697071990.post-13391985975713855902022-07-02T11:51:00.003-04:002022-07-02T11:51:40.434-04:00Microsoft Outlook: Remove the primary accountClose Outlook.Click the Windows icon and then Run menu. Run command: control mlcfg32.cpl.Click on Show Profiles.Click the Add button to create a new profile.Use Auto Account Setup to set up the new account.In the Mail window, make the new profile default by clicking on Always use this profile.Click Apply to save.Finally, just select your old profile and click Remove.Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-6144117508697071990.post-71026908546043348742022-05-14T12:46:00.005-04:002022-05-14T12:46:43.153-04:00Windows 11: Pin a "bat" shortcut to Start1. Right click on the xx.bat file and copy.2. Right click on the destination fold and select "Show more options" -> "Paste shortcut" to create a shortcut of the xx.bat file.3. Right click on the newly created shortcut and select "Properties".4. In the Properties dialog, change the Target field to: cmd /c "...../xx.bat" where the highlighted part is the Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-6144117508697071990.post-86636303923296933632022-01-23T17:42:00.002-05:002022-01-23T17:42:20.810-05:00Linux: edit PDF with LibreOffice DrawOn Linux, PDF files can be opened and edited by LibreOffice Draw.However, depending on how the PDF is generated, the formatting of the file can be a mess when it is opened by LibreOffice Draw.If that happens, we can use a PDF reader to open it first and print it into a SVG image file.After that, use LibreOffice Draw to open the SVG file and edit it.After the edit, LibreOffice Draw can export the Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6144117508697071990.post-70525588871683124742022-01-23T11:05:00.004-05:002022-01-23T11:05:28.317-05:00Windows: install application as non-admin userSome Windows applications require Administrator account to install.To force the applications to run as a normal user, set the following first: set __COMPAT_LAYER=RunAsInvokerNote: there are two underscore (_) characters at the prefix.For example, if you want to run SteamSetup.exe as a regular user, create a run.bat file and put the following 2 lines in: &Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6144117508697071990.post-89356918494973389672021-12-15T20:40:00.000-05:002021-12-15T20:40:02.865-05:00Linux: Change Swap sizeDisable the old swap file: $ sudo swapoff /swapfileCreate a bigger (8gb) swap file:$ sudo fallocate -l 8G /swapfile$ sudo chmod 600 /swapfile$ sudo mkswap /swapfileEnable the new swap file: $ sudo swapon /swapfile Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6144117508697071990.post-66628761303868722742021-10-31T20:12:00.005-04:002021-11-22T18:38:50.008-05:00GIMP: Outline text or add border to textAdd text and copy path from the text.right-click on the text, and from the context menu, select the Path from Text option Create a new transparent layer and select from path.Menu -> Layer -> New Layer... Menu -> Select -> From PathMove the layer below the layer having the text. Set up a grow size.Menu -> Select -> Grow Add a stroke line to the selection.Menu ->Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-6144117508697071990.post-84353336569879294332021-10-29T20:09:00.004-04:002021-10-29T20:09:46.703-04:00GIMP: Resizing image and filling the empty space1. Resize the CanvasMenu -> Image -> Canvas Size...Note: Click the "Center" button to center the original image. 2. Duplicate the layerMenu -> Layer -> Duplicate Layer3. Resize the lower layerSelect the lower lay (on the right panel) Menu -> Layer -> Scale Layer...Change the Width/Height to a bigger value to make the image cover the whole Canvas.4. Fuzzy the lower Unknownnoreply@blogger.com0