<title of image as alt>

Carlo Bertini’s personal website

WaYdotNET : Web Developer/ Devops and problem solver adept at programming
zen-generator

Zen Generator: A bidirectional Python code generator

🚀 Introduzione Zen Generator è un tool open-source progettato per semplificare la generazione di codice Python a partire da specifiche AsyncAPI e per ottenere specifiche AsyncAPI da codice Python esistente. Il suo obiettivo è automatizzare la creazione di componenti per architetture a microservizi basate su messaggistica, riducendo il lavoro manuale e garantendo coerenza tra implementazione e documentazione. 📌 Cos’è AsyncAPI? AsyncAPI è una specifica open-source pensata per definire e documentare API asincrone, analogamente a quanto fa OpenAPI per le API REST. ...

March 13, 2025 Â· 4 min Â· Carlo Bertini [WaYdotNET]
#automation #bidirectional programming #code generation #programming tools. #Python #software development #Zen Generator

Zero waste: trucchi per riciclare (la memoria) meglio

Talk Qui potete vedere il talk che ho fatto insieme a Francesco Panico durante il Pycon.it 2024 PDF Previous Next     / [pdf] View the PDF file here. Elevator pitch Un talk sul riciclaggio? In un certo senso si! Parleremo infatti del peggior spreco per un dev: quello di memoria. Esploreremo il funzionamento del GC e gli algoritmi alla base del suo funzionamento. Impareremo alcune tecniche per analizzare e ridurre il consumo di memoria del nostro codice. ...

June 16, 2024 Â· 4 min Â· Carlo Bertini [WaYdotNET]
#Best Practice #python #Performance #CPython #Debugging #Code Analysis
Separare l’interfaccia dall’implementazione, una delle regole d’oro dell’OOP. Come applicarla in un linguaggio tipizzato dinamicamente come Python? Un’introduzione allo Structural Subtyping e all’utilizzo dei Protocol

Coding to interfaces: Structural Subtyping in Python

Talk Qui potete vedere il talk che ho fatto insieme a Francesco Panico durante il Pycon.it 2023 PDF Previous Next     / [pdf] View the PDF file here. Elevator pitch Separare l’interfaccia dall’implementazione, una delle regole d’oro dell’OOP. Come applicarla in un linguaggio tipizzato dinamicamente come Python? Un’introduzione allo Structural Subtyping e all’utilizzo dei Protocol ...

June 15, 2024 Â· 3 min Â· Carlo Bertini [WaYdotNET]
#Best Practice #python #Clean Code #Static Analysis #Type-Hinting

Use Sqlite Instead of Db in Memory to Verify Foreign Key

How to check check Constrains in test ? Todo: i need to insert some description :D When we need to check check, we need to use Sqlite provider When use providers: using System; using System.Threading.Tasks; using Bogus; using Microsoft.EntityFrameworkCore; using TrackingConsumerService.Data; using TrackingConsumerService.Data.Models; using Xunit; namespace TrackingConsumerService.Test.Fixture { public class DbContextFixture : IDisposable { public MyDbContest DbContext { get; private set; } public DbContextFixture() { var options = new DbContextOptionsBuilder<MyDbContest>() .UseSqlite("Filename=:memory:") .Options; DbContext = new MyDbContest(options); DbContext.Database.OpenConnection(); DbContext.Database.EnsureCreated(); } public void Dispose() { DbContext?.Database?.CloseConnection(); DbContext?.Dispose(); } } [CollectionDefinition("DbContext")] public class InMemoryDbContextFixtureCollection : ICollectionFixture<DbContextFixture> { // This class has no code, and is never created. Its purpose is simply // to be the place to apply [CollectionDefinition] and all the // ICollectionFixture<> interfaces. } } todo: add test example ...

June 15, 2024 Â· 1 min Â· Carlo Bertini [WaYdotNET]
#csharp #dotnet

Use Padrino and sprockets with sprockets-helpers

Thanks to @arthur_chiu and his post on how to integrate sprockets in Padrino with sprockets-helpers, i’ve create my version :D:D:D:D 1) Create padrino-sprockets in config/sprockets.rb module Padrino::Sprockets def self.registered(base) base.set :sprockets, ::Sprockets::Environment.new(Padrino.root) # Add folder base.sprockets.append_path 'assets/javascripts' base.sprockets.append_path 'assets/stylesheets' base.sprockets.append_path 'assets/images' base.set :digest_assets, true # compress file if PADRINO_ENV == 'development' base.sprockets.js_compressor = Uglifier.new(mangle: true) base.sprockets.css_compressor = YUI::CssCompressor.new end # sprockets-helpers base.helpers Sprockets::Helpers # We can configure \`sprockets-helpers\` to find the correct assets for us. Sprockets::Helpers.configure do |config| manifest_path = File.join(Padrino.root,'public','assets','manifest.json') config.environment = base.sprockets config.prefix = '/assets' config.manifest = Sprockets::Manifest.new(base.sprockets, manifest_path) config.digest = true config.public\_path = base.public\_folder end # call sprockets :D if PADRINO_ENV == 'development' base.get '/assets/*splat' do env\['PATH_INFO'\].gsub!(%r{A/?assets}, '') settings.sprockets.call(env) end end end end In this file you need add all your asset's folder.. 2) Load this file at startup application: **config/boot.rb** \# after this line Bundler.require(:default, PADRINO_ENV) \# add this require Padrino.root('config/sprockets') 1) register Padrino::Sprockets in your application Module Foo class App < Padrino::Application register Padrino::Sprockets end end 4) Use js,css sprockets version in you layout, es: **layout.slim** link href= stylesheet_path('app') media="screen" type="text/css" rel="stylesheet" instead = stylesheet\_link\_tag :app 5) Use Rakefile to create asstes to pre-compilation :D:D PADRINO\_ENV = ENV\['PADRINO\_ENV'\] ||= ENV\['RACK\_ENV'\] ||= 'development' unless defined?(PADRINO\_ENV) require 'bundler/setup' require 'padrino-core/cli/rake' require 'sprockets/../rake/sprocketstask' Bundler.require(PADRINO_ENV) require File.expand\_path("../config/boot.rb", \_\_FILE__) PadrinoTasks.use(:database) PadrinoTasks.use(:minirecord) PadrinoTasks.init \# Use fake application module FakeSprock class App < Padrino::Application register Padrino::Sprockets end end SPROCKETS = FakeSprock::App.sprockets \# or your real app name \# SPROCKETS = RealAppName::App.sprockets Rake::SprocketsTask.new do |t| manifest_path = File.join(Padrino.root,'public','assets') t.environment = SPROCKETS t.output = File.join(Padrino.root,'public','assets') t.manifest = Sprockets::Manifest.new(SPROCKETS, manifest_path) t.assets = %w\[app.js app.css *.png *.gif *.jpg\] end and call it with ...

June 14, 2024 Â· 2 min Â· Carlo Bertini [WaYdotNET]
#ruby

Padrino 0.11.0 Released - Padrino Lives!

The Padrino team is very pleased to finally be able to announce the 0.11.0 release of the Padrino Framework! We have been working on this release for almost a year now and we have had dozens of contributors helping us stabilize Padrino. We know our release cycle got out whack and this version took too long to release. We all take accountability for that and will work to pick up release momentum and release patch and minor versions more often. Since our 0.10.7 release, development on Padrino has been moving forward very actively and as such this is probably our biggest release in terms of code modified and issues resolved that we have had in years. We are very proud of this release which includes several major improvements: 1) Totally Redesigned Admin 2) New brand identity on the way 3) Upgraded Sinatra and http_router 4) CSRF Form Protection 5) ActiveSupport::SafeBuffer 6) New Rakefile format 7) Gemified Apps 8) Performance Tools 9) App Namespacing 10) Project Modules 11) Optimized Reloader http://www.padrinorb.com/blog/padrino-0-11-0-released-padrino-lives ...

March 23, 2013 Â· 1 min Â· Carlo Bertini [WaYdotNET]
#ruby

Usage ImageSorcery with CarrierWave by gem

CarrierWave::ImageSorcery https://github.com/WaYdotNET/carrierwave-imagesorcery Additional processing to use ImageSorcery into CarrierWave. Installation Add this line to your application’s Gemfile: gem ‘carrierwave-imagesorcery’ And then execute: $ bundle Or install it yourself as: $ gem install carrierwave-imagesorcery Usage To use those, you should include specified module (ImageSorcery) into your uploader and use processors: class AvatarUploader < CarrierWave::Uploader::Base include CarrierWave::ImageSorcery ….. end Method implemented convert dimensions resize_to_limit resize_to_fit resize_to_fill resize_and_pad Example class Uploader < CarrierWave::Uploader::Base # Image manipulator library: include CarrierWave::ImageSorcery ...

August 22, 2012 Â· 2 min Â· Carlo Bertini [WaYdotNET]
#AiS #ruby

The library is a simple API in Ruby for Microsoft Translator V2

MsTranslate The library is a simple API in Ruby for Microsoft Translator V2 The Microsoft Translator services can be used in web or client applications to perform language translation operations. The services support users who are not familiar with the default language of a page or application, or those desiring to communicate with people of a different language group. Installation Add this line to your application’s Gemfile: gem ‘ms_translate’ And then execute: ...

March 13, 2012 Â· 2 min Â· Carlo Bertini [WaYdotNET]
#AiS #gems #github #ms_transalte #OpenOttica #ruby #ruby #rubygems #tips #traduttore #translate #wrapper

Padrino-admin Twitter Bootstrap v2.0 is ready

(Padrino Admin TwitterBootstrap 2.0) Padrino-Modal: rack-flash and delete function into modal :D highlights error field tof helper: Automatic replace true or false with relative image (list.slim and list.haml) Breadcrumbs Automatic time_ago_in_words when column model is created_at or updated_at Migrate function for MiniRecord Padrino-Modal All result from rack-flash and delete request, now is automatic insert into modal javascript plugin highlights error field tof_helper Automatic replace true or false with relative image (list.slim and list.haml) ...

February 2, 2012 Â· 1 min Â· Carlo Bertini [WaYdotNET]
#AiS #bootsrtap #github #OpenOttica #padrino #padrino-admin #padrinorb #ruby #ruby #twitter #twitter bootstrap

Padrino Admin another new layout (based on Twitter Bootstrap v2.0-wip)

http://glowing-leaf-7114.heroku.com/admin/ user: test@padrinorb.com pass: test PLEASE DON’T CHANGE LOGIN/PASSWORD Additional feature: ✔ Padrino-Modal: rack-flash and delete function into modal :D ✔ highlights error field ✔ tof helper: Automatic replace true or false with relative image (list.slim and list.haml) ✔ Breadcrumbs ✔ Automatic time_ago_in_words when column model is created_at or updated_at ✔ Migrate function for MiniRecord clone my repository and enjoy :D https://github.com/WaYdotNET/padrino-framework See the code and comment please !!!!

January 30, 2012 Â· 1 min Â· Carlo Bertini [WaYdotNET]
#AiS #github #OpenOttica #padrino #padrino-admin #padrinorb #ruby #ruby #twitter #twtitter-bootstrap #waydotnet