RSSAmplifier

Blog

Imagination

The beauty of imagination is that sometimes it makes things come true.

beauty-of-imagination.blogspot.comRSS feed ↗25 posts

Latest posts

Abusing yahi -a log based statistic tool à la awstats- to plot histograms/date series from CSV

Foreword what is yahi? Yahi is a python module that can installed with pip to make a all in one static html page aggregating the data from a web server. Actually, as shown with the parsing of auth.log in the documentation , it is pretty much a versatile log analyser based on regexp enabling various aggregation : by geo_ip, by histograms, chronological series. The demo is here . It pretty much is…

The true cost and code of parsing the integrality of (french speaking) bluesky ATPROTO in python

I was reading this news on ycombinator and was flabbergastered by the affirmation of people regarding the cost and complexity of parsing the integrality of bluesky. >I suspect that the cost of running AT proto servers/relays is prohibitive for smaller players compared to a Mastadon server selectively syndicating with a few peers, but I say this with only a vague understanding of the internals of…

The advantages of HTML as a data model over basic declarative ORM approach

Very often, backend devs don't want to write code. For this, we use one trick : derive HTML widget for presentation, database access, REST endpoints from ONE SOURCE of truth and we call it MODEL. A tradition, and I insist it's a conservative tradition, is to use a declarative model where we mad the truth of the model from python classes. By declaring a class we will implicitly declare it's SQL…

The crudest CRUD of them all : the smallest CRUD possible in 150 lines of python

Right now, I am on a never ending quest that requires me to think of building a full fledge MVC controller : an anti-jira tracker that would favours HARD CHECKED facts over wishful thinking. For this to begin, I am not really motivated in beginning with a full fledged MVC (Model View Controller) à la django because there is a lot of boilerplates and actions to do before a result. But, it has a lot…

Is chatgpt good at generating code for tuning a guitar ?

I was on a french speaking IRC chan bragging a tad about how I was doing a guitar tuner and paying attention to not fall into the pit of confusing precise and exact figures as a random computer engineer. Science he was a patented CS engineer he wanted to prove me that my new guitar tuner was useless since AI could come with a better less convoluted exact example in less lines of code than mine…

Tune your guitar with python

Today's exercice is just about turning a very nice example of the python soundevice module into something that works for me© to help me tune my bass. Long story short, I suck at tuning my instrument and just lost my tuner... This will require the python module soundevice and matplotlib . So in order to tune my guitar I indeed need a spectrosonogram that displays the frequencies captured in real…

Hello world part II : actually recoding print

In part I we explored the pre-requisite in order to code print : having a grasp on the framebuffer . Here, we are gonna deep inside one of the most overlooked object oriented abastraction : a file and actually print what we can of hello world in 100 lines of code. The file handler and the file descriptor These two abstractions are the low level and high level abstractions of the same thing : a…

Revisiting hello world : coding print from scratch part I

The « hello world » example is about standing on the shoulders of the giant and learn how to use function as tools. Most coders will use print during their whole life without actually coding it. However, it is a fun exercise. The framebuffer Given you are on linux you probably have a device named /dev/fb0 if you don't, you can't do this. The framebuffer is a view of the linear graphical memory…

3D ploter in python-tk with matplotlib.

Wishing to prove my assertion wrong on python-tk that piping python directly into tk/tcl interpreter is simple I tried to contradict myself by making a full GUI in matplotlib. Because, if you are not aware : matplotlib supports multi-target (Wx, Qt, gtk, tk, html) multi-platform widgets (Button, checkbox, text entry and so much more) . The challenge seemed pretty easy, to assemble an easy demo…

Writing an interactive tcl/tk interpreter proxy to wish in python

Maybe, you want to experiment small stuffs in wish (the tcl/tk) interpreter because of a post claiming that direct python tcl/tk is simpler in some simple cases than tkinter . As a convinced tkinter/FreeSimpleGUI user, I see this as an extreme claim that requires solid evidences. When all is said and done, wish interpreter is not interactive, and for testing simple stuff it can get annoying very…

Bidirectionnal python/tk by talking to tk interpreter back and forth

Last time I exposed an old way learned in physical labs to do C or python/tk like in the old days : by summoning a tcl/tk interpreter and piping commands to it. But what fun is it? It's funnier if the tcl/tk interperpreter talks back to python :D as an hommage to the 25 years awaited TK9 versions that solves a lot of unicode trouble. Beforehand, to make sense to the code a little warning is…

Simpler than PySimpleGUI and python tkinter: talking directly to tcl/tk

Well, the PySimpleGUI rug pulling of its licence reminded me how much dependencies are not a good thing. Even though FreeSimpleGUI is a good approach to simpler tk/tcl binding in python : we can do better , especially if your linux distro split the python package and you don't have access to tkinter. I am watching you debian, splitting ALL packages and breaking them including ... tcl from tk (what…

PySimpleGUI : surviving the rug pull of licence part I

I liked pySimpleGUI, because as a coder that likes tkinter (the Tk/Tcl bindings) and as a former tcl/tk coder I enoyed the syntaxic sugar that was avoiding all the boiler plates required to build the application. The main advantage was about not having to remember in wich order to make the pack and having to do the mainloop call. It was not a revolution, just a simple, elegant evolution, hence I…

Modern Computer Science is obscurantism disguised as science

Recently I decided to get back to the basics and question my use of classes/frameworks. I tried to find a definition of the word framework but weirdly this word is a tautology, no one knows what it is, but it refers at itself for something people use to get the work done through the use of external knowledge. But can you manipulate knowledge you do not understand? This word has been broadening so…

I still find with the examples used for teaching OOP counterproductive

After the stupid example with the taxonomy of the species/car/employees that makes you do a lot of inheritance one of the valid use case for OOP is 2D geometry : points & rectangles. This is the python example in wiki.python.org https://wiki.python.org/moin/PointsAndRectangles Don't worry, python is one of the many language doing this class. It is an actual use case for learning classes. 200 lines…

Querying complex unknown database with python

In my job, I sometimes have to deal with web applications that are pointing to half a dozen databases with an overall of more than 160 tables. Not to say it can be complex, but sometimes it is :) So I made a small script using 2 of my favourite technologies to deal with that: graphviz , and sqlsoup . Sqlsoup is a lesser known child of the great software that Mike Bayer (zzeek) made: sqlalchemy. I…

Using python to visualize randomness

Heard of randomness? What is random: something that given a serie of chronological events (happening after one another) whatever long the time serie is, we cannot predict the future. Two kinds of events are random; purely random events (stochastics) or mathematically deterministic equations that are so sensitive to initial conditions that they are very hard to predict. PRNG is the second kind of…

So I wrote a Proof of Concept language to address the problem of safe eval

I told fellow coders: «hey! I know a solution to the safe eval problem : it is right under my eyes». I think I can code it in less than 24 hours from scratch. It will support safe templating... Because That's the primary purpose for it. TL; DR: I was told my solution was overengineering because writing a language is so much efforts. Actually it took me less time to write a language without any…

Eval is even more really dangerous than you think

Preamble, I know about this excellent article: http://nedbatchelder.com/blog/201206/eval_really_is_dangerous.html I have a bigger objection than ned to use eval; python has potentially unsafe base types. I had this discussion with a guy at pycon about being able to safely process templates and do simple user defined formating operations without rolling your own home made language with data coming…

An opinionated versioning system based on mapping versions string to numbers in weird base

While we have a convention in python for numbering: http://legacy.python.org/dev/peps/pep-0440/ We can mostly say that version numbering thanks to "Windows 9" has shed an interesting spotlight on version comparaison. They are to tenants of version handling: - the naïves who consider versions has strings; - the picky people who consider version has a very dark grammar that requires to be parsed…

Perfect unusable code: or how to modelize code and distributivity

So let's speak of what and un/deterministic code really are. I am gonna prove that you can achieve nearly chaotic series of states with deterministic code \o/ Definitions: Deterministic: code is deterministic if the same input always yield the same output Chaotic : a time serie of value is considered chaotic if knowing of sample of t-n samples cannot make you able to predict the t+1 term. Turing…

Auto documenting and validating named arguments

In real life there are companies were keywords ( **kw ) are prohibited, and others where positional arguments can stack up as high as seven. Let's state the obvious concerning arguments: Human beings are flawed The positional arguments are fixed arguments. Some are mandatory others are optional (and are being set at function definition). Named arguments is a way to give arguments which are known…

Cross dressing on the internet and gender issues

So the actual buzz is gender issues http://www.kathrineswitzer.com/written_about.shtml I dare say it is a non problem. But before let me tell you my story as a cross dresser ... on the internet. Once upon a time I signed up for a famous dating site. And as advised by a friend, I was told to try with a fake feminine account. Well, let me tell you: it feels awkward. You are not at the right place.…

Using signal as wires?

Learning that signals were software interrupts in a book on Unix, I thought, « hey, let's try to play with signals in python since it is in stdlib!» The proposed example is not what one should really do with signals, it is just for the purpose of studying. Well remember this point it will prove important later: http://docs.python.org/dev/library/signal.html#signal.getsignal There is no way to…

My problem with Computer Science pseudo code

I remembered opening books of Computer Science to learn algorithm when I began. And my first reaction was: it seems unnecessarily complicated like maths, but I must be an idiot since I learnt physics . So 15 years later I reopened Introduction To Algorithms By Thomas H Cormen, Charles E Leiserson, Ronald L Rivest, Clifford Stein. And I decided to see if my experience in coding would help me…