Saturday, December 30, 2023

Python vs. GoLang : Easy vs. Simple

 Python is Easy. Go is Simple. Simple != Easy. · Preslav Rachev

"The most pragmatic solution we have found in our work is combining the powers of Python’s easiness and Go’s simplicity. For us, Python is a great prototyping playground.

Once the rough Django proof-of-concept starts resembling a product, we identify how much of it can be rewritten in Go. Since the Django application has already defined the structure of the database and how data models look, writing the Go code that steps up on top of it is quite easy."



Friday, December 29, 2023

AI: custom LLM: YugoGPT-chat

yugochat.com/en

yugo or golf?

by Aleksa Gordić @ LinkedIn

x ETF BG, Microsoft, Google DeepMind

the model outperformed Mistral & LLaMA 2 for Serbian, Bosnian, Croatian, and Montenegrin and now you can play with it in our playground app.


Runa AI – Artificial Intelligence for your Language.

Zip API: append

JavaScript

jszip - npm

javascript - How to Zip files using jszip library - Stack Overflow

Stuk/jszip: Create, read and edit .zip files with Javascript @GitHub

A library for creating, reading and editing .zip files with JavaScript, with a lovely and simple API.

See https://stuk.github.io/jszip for all the documentation.

dual-licensed. You may use it under the MIT license or the GPLv3

5 M downloads / week


alternative lib, less features?

cthackers/adm-zip: A Javascript implementation of zip for nodejs. Allows user to create or extract zip files both in memory or to/from disk @GitHub

The library allows you to:

  • decompress zip files directly to disk or in memory buffers
  • compress files and store them to disk in .zip format or in compressed buffers
  • update content of/add new/delete files from an existing .zip

adm-zip - npm

MIT, 3.1M downloads/week

ADM ZIP · cthackers/adm-zip Wiki

node.js - How to add my file to an existing zip-folder using node-js in lambda? - Stack Overflow


Python 

Python's zipfile: Manipulate Your ZIP Files Efficiently – Real Python




SolidJS vs React; useSignal() vs useState()

Solid.js is very similar to React, but fundamentally different: 
no shadow dom, less state complexity

Getting Started with SolidJS - YouTube by Academind / Max S.
SolidJS made "Signals" one of the most important frontend JS framework trends you can find right now! 

solidjs.com
Simple and performant reactivity for building user interfaces.


solidjs/solid: A declarative, efficient, and flexible JavaScript library for building user interfaces. @GitHub


Websites using SolidJS - Wappalyzer
OpenAI is using SolidJS


useSignal?

Solid.js and many other tools implement a new way for managing "app state"


The key difference between Signals and State is that Signals return a getter and a setter, 
whereas non-reactive systems return a value (and a setter).

Why is returning a getter (function) better than returning a value?
Because by returning the getter, you can separate the passing of the state-reference from a reading of the state-value.




Why are people SO obsessed with useSignal()? - YouTube
SolidJS, Qwik.js, Preact.js, Angular


by Misko Hevery CTO at Builder.io, Creator of Angular & Qwik





even latest Angular supports useSignal!






Wednesday, December 27, 2023

Neon: serverless Postgres database

neondatabase/neon: Neon: Serverless Postgres. We separated storage and compute to offer autoscaling, branching, and bottomless storage. @GitHub

"Neon is a serverless open-source alternative to AWS Aurora Postgres. It separates storage and compute and substitutes the PostgreSQL storage layer by redistributing data across a cluster of nodes."

db that supports GitHub branches!

Apache license + online service available; Rust + C + Python

Neon Free Tier - Neon Docs




Tuesday, December 26, 2023

SpaceX Falcon 9 "sinks"

 Historic SpaceX Falcon 9 booster topples over and is lost at sea – Spaceflight Now

This particular booster, tail number B1058, was coming back from its record-breaking 19th mission when it had its fatal fall. ...The booster made a successful landing... succumbed to “high winds and waves.”




EV: Kia Electric Truck

 The 2026 Kia Electric Truck: Everything You Need to Know

Kia's PR release noted, "in the United States, where mid-sized SUVs and pickups are popular, electric versions of these models will be produced locally from 2024."

Building the truck in America would allow Kia to avoid the chicken tax for the truck and let it to be eligible for the federal EV tax credit.






"Chroma": Vector Database for ML/AI

podcast: The Cloudcast: Intro to Vector Databases


chroma-core/chroma: the AI-native open-source embedding database @GitHub
Apache license; Go + Python + Jupyter + TypeScript

pip install chromadb # python client
# for javascript, npm install chromadb!
# for client-server mode, chroma run --path /chroma_db_path

Embeddings?

What are embeddings?

  • Read the guide from OpenAI
  • Literal: Embedding something turns it from image/text/audio into a list of numbers. 🖼️ or 📄 => [1.2, 2.1, ....]. This process makes documents "understandable" to a machine learning model.
  • By analogy: An embedding represents the essence of a document. This enables documents and queries with the same essence to be "near" each other and therefore easy to find.
  • Technical: An embedding is the latent-space position of a document at a layer of a deep neural network. For models trained specifically to embed data, this is the last layer.
  • A small example: If you search your photos for "famous bridge in San Francisco". By embedding this query and comparing it to the embeddings of your photos and their metadata - it should return photos of the Golden Gate Bridge.

Embeddings databases (also known as vector databases) store embeddings and allow you to search by nearest neighbors rather than by substrings like a traditional database. By default, Chroma uses Sentence Transformers to embed for you but you can also use OpenAI embeddings, Cohere (multilingual) embeddings, or your own.


tryChroma.com (+$18M investment)

"the AI-native open-source embedding database"

Python AST <=> JSON

Python language comes with "batteries included", many useful modules / libraries

ast — Abstract Syntax Trees — Python 3.12.1 documentation

ast2json · PyPI

json2ast · PyPI

Here is an example that does full "round-trip" 
python code text => ast => json => ast => code text

import ast
import json
from ast2json import ast2json
from json2ast import json2ast

code_text="""
def hello(name):
   print("Hello ", name) hello('World')
"""
print('=== code text ===\n', code_text)

ast_from_code=ast.parse(code_text)
print('=== ast from code ===\n', ast.dump(ast_from_code, indent=4))

json_from_ast = ast2json(ast_from_code)
print('=== json from ast ===\n', json.dumps(json_from_ast, indent=2))

ast_from_json = json2ast(json_from_ast)
print('=== ast from json ===\n', ast.dump(ast_from_json, indent=4))

code_from_ast = ast.unparse(ast_from_json)
print('=== code from ast ===\n', code_from_ast)

interesting: after "round-trip" double quotes from "Hello" from print statement are converted to single quotes. Python "likes" single quotes more :)


Saturday, December 23, 2023

Go AST <=> JSON

Go lang compiler is written in Go, so parsing source code and AST are available as packages.
Getting AST is "one line of code"
But the AST is using recursive pointers, and serializing to JSON requires some extra effort.

Here is a useful tool for that:

asty-org/asty: Converts golang AST to JSON and JSON to AST @GitHub

AST → JSON | JSON → AST

Marshals golang AST into JSON and unmarshals it back from JSON.

It allows building pattern matching, statistical analysis, language transformation, search/data-mine/anything algorithms for golang with any other language (I like to do it with python. Check out asty-python)


Demo:

Go-to-AST-JSON: Convert Go to AST-JSON instantly


how it works

Analyzing AST in Go with JSON tools - DEV Community


Basic AST Traversal in Go - zupzup


Here is a minimalistic example of using Go AST

package main

import (
    "fmt"
    "go/ast"
    "go/parser"
    "go/token"
    "os"
)

func main() {
    if len(os.Args) < 2 {
        fmt.Println("Please provide a filename as a command line argument.")
        os.Exit(1)
    }
    filename := os.Args[1]

    // read source from text file
    data, err := os.ReadFile(filename)
    if err != nil {
        fmt.Println("Error reading file:", err)
        os.Exit(1)
    }
    src := string(data)
    fmt.Println(src)

    // Initialize a new token file set
    fset := token.NewFileSet()
    // Parse the source code
    f, err := parser.ParseFile(fset, "", src, parser.ParseComments)
    if err != nil {
        fmt.Println(err)
        return
    }
    // Print the AST
    ast.Print(fset, f)
}

Abstract syntax tree - Wikipedia

An abstract syntax tree (AST) is a data structure used in computer science to represent the structure of a program or code snippet. It is a tree representation of the abstract syntactic structure of text (often source code) written in a formal language. Each node of the tree denotes a construct occurring in the text. It is sometimes called just a syntax tree.

AI + React: v0 by Vercel, with Tailwind CSS

v0 by Vercel

Introducing v0: Generative UI - YouTube

v0: Vercel's AI-Powered React Component Creator
The AI-powered v0 looked fascinating on its release, but has been stuck behind a waitlist till now. Vercel has dropped that list, opening it to all users. Even Larry David would admit it's pretty, pretty good.

Announcing v0: Generative UI – Vercel

Here’s how it works:Describe the interface you want to build
v0 produces code using open-source tools like React, Tailwind CSS, and Shadcn UI
Select an iteration and keep editing in v0
When you're ready, copy and paste that code into your app and develop from there

v0 FAQ

v0 is a generative user interface system by Vercel powered by AI. It generates copy-and-paste friendly React code based on shadcn/ui and Tailwind CSS that people can use in their projects.




Friday, December 22, 2023

HTMX: HTML First

HTML First

HTML First is a set of principles that aims to make building web software easierfaster, more inclusive, and more maintainable by...

  1. Leveraging the default capabilities of modern web browsers.
  2. Leveraging the extreme simplicity of HTML's attribute syntax.
  3. Leveraging the web's ViewSource affordance.
</> htmx ~ Locality of Behaviour (LoB)

HTML First code snippet library.

HTMX.org on the ViewSource affordance

Tesla open source @GitHub

 Tesla, Inc. @GitHub

teslamotors/fleet-telemetry 
Go

Fleet Telemetry is a server reference implementation for Tesla's telemetry protocol. Owners can allow registered applications to receive telemetry securely and directly from their vehicles. This reference implementation can be used by individual owners as is or by fleet operators who can extend it to aggregate data accross their fleet.

helm-charts/charts/fleet-telemetry at main · teslamotors/helm-charts

for Kubernetes deployment of telemetry


Swift, Kotlin, TypeScript...




Thursday, December 21, 2023

architecture: Las Vegas Sphere

Sphere (venue) - Wikipedia

The venue's exterior also features 580,000 sq ft (54,000 m2) of LED displays.
Sphere measures 366 feet (112 m) high and 516 feet (157 m) wide.

Winter solstice 2023; WebGL Earth; Vivaldi

Vivaldi Four Seasons: Winter (L'Inverno), original version. Freivogel & Voices of Music RV 297 4K - YouTube   Vivaldi Winter! The complete concerto performed on original instruments.


Winter solstice - Wikipedia

a shortest day of the year on northern Earth hemisphere, 
and start of winter.


WebGL Earth - 3D digital globe for web and mobile devices



webglearth/webglearth2: WebGL Earth 2 - the source code of the project @GitHub

Open-source virtual planet web application running in any web browser with support for WebGL HTML5 standard. Mobile devices such as iPhone, iPad or Android based mobile phones are going to be supported too.

CesiumGS/cesium: An open-source JavaScript library for world-class 3D globes and maps :earth_americas: @GitHub


Google Earth



LanceDB: vector database, search, AI

podcast

Open source, on-disk vector search with LanceDB featuring Chang She, CEO and co-founder of LanceDB (Practical AI #250) |> Changelog

LanceDB




Rust + Python + TypeScript

Apache






A vector database is a type of database that stores data as high-dimensional vectors, which are mathematical representations of features or attributes. Each vector has a certain number of dimensions, which can range from tens to thousands, depending on the complexity and granularity of the data. The vectors are usually generated by applying some kind of transformation or embedding function to the raw data, such as text, images, audio, video, and others. The embedding function can be based on various methods, such as machine learning models, word embeddings, feature extraction algorithms.

The main advantage of a vector database is that it allows for fast and accurate similarity search and retrieval of data based on their vector distance or similarity. This means that instead of using traditional methods of querying databases based on exact matches or predefined criteria, you can use a vector database to find the most similar or relevant data based on their semantic or contextual meaning.

Tuesday, December 19, 2023

AI Music Generator - SOUNDRAW.io

 AI Music Generator - SOUNDRAW

"Simply choose the mood, the genre and the length. Our AI will generate beautiful songs for you." 

examples



Sunday, December 17, 2023

code katas @ GitHub

gamontal/awesome-katas: A curated list of code katas @GitHub

A kata, or code kata, is defined as an exercise in programming which helps hone your skills through practice and repetition. Dave Thomas @pragdave, started this movement for programming.




Kata is a Japanese word ( or ) meaning "form". It refers to a detailed choreographed pattern of martial arts movements made to be practised alone. It can also be reviewed within groups and in unison when training. It is practised in Japanese martial arts as a way to memorize and perfect the movements being executed.