Posts

New: How to connect to mysql database from go - correct way

  The dbconnect.go Architecture In Go, sql.Open doesn't actually connect to the database—it initializes a Pool . This pool is a manager that sits between your code and the database, handing out "check-out" tickets for connections. 1. The Connection (The "Dial") The DSN string defines the network path. By adding parameters like timeout=30s , you tell the driver how long to wait for the initial handshake before giving up. 2. The Pooling (The "Manager") By setting SetMaxOpenConns , you create a hard ceiling. If you set it to 10, Go will never attempt an 11th connection. Instead, it makes the next request wait in a queue. SetConnMaxLifetime ensures that old, "stale" connections are killed off before the server (DreamHost) forcibly drops them. 3. The Context (The "Stopwatch") Using context.WithTimeout is how you control that queue. Without a context, a query might wait forever for a free connection. With a context, you say: "I ...

Do not use anydesk application

Image
 I have recently installed anydesk on my Linux Mint Cinnamon Dell laptop. Two bad things happened: It installs itself as an autostart application which starts immediately when a session starts. That's considered bad behavior. I don't need it to autostart just to connect to other computers every few months. I couldn't find inside the application itself how to disable it had to get into my Cinnamon settings startup apps and disable it. Even worse than that:           2. I started getting weird behavior of Cinnamon. It happened that a new gnome-session was starting in the background causing me to lose the Cinnamon session while working. After running "apt purge anydesk" all problems were solved. That's looks like a bug or some other disturbing behavior. I recommend other software like teamviewer which does not include the malicious behavior above. I am not affiliated with any o...

Using locate, updatedb, mlocate and plocate on Linux with encrypted home directory

I love using " locate " command on Linux. Finding files in a blink of an eye. Combining with " updatedb " it works amazingly fast. I discovered that if your home directory is encrypted (or other directories are encrypted), by default locate command will not find anything in those directories. The better solution is to build a local indexed database of your files: updatedb -l 0 -o ~/.my_locate.db -U $HOME And then using this database to search for files: locate -d ~/.my_locate.db "part file name"    You may also want to edit: cat /etc/updatedb.conf And look at disregarded directories and filesystems: PRUNEPATHS, PRUNEFS  

Someone using Tencent servers have been attacking my websites

Image
Someone using Tencent servers have been attacking my websites, mostly from China, Singapore, Vietnam, but also the US and Brazil. I usually have around 1K people surfing my website at any given time. Occasionally my website https://www.gematrix.org is getting published in a blog about Gematria and numeric values and I get higher traffic organically.  This attack was happening on multiple websites I own, not just this one, but the attack was made more brutally on Gematrix and at this website I investigated it. Lately, my website started crushing down. Did not worked properly. Responses were very slow.  Looking a bit more deeply into it, I could see I have around 12K visitors at the same second in my website which caused the delay. Like thousands of thousands requests per seconds. I did two things: 1. One of them is what I call "scale better": I have improved the way I handle requests, improved the caching and improved the database querying, schema and access.  Thanks god I...