Preskoči na glavno vsebino

Objave

Prikaz objav, dodanih na avgust, 2022

Making a minimal web-application server #1

I expect a minimal web-application server to do two things: serve semi dynamic html pages provide an API interface to web-based client  Very simple HTTP-based API You can create your API-s in plethora of ways, but I mostly used a very simple strpc "standard" to do my API-s for the last 14 years. It's very easy to create and serve an API on the server side and it's very easy to call such API. Any programming language, or a bash shell can do it without any special libraries. I called it strpc (SoTinyRPC) back then. In short, a HTTP POST request to url like this: www.example.com/API?_r=util&_m=add with url-encoded arguments in a POST payload: a=100&b=11 ... would be an example of strpc call. _r - defines resource _m - defines method _f - (optional) would define response format (json, csv, html, ...) _x - (optional) would define explore mode (api self-documents itself) You can make a strpc call from your shell using Curl command, for example: curl -k \ -u $T

Full text search integration - Bleve

Bleve looks like a great full text search library for Go in par with Lucene of Solr and Elasticsearch fame. I will need something like full text search for our FAQ tool, so I tried integrating it. The very basic example works. Now I need to add functions to define custom IndexMappings, so we can index (and store) more structured data. Go with it's awesome tooling and even more awesome libraries really is a gift that keeps on giving!

Rye details - let the jack go

This is a second post in a series. Click here to read the first one . Modifier functions So, when we have to, how do we change values of words outside our current context? The answer is "Explicitly". Rye has a limited number of functions that change values of words in-place . They all end with exclamation mark. These functions currently are: change! - changes a value and returns true if value was changed inc! - increments a value in-place (like i++) append! - appends a value or a block of values to a series in-place purge! - higher order-like function that removes items from an series in-place Ordinary functions in Rye don't change their arguments in-place. Rebol's and Python's functions or methods are more mixed bags about this. Append in Rebol both adds a new value to the existing series and returns it. Python's list.append() returns None and modifies the existing list. Rye prefers expressions (not statements). Expression is something that returns a res

Rye details - context matters

disclaimer: this is alpha version, so things could still change I am writing a little bigger Rye script (a concrete Telegram bot). So I started thinking about organizing the code, and there, various small details of a language become important. This is a series of blog-posts where I try to define them more clearly.   First class value Scope (context) is a first class citizen in Rye. You can construct contexts in code, manipulate them, evaluate commands inside a specific context, define functions in and with specific contexts, use them to organize code, etc ... Context is a dictionary with an optional parent context.   Search at the parent's house If a word can't be found in the current context, Rye evaluator recursively searches the parent contexts to read a value. It's the same with functions. Ordinary functions have their own contexts that they evaluate in. It's parent context is a current context at evaluation time. Why is this needed? First, builtin and user funct