tag:blogger.com,1999:blog-84045097260099056332024-02-18T20:57:53.314+02:00Mind ReferenceSimplicity and elegance are unpopular because they require hard work and discipline to achieve and education to be appreciated. — Edsger W. DijkstraAndriy Kornatskyyhttp://www.blogger.com/profile/04890869628175359888noreply@blogger.comBlogger212125tag:blogger.com,1999:blog-8404509726009905633.post-27130424013462697982022-08-27T11:29:00.003+03:002022-08-27T11:30:36.165+03:00Debian: Clean up dpkg rc packages rc means that the package is not completely removed.
dpkg --list | grep "^rc" | cut -d " " -f 3 | \
xargs sudo dpkg --purge
Andriy Kornatskyyhttp://www.blogger.com/profile/04890869628175359888noreply@blogger.com0tag:blogger.com,1999:blog-8404509726009905633.post-79798110582435012142022-08-22T10:58:00.006+03:002022-08-22T11:00:54.276+03:00Debian: Possible missing firmwareIf you encounter issue like the following, you need to download/update firmware files.
W: Possible missing firmware /lib/firmware/i915
The script below recursively downloads all available firmware for i915, (as example) copies files related to kernel 5.19 and updates initramfs which should now be without warnings.
wget -r --no-parent https://anduin.linuxfromscratch.org/sources/Andriy Kornatskyyhttp://www.blogger.com/profile/04890869628175359888noreply@blogger.com0tag:blogger.com,1999:blog-8404509726009905633.post-58101241952894072732020-08-29T13:30:00.005+03:002020-08-29T14:06:04.405+03:00Wheezy Projects UpdateAll libraries related wheezy.web and wheezy.template have been recently migrated from bitbucket to github.
As a part of this migration there have been provided the following major benefits:
Established build process with travis-ci
Dependecy updates with dependabot
Integrated with covereall.io, 100% test coverage
Release process to pypi per tags with github actions
Replaced MakefileAndriy Kornatskyyhttp://www.blogger.com/profile/04890869628175359888noreply@blogger.com0tag:blogger.com,1999:blog-8404509726009905633.post-84540959316790448152020-08-01T15:00:00.007+03:002020-08-01T18:04:11.851+03:00Python ASGI CLICall ASGI Python application module from command line (without an application server), just like CURL. Interested?
You need to install asgi-cli package:
pip install asgi-cli
Usage
asgi-cli --help
usage: asgi-cli [-h] [--version] [-X COMMAND] [-I] [-H HEADER] [-d DATA] [-b]
[-n NUMBER] [-v]
app [url]
positional arguments:
app an Andriy Kornatskyyhttp://www.blogger.com/profile/04890869628175359888noreply@blogger.com0tag:blogger.com,1999:blog-8404509726009905633.post-45554131977496189792020-07-09T14:00:00.000+03:002020-07-09T15:17:17.445+03:00Authorization in Microservices LandscapeOverview
This article outlines a high-level design of authentication and
authorization options in Azure per a typical SPA use case interacting with
multiple microservices. Compares API gateway pattern versus a direct
client-to-API communication in microservices environment.
Use Case
A user should be able to request the following information:
User profile via Azure Graph API.
User documents Andriy Kornatskyyhttp://www.blogger.com/profile/04890869628175359888noreply@blogger.com0tag:blogger.com,1999:blog-8404509726009905633.post-23018774597705050152015-05-27T16:00:00.000+03:002015-05-27T18:48:25.413+03:00Asynchronous Python in Web ApplicationsAsynchronous or non-blocking IO allows worker to process other requests before current request has finished. That is possible in case a processing of current web request is related to an operation that is IO bound.
Prerequisites
What is important to understand about applicability of async pattern for IO bound operations, they must:
Utilize the same event loop, in this case worker's event Andriy Kornatskyyhttp://www.blogger.com/profile/04890869628175359888noreply@blogger.com2tag:blogger.com,1999:blog-8404509726009905633.post-40668038828974010612015-04-04T15:00:00.001+03:002015-04-04T15:06:59.233+03:00wheezy template: static website generatorSometimes you need a quick way to generate a static web site and put it up on a server. Here is how you can generate a static website with wheezy.template.
Let's suppose the following structure of the site:
content/
`- index.html
- main.html
shared/
`- master.html
snippet/
`- script.html
- widget.html
shared/master.html:
<!DOCTYPE html>
<html lang="en"&Andriy Kornatskyyhttp://www.blogger.com/profile/04890869628175359888noreply@blogger.com2tag:blogger.com,1999:blog-8404509726009905633.post-56077172321055619922014-10-29T17:00:00.000+02:002014-10-29T17:18:36.632+02:00wheezy web: RESTful API DesignIn this article we are going to explore a simple RESTful API created with wheezy.web framework. The demo implements a CRUD for tasks. Includes entity validation, content caching with dependencies and functional test cases. The source code is structured with well defined actors (you can read more about it here).
Design
The following convention is used with respect to operation, HTTP method (verbAndriy Kornatskyyhttp://www.blogger.com/profile/04890869628175359888noreply@blogger.com7tag:blogger.com,1999:blog-8404509726009905633.post-18271308838989526222014-08-04T20:30:00.000+03:002014-08-04T20:43:54.214+03:00wheezy web: deploy nginx + uwsgi + memcachedwheezy.web is a lightweight, high performance, high concurrency WSGI web framework with the key features to build modern, efficient web. Here we will deploy quick start with nginx, uwsgi and memcached to clean debian stable installation.
Before proceeding ensure you have quick start empty or quick start i18n up and running. We will use the following names for installation:
master - a user Andriy Kornatskyyhttp://www.blogger.com/profile/04890869628175359888noreply@blogger.com0tag:blogger.com,1999:blog-8404509726009905633.post-4252055734094689032014-03-15T07:30:00.000+02:002014-08-26T16:40:26.301+03:00memcached statistics statusHere is a "top" emulator for memcached statistics:
watch -n 5 "echo stats | socat unix-connect:/var/tmp/memcached.sock -"
The screen will be refreshed every 5 seconds and display results of memcached stats command.
Here is a sample output:
STAT pid 16779
STAT uptime 131077
STAT time 1394862592
STAT version 1.4.13
STAT libevent 2.0.19-stable
STAT pointer_size 64
STAT rusage_user 667.997747
Andriy Kornatskyyhttp://www.blogger.com/profile/04890869628175359888noreply@blogger.com0tag:blogger.com,1999:blog-8404509726009905633.post-83123446043803636192013-11-14T19:00:00.000+02:002013-11-15T12:49:05.694+02:00How to build Python deb package from sourceYou need a newer python version that is not available with the Debian package management system. You can compile it from source and install but that usually takes a lot of time. It would be better to build a deb instead and install it on as many machines as you need. You can use checkinstall for this.
apt-get install checkinstall
The instruction how to compile python from source is here. OnceAndriy Kornatskyyhttp://www.blogger.com/profile/04890869628175359888noreply@blogger.com2tag:blogger.com,1999:blog-8404509726009905633.post-25097049039128396332013-10-23T16:00:00.000+03:002014-03-26T20:04:37.113+02:00PostgreSQL Streaming Replication Hot StandbyStreaming replication allows a standby server to stay up-to-date with primary. The standby connects to the primary, which streams WAL records to the standby as they're generated.
Hot standby is the term used to describe the ability to connect to the server and run read-only queries.
This method of replication is completely transparent to the client, it doesn't require any changes to database, Andriy Kornatskyyhttp://www.blogger.com/profile/04890869628175359888noreply@blogger.com0tag:blogger.com,1999:blog-8404509726009905633.post-56117624612178774182013-10-13T14:00:00.000+03:002013-10-19T16:51:00.264+03:00Python HTTP Client APIThe modern web services expose public API to the world and JSON is de-facto standard in this communication. Here is a simple use case that integrates with buildbot public API.
Lets setup a virtual environment and install wheezy.core package:
virtualenv env
env/bin/easy_install wheezy.core
Launch python from virtual environment (env/bin/python) and try this:
>>> from wheezy.core.httpclient Andriy Kornatskyyhttp://www.blogger.com/profile/04890869628175359888noreply@blogger.com10tag:blogger.com,1999:blog-8404509726009905633.post-63205865573555460152013-10-08T17:00:00.000+03:002013-12-05T18:36:04.008+02:00Keep FreeBSD up to date with subversionThe freebsd ports tree is quite big and sometimes you need just few packages. You can do that with subversion sparse checkouts.
pkg_add -r subversion
Checkout only immediate top level. The list of svn mirrors is here.
svn checkout --depth=immediates \
http://svn0.eu.freebsd.org/ports/head /usr/ports
Update tree on as needed basis:
cd /usr/ports
# common
svn up --set-depth=infinity Mk Andriy Kornatskyyhttp://www.blogger.com/profile/04890869628175359888noreply@blogger.com0tag:blogger.com,1999:blog-8404509726009905633.post-1008225362819271492013-10-03T09:00:00.000+03:002013-10-04T08:45:02.121+03:00Convenient Remote Access with SSH ConfigIf you are working with a lot of remote ssh hosts it becomes hard to remember all that host specific information: username, ip address, identity file, non-standard port or local/remote port forwarding. ssh_config to rescue. Here is a sample to give you an idea (file ~/.ssh/config):
Compression yes
IdentityFile ~/.ssh/id_rsa
LogLevel ERROR
Port 22
Host h1
HostName 192.168.91.57
User Andriy Kornatskyyhttp://www.blogger.com/profile/04890869628175359888noreply@blogger.com0tag:blogger.com,1999:blog-8404509726009905633.post-62431639482207966492013-10-02T09:30:00.000+03:002013-10-02T09:59:29.678+03:00How to manage Git or Mercurial repositoriesManaging version control repositories can be a challenge in multi-user environment especially when simplification of user collaboration is your goal. There are usually two primary concerns while considering enterprise deployment for version control repositories: access control and safety of your data. Both are not directly addressed by version control itself, thus a sort of security facade is Andriy Kornatskyyhttp://www.blogger.com/profile/04890869628175359888noreply@blogger.com0tag:blogger.com,1999:blog-8404509726009905633.post-49957123503800106442013-09-10T18:00:00.000+03:002015-05-08T16:07:52.698+03:00wheezy web: ActorsThe application design of wheezy.web application consists of several actors, each playing its unifying role. Actors are grouped into packages, e.g. models, repository, service, web, content, tests, etc. These packages (or layers) shape a subsystem.
The diagram below visualizes relations between actors, boundaries between packages, subsystems and application, giving a better picture of whole:
Andriy Kornatskyyhttp://www.blogger.com/profile/04890869628175359888noreply@blogger.com1tag:blogger.com,1999:blog-8404509726009905633.post-12484930152089688682013-02-06T14:30:00.000+02:002013-02-06T18:36:58.667+02:00Thoughts on SQL vs ORMThe question of persistence implementation arise often. I found repository pattern very valuable due to separation of concerns, mediate between domain model and data source (mock, file, database, web service, etc). The database data source is somewhat specific since you can proceed with SQL functions or ORM. Here are some thoughts why you might prefer SQL functions over ORM in your next project:
Andriy Kornatskyyhttp://www.blogger.com/profile/04890869628175359888noreply@blogger.com25tag:blogger.com,1999:blog-8404509726009905633.post-2503653559469958382013-01-16T17:00:00.000+02:002013-01-16T17:25:21.564+02:00wheezy web: Quick Start i18n Projectwheezy.web is a lightweight, high performance, high concurrency WSGI web framework with the key features to build modern, efficient web. Here we will use an i18n (multilingual internationalization) project quick start to build a new project.
Download quickstart-i18n.zip and extract.
Rename extracted directory `quickstart-i18n` to meet your project name, e.g. mysite and open terminal in that Andriy Kornatskyyhttp://www.blogger.com/profile/04890869628175359888noreply@blogger.com6tag:blogger.com,1999:blog-8404509726009905633.post-69854472827869632132013-01-15T20:00:00.000+02:002013-01-15T20:11:32.305+02:00wheezy web: Quick Start Empty Projectwheezy.web is a lightweight, high performance, high concurrency WSGI web framework with the key features to build modern, efficient web. Here we will use an empty project quick start to build a new project.
Download quickstart-empty.zip and extract.
Rename extracted directory `quickstart-empty` to meet your project name, e.g. mysite and open terminal in that directory.
The empty project Andriy Kornatskyyhttp://www.blogger.com/profile/04890869628175359888noreply@blogger.com8tag:blogger.com,1999:blog-8404509726009905633.post-72739234906631029482012-12-11T21:30:00.000+02:002012-12-11T22:16:01.428+02:00How to create Jail in FreeBSD Operating system virtualization is the most effective way to utilize your system resources, jails let you setup isolated mini-systems. Jails are explains well in handbook however, from practical standpoint of view, the presented material is incomplete. Here we will setup few scrips that follow handbook's 'Application of Jails' article and enhance with few missing features. Let note preliminary Andriy Kornatskyyhttp://www.blogger.com/profile/04890869628175359888noreply@blogger.com2tag:blogger.com,1999:blog-8404509726009905633.post-51956129480618836432012-12-03T22:30:00.000+02:002014-06-12T13:36:19.487+03:00How to Send Mail in PythonThere are several use cases how you can send an email message using Python:
Plain Mail: an email message with plain text or html content.
Mail with Attachment: an email message with attached document.
Alternative Mail Views: you provide a convenient way to email recipients to view your message in plain text or html with optional rich content including images, etc.
Here is an example of Andriy Kornatskyyhttp://www.blogger.com/profile/04890869628175359888noreply@blogger.com1tag:blogger.com,1999:blog-8404509726009905633.post-91235400270140012162012-11-28T20:00:00.000+02:002012-11-28T20:20:54.657+02:00How to ship eggs with pyo files only in PythonThere is sometimes a need to ship python egg distribution with pyo files only. There is confusion using bdist_egg command since it doesn't have any options to do that; instead, you can instruct install_lib command. Here is what you need in setup.cfg file:
[install_lib]
compile = 0
optimize = 2
[bdist_egg]
exclude-source-files = 1
Issue the following command to build egg.
python setup.py -qAndriy Kornatskyyhttp://www.blogger.com/profile/04890869628175359888noreply@blogger.com0tag:blogger.com,1999:blog-8404509726009905633.post-9108268359359294672012-11-20T19:30:00.000+02:002013-11-24T18:01:54.074+02:00Python Web Frameworks Excessive ComplexityCyclomatic (or conditional) complexity is a metric used to indicate the complexity of a source code. In this post we will take a look at web frameworks source code and estimate excessive complexity, something that is beyond recommended level of 10 (threshold that points to the fact the source code is too complex and refactoring is suggested). Here is a list of web frameworks examined:
bottle
Andriy Kornatskyyhttp://www.blogger.com/profile/04890869628175359888noreply@blogger.com24tag:blogger.com,1999:blog-8404509726009905633.post-26925615289682483382012-11-15T21:00:00.000+02:002012-11-15T21:24:07.024+02:00Lazy Attribute in PythonA lazy attribute is an attribute that is calculated on demand and only once. Here we will see how you can use lazy attribute in your Python class. Setup environment before you proceed:
$ virtualenv env
$ env/bin/pip install wheezy.core
Let assume we need an attribute that is display name of some person
Place the following code snippet into some file and run it:
from wheezy.core.descriptorsAndriy Kornatskyyhttp://www.blogger.com/profile/04890869628175359888noreply@blogger.com2