Tu escritorio no hace esto
Integracion de google home con ... mi monitor? WHAT? (No, no es ningun extraño monitor smart, de hecho tiene una sola entrada HDMI)
Integracion de google home con ... mi monitor? WHAT? (No, no es ningun extraño monitor smart, de hecho tiene una sola entrada HDMI)
Este post es una lista de "proyectos" en los que estoy metiendo mano en estos tiempos. En otras épocas hubiera sido una lista de proyectos open source pero hoy en día es algo bastante más diverso.
NINGUNA de las cosas que van a ver a continuación es un proyecto "serio" o usable para algún ser humano que no sea yo (y a veces ni eso).
Convertí una raspberry pi 3 (o 4, ahora que sé que anda) en una compu all-in-one, con una pantalla de 8.8 pulgadas con resolucion 1920x480 (sí, es todo una combinación bastante ridícula)
Por algún motivo me hace acordar a algunos diseños de Olivetti (eso es algo bueno!) pic.twitter.com/trldKPQo8H
— Roberto H. Alsina (@ralsina) June 21, 2022
¡Está básicamente terminada! Podría dejarla como está y decir "listo", excepto que algunas de las partes de la carcaza no son ideales, y otras están hechas de dos o tres partes pegadas cuando deberían ser una sola.
¿Funciona? Oh sí.
Lo que me lleva al segundo proyecto ...
Después de varios meses de NO tener compu en casa me rendí y habilité una Thinkpad T430, que es un fierro, pero ...
Si Skynet mandaba a T430 en vez de T800, la película duraba 7 minutos, cero secuelas.
— Roberto H. Alsina (@ralsina) June 11, 2022
La pantalla es muy mala. 1384x768. ¡Tiene casi la misma cantidad de pixels que la pantalla ridícula de mi compu artesanal!
Así que con DOS computadoras con pantallas limitadas decidí hacer algo al respecto: elegir y usar software que no desperdicia tanto espacio en pantalla.
Estas son algunas de las elecciones, después de probar literalmente docenas de alternativas para cada cosa.
A su vez tratar de no usar Chrome implica ... donde están mis passwords?
Así que estoy migrando a pass
... parece estar andando bien, pero todavía
no traté de usarlo en el celular.
A su vez eso me llevó a ...
Sabés cuantas cosas salen si buscás "terminal" en Arch Linux? Incluyendo los paquetes del AUR? CIENTOS. Y probé una fracción grande de ellas.
En particular me encontré con algunos programas que son joyitas que nunca había oído nombrar.
tab-rs un multiplexer con un solo shortcut! de hecho armé un setup bastante extraño usándolo pero que me gusta mucho, que merece su propia descripción.
slides ... slides! Hechos con Markdown! En una terminal!
kiro ... mejor que nano.
Cuando haga mi notebook, voy a necesitar algo así. Tal vez. Quien sabe.
Lecciones de hoy:
— Roberto H. Alsina (@ralsina) May 31, 2022
1) la pi pico es más barata que un Arduino en MeLi así que ... Se usa.
2) el botón del joystick es, como esperaba, horriblemente flaky, se aprieta cuando lo moves, se suelta solo ... No sirve, al mouse hay que ponerle botones de verdad. pic.twitter.com/ofYWrAVbKo
Y eso me llevó a ...
Mucho mas lindo que programar Arduino, y cuestan lo mismo.
Y las posibilidades! Es posible hacer una conexión USB a mi mouse-joystick y configurar el firmware usando una interfaz de terminal!
Quiero un teclado que se remapee con una terminal serie USB!
No quiero HACERLO porque no quiero soldar todo eso pero ... y si lo hago con un Modelo M?
Y laburo full time. Y leo bastante (acá salen los libros que voy terminando)
Así que ando ocupado.
This post has only one objective. The next person who wants to run the tests on his Python project hosted on GitHub should be able to read it and get his tests running in 15 minutes or less using GitHub Actions.
So, concepts:
This assumes your project is "modern" in that it uses Poetry for dependency management and packaging. Of course maybe it doesn't, but don't worry, that only is important for maybe 3 lines of YAML.
So, Github Actions runs what's called "workflows". You define these in YAML files
in .github/workflows/whatever.yml
in your repo.
Here's the original version of the workflow we'll be studying today: test.yml
Don't worry about the project it's in, it really doesn't matter.
Now, let's examine that file bit by bit with explanations, so you can see if something needs changing for you.
name: CI
on:
[push, pull_request]
This workflow is called "CI" and it runs on every push to any branch.
jobs:
build:
strategy:
matrix:
python-version: ["3.10"]
runs-on: ubuntu-latest
Put all the versions of Python you want to test in python-versions
. This will run the tests in Ubuntu.
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Switch to Current Branch
run: git checkout ${{ env.BRANCH }}
Checkout this repo we are testing, go to the right branch.
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
Install whatever Python version we are testing.
- name: Install dependencies
run: |
pip install poetry
poetry install
Install whatever you need. Since this project uses poetry, I install poetry and then use poetry to setup things. If you are using something else, then change it accordingly.
- name: Run unit tests
run: |
poetry run pytest
Run the tests in whatever way they need to run. Again, since I am using poetry, this works. If you are not, then change this as needed.
So, put this file in .github/workflows/test.yml
, modify as needed. Commit. Push.
Now your tests run on every push.
And that's it. If your project uses poetry, then this workflow may work unchanged (except maybe for Python versions?)
Good luck!
Vi algo en twitter, eso me hizo googlear, llegué a https://obsproject.com/forum/threads/180-degree-live-fisheye-distortion-correction.100214/ y ... terminé haciendo este video, que explica como hacer dos cosas, una útil, la otra ... no tanto (aunque es medio parecido a algo que apple mostró en WWDC!)
Sospecho que la única manera de que haga videos es que sean cosas así, espontáneas, sin mucho laburo atrás porque estoy haciendo muchas cosas y no tengo tiempo.
Note: This is based on an old (2018) Quora answer.
If I asked you "How much hard drive space would be required for a Database representing every possible position in chess?" what would you answer?
Well, most answers go like this:
"Claude Shannon estimated there are 1043 positions in chess, which can be stored in ~32 bytes each, so it's something like 1044 bytes, and the observable universe has only 1080 atoms so it's something pretty large!"
To that I say phooey Shannon! It takes around 700 bytes if you want the fancy version.
Let's start by defining what the requested artifact is.
"A database representing every possible position in chess"
So, what is such a database's behaviour? I propose:
My proposed implementation will do the first 2 which I consider actual requirements, the 3rd being just a "nice to have". While it's not impossible to add, even my willingness to do stupid things has a limit.
So, limiting myself to the first two requirements, if I fulfill those then it's done, right? Because if the deliverable is correct, the rest is implementation details?
Let's implement it!
Welcome to Forsyth-Edwards notation (FEN for short). It's a wonderful thing that provides all the necessary information to restart a game.
I will use a hacked subset since all I want is the position (not things like "has white castled?" or "who is moving next?") but it's a trivial exercise to expand this database to do just that.
So, how does this database describe a position? A position is a list of pieces and their positions in a 8x8 board.
In the original FEN white pawn is identified as P and black pawn as p. I consider that an insult to the IETF who has adopted UTF-8 in RFC2777 (and also slightly racist), therefore I will use the proper glyphs: ♙ and ♟.
In fact, I will use ♙♘♗♖♕♔♟♞♝♜♛♚.
As for positions, since my database is small enough that data compression is pointless, let's just use a 64-character fixed-size string where each position is either a piece of a space meaning the square is empty.
So, a position is a string of length 64 where these are the only valid values: "♙♘♗♖♕♔♟♞♝♜♛♚ "
It's obvious that each position is equivalent to a 64-digit number in base 13, which means there are 196 053 476 430 761 073 330 659 760 423 566 015 424 403 280 004 115 787 589 590 963 842 248 960 possible positions.
That 64-digit number is the index key for each position (it's an optimal key, it can't be made any smaller!)
So here's the database core code, offered with no comments since it's barely 12 lines of code doing nothing weird:
def get_position(index):
def digit_to_char(digit):
return "♙♘♗♖♕♔♟♞♝♜♛♚ "[digit]
def str_base(number, base=13):
(d, m) = divmod(number, base)
if d:
result = str_base(d, base) + digit_to_char(m)
else:
result = digit_to_char(m)
return result
position = str_base(index).rjust(64)
return position
For convenience, here is a pretty printer for your boards:
def print_board(position):
print(" ABCDEFGH ")
for i in range(8):
print("%d%s%d" % (i, position[8 * (i) : 8 * (i + 1)], i))
print(" ABCDEFGH ")
Here you can see it in action (sadly asciinema butchers the alignment, it works properly in real life):
And here is the full source code:
def get_position(index):
def digit_to_char(digit):
return "♙♘♗♖♕♔♟♞♝♜♛♚ "[digit]
def str_base(number, base=13):
(d, m) = divmod(number, base)
if d:
result = str_base(d, base) + digit_to_char(m)
else:
result = digit_to_char(m)
return result
position = str_base(index).rjust(64)
return position
def print_board(position):
print(" ABCDEFGH ")
for i in range(8):
print("%d%s%d" % (i, position[8 * (i) : 8 * (i + 1)], i))
print(" ABCDEFGH ")
if __name__ == "__main__":
import sys
print_board(get_position(int(sys.argv[1])))
Please notice that this database also covers all alternative chess variants where extra pieces are given or removed as handicap.
There is no step 3.