472 subscribers
6 photos
1 video
2 files
550 links
python, go, code quality, security, magic

Website and RSS:
https://itgram.orsinium.dev

Source:
https://github.com/orsinium/itgram

Author:
@orsinium
https://orsinium.dev/
Download Telegram
πŸ“„ That XOR Trick is an article about properties of XOR with Python 🐍 examples. Another one fun exercise in category "avoid it on production".
πŸ“„ A new and innovative way for Google to kill your SaaS startup. TL;DR: a company's domain was added in Google Safe Browsing list and so Chrome of their users kinda blocked access to the website. The reasons how it get there remain unknown. Oh, and at the beginning of the article is a short list of related cases how Google takes control over the world. It's time for a tin foil hat πŸ‘
πŸ“„ The worst pieces of code I've ever seen. TL;DR:

* Think about your readers.
* Keep code consistent.
* The devil can be in dependencies, trust no one.
* Sometimes, it's better just replace all the module is it is too messy.
* Most of articles on writing a good code just cite or re-tell "Clean Code" or "Code complete", so just read these books.

As a side note, I hope the author doesn't read Reddit comments. There is a short summary:

* Author doesn't have any experience.
* Author is too emotional
* The problem is small and nothing important.
* The story is made up and never could happen.
* All these issues because it's JS.

Ugh, reddit...
πŸƒ gofakeit is a fake data generator for Go. Looks cool, it can generate a lot of things, like names, emails, emojis, quotes etc.

#golang
I made a thing.

πŸšπŸ”§ logit is a CLI tool that takes JSON logs from stdin and transfers them into google cloud, AWS, syslog, sentry, anywhere you want, or just nicely formats them.

It all started from idea that an application should have only business-logic in it. Later, I faced an application that has a lot of code to handle logging into GCP, which is unstable and hard to maintain. And at some point that application started to break everything because google cloud library uses grpc, networking, all that stuff that rest of the application isn't need. And it all started to go wrong because the network is unstable, grpc breaks multiprocessing, not every environment (for instance, CI) has access to google cloud and so on. In short, a lot of headache just to log things. So, if you don't want to get there, consider using logit or rsyslog.
πŸ“Š JetBrains has published The state of Go survey results. A few highlights:

+ China πŸ‡¨πŸ‡³ has the biggest ratio of Go devs, 16%. Then Japan πŸ‡―πŸ‡΅, Russia πŸ‡·πŸ‡Ί, Ukraine πŸ‡ΊπŸ‡¦.

+ Still isn't the most popular language but already in top 10.

+ Used mostly for web apps and CLI tools.

+ 82% of devs on go modules πŸŽ‰

+ most popular routers are gorilla/mux and stdlib

+ gin web framework is pretty popular, 46%. BTW, that means, more people use httprouter than the survey says (16%). Probably, they just don't know that it is in gin under the hood.

+ testify is used only by 13% of devs. IDK how others survive.

#golang
Trello Resources is a public trello board with tips on how to use trello, project, extensions, clients.
This code does not exist randomly pops snippets of C++ code either real (from debian packages source) or GPT-2-generated. Try to guess which one is real.

Hell is the code of other people πŸ‘€
πŸ“„ Bad software sent postal workers to jail, because no one wanted to admit it could be wrong. The program UK post office used for accounting has a bug that showed made it look like employees steal money. Lots of people paid from their own money, selling their homes, many end up in jail, one committed suicide. The post office knew about the bug but continued to accuse people.

There are lots of people to blame. In one side, the post office legal department that knew about the bug. They wouldn't pretend that all is correct if the bug would produce direct loses for the company, not random workers. On another side, the Post Office IT department getting a software into the work without testing and additional logs, and Fujitsu engineers not investing enough into testing the system.

The thing that bothers me the most is that the problem is already solved from early-medieval times. The solution is double-entry bookkeeping. Every change in the balance is tracked by at least 2 independent sides, so if there is an error, the records will produce different results, exposing the bug. Even more, since early telecom, we have redundant encoding to detect or even correct errors. For example, Hamming code. The same story but a bit closer to IT. Even simple logging would allow to reproduce transactions and find an error in accounting. But no, we will keep shit-coding even if human lives and/or huge money depend on it.
πŸ“„ The dispassionate developer. Warning: this post hurts. It's an essay on working for free (open source, podcasts, articles) to gain portfolio, about self-improvement and if companies should invest in it, about making technical decisions, aiming to be famous.
For a long time, I was looking for a good REPL for Go. I tried gore, gomacro, and a few similar solutions, but it all so clumsy. And so I found it.

gophernotes is a Go core for Jupyter Notebooks (I use it with Jupyter Lab, it's all the same). It misses documentation and type signature discovery (#173) but still better than everything else I tried so far.

#golang
I have raspberry pi where I store movies, podcasts, audiobooks, other media. How to stream all this media to other devices? FTP won't do because it requires to download the whole file first. So, there are 2 protocols: proprietary AirDrop used by Apple devices and DLNA used by everyone else. Apparently, we'll go with DLNA.

If you google how to set up a DLNA server, you'll find tons of articles on using MiniDLNA. It was hard as hell to set up: create a user, make a cache dir, write a config, write a server, troubleshoot why it doesn't work, troubleshoot why it doesn't see new files and so on. And after all that, at some point it just stopped working. Ugh...

And then I stumbled across dms. I've built a binary, sent it onto raspberry, run, and it just works! So, use dms.

git clone https://github.com/anacrolix/dms.git
cd dms
GOOS=linux GOARCH=arm GOARM=5 go build
scp ./dms root@raspberry:/usr/local/bin/

I noticed that when I have too many troubles with something, I search for an alternative written on Go because it just works. Partially, because of amazing tooling, amazing backward compatibility (I just compile everything I find with the latest Go release and never had any issues), and cross-compilation (like above we've built a binary for raspberry in one command). Partially, because of the language simplicity and the gophers' mindset. So, doesn't matter how the language itself is controversial and in some places immature, the tooling (first of all, CLI tools) is definitely benefits from it. See also: Why GitHub's CLI team switched from Ruby to Go.

#golang
πŸŽ₯ Agile Product Ownership in a Nutshell is the best intro into Agile, Product Management, basic terms, tasks, and techniques.
Today I learned that Amsterdam's administration has over 300 open source projects. Nothing interesting for me in the projects itself but I found a few short and simple but good style guides:

+ How to code for humans
+ How we code Python
+ How to write a README

Their example of flake8 config is a bit mess but otherwise it looks neat.
Two months ago, a hot discussion was started by a Go core developer in the "standard go project layout" repository:

this is not a standard Go project layout

The short version is that some people come into Go, look for a standard project layout (how to name files and how to group them), don't find an official one, search for something, find this one, and stick to it as the "best practice". The truth is that it is highly opinionated and not in any way is the only way to go. Since then, the author of the repository slightly updated the readme with a few small disclaimers but the issue is still open and discussion is still going.

I personally found this blog post a good answer to the topic:

Thoughts on how to structure Go code

TL;DR: name things after the domain terms, not the framework/language ones. I suppose, the motivation to write this post was the discussion above but the idea isn't new. The first time I've heard it from Bob Martin in his "Clean Architecture": Clean Code - Uncle Bob / Lesson 5.
🐍 folium is a Python library to render interactive maps right in Jupyter notebooks. Perfect for geo points visualization: easy to use, different styles and APIs, customizable markers.

#python
Finally got to posting my little open source projects on reddit. I looked at a few alternatives and cronnit.us is pretty good for scheduling posts. It doesn't support flairs yet but otherwise works fine. Especially I like that you can write everything in csv and then just import it.
πŸ”§ task is an amazing alternative to make. I use it all the time and it is 10 out of 10. Simple configuration, easy to install, supports dependencies between tasks, watch mode, skipping jobs when a file wasn't changed, shared configurations, simple templates. Another one beautiful CLI tool on Go. Give it a try.
πŸ“„ Crypto miners are killing free CI. The title pretty much says it. Inside also a few examples how exactly people exploit CIs. This is a good example of tragedy of commons. Some people for a relatively small amount of money spend a lot of resources, killing CI, world, raising prices to hardware etc. "This is why we can't have nice things". CI services are fighting back: Gitlab recently reduced their free quotas, GitHub Actions requires to manually allow CI runs for the first time contributors. It doesn't solve the problem but it is still something.
πŸƒπŸ“„ Increasing http.Server boilerplate is a guide on how to configure the default golang http server with good timeouts, secure ssl/tls, and systemd socket.

#golang
This media is not supported in your browser
VIEW IN TELEGRAM
Today I've got access to GitHub Copilot preview. This is the biggest thing of the year! I just started to use it, and it already writes code for me. It's not a garbage like tabnine that finds you StackOverflow snippets of sorting functions or whatever, oh no, copilot knows the context of the current file.