blog.notmyidea.org/tag/python.html

130 lines
No EOL
8.7 KiB
HTML

<!DOCTYPE html>
<html lang="fr">
<head>
<title>
Python - Alexis Métaireau </title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet"
href="https://blog.notmyidea.org/theme/css/main.css?v2"
type="text/css" />
<link href="https://blog.notmyidea.org/feeds/all.atom.xml"
type="application/atom+xml"
rel="alternate"
title="Alexis Métaireau ATOM Feed" />
</head>
<body>
<div id="content">
<section id="links">
<ul>
<li>
<a class="main" href="/">Alexis Métaireau</a>
</li>
<li>
<a class=""
href="https://blog.notmyidea.org/journal/index.html">Journal</a>
</li>
<li>
<a class=""
href="https://blog.notmyidea.org/code/">Code, etc.</a>
</li>
<li>
<a class=""
href="https://blog.notmyidea.org/weeknotes/">Notes hebdo</a>
</li>
<li>
<a class=""
href="https://blog.notmyidea.org/lectures/">Lectures</a>
</li>
<li>
<a class=""
href="https://blog.notmyidea.org/projets.html">Projets</a>
</li>
</ul>
</section>
<h1>
Tag « Python » </h1>
<section class="section index">
<time datetime="2023-11-21T00:00:00+01:00">21 novembre 2023</time> <a class='tag' href="https://blog.notmyidea.org/tag/python.html">Python</a>
, <a class='tag' href="https://blog.notmyidea.org/tag/crdt.html">CRDT</a>
, <a class='tag' href="https://blog.notmyidea.org/tag/sync.html">Sync</a>
, <a class='tag' href="https://blog.notmyidea.org/tag/umap.html">uMap</a>
<h1>
<a href="https://blog.notmyidea.org/adding-real-time-collaboration-to-umap-second-week.html" id="page-title">Adding Real-Time Collaboration to uMap, second&nbsp;week</a>
</h1>
A heads-up on what I've been doing this week on uMap
</section>
<section class="section index">
<time datetime="2023-11-11T00:00:00+01:00">11 novembre 2023</time> <a class='tag' href="https://blog.notmyidea.org/tag/python.html">Python</a>
, <a class='tag' href="https://blog.notmyidea.org/tag/crdt.html">CRDT</a>
, <a class='tag' href="https://blog.notmyidea.org/tag/sync.html">Sync</a>
, <a class='tag' href="https://blog.notmyidea.org/tag/umap.html">uMap</a>
<h1>
<a href="https://blog.notmyidea.org/adding-real-time-collaboration-to-umap-first-week.html" id="page-title">Adding Real-Time Collaboration to uMap, first&nbsp;week</a>
</h1>
A heads-up on what I've been doing this week on uMap
</section>
<section class="section index">
<time datetime="2023-10-18T00:00:00+02:00">18 octobre 2023</time> <a class='tag' href="https://blog.notmyidea.org/tag/sql.html">SQL</a>
, <a class='tag' href="https://blog.notmyidea.org/tag/sqlalchemy.html">SQLAlchemy</a>
, <a class='tag' href="https://blog.notmyidea.org/tag/python.html">Python</a>
<h1>
<a href="https://blog.notmyidea.org/using-distinct-in-parent-child-relationships.html" id="page-title">Using <span class="caps">DISTINCT</span> in Parent-Child&nbsp;Relationships</a>
</h1>
How to get parent and most-recent child in a one-to-many relationship
</section>
<section class="section index">
<time datetime="2023-10-11T00:00:00+02:00">11 octobre 2023</time> <a class='tag' href="https://blog.notmyidea.org/tag/python.html">python</a>
, <a class='tag' href="https://blog.notmyidea.org/tag/conversion.html">conversion</a>
<h1>
<a href="https://blog.notmyidea.org/convert-string-to-duration.html" id="page-title">Convert string to&nbsp;duration</a>
</h1>
<p>I found myself wanting to convert a string to a duration (int), for some&nbsp;configuration.</p>
<p>Something you can call like&nbsp;this:</p>
<div class="highlight"><pre><span></span><code><span class="n">string_to_duration</span><span class="p">(</span><span class="s2">&quot;1d&quot;</span><span class="p">,</span> <span class="n">target</span><span class="o">=</span><span class="s2">&quot;days&quot;</span><span class="p">)</span>
<span class="n">string_to_duration</span><span class="p">(</span><span class="s2">&quot;1d&quot;</span><span class="p">,</span> <span class="n">target</span><span class="o">=</span><span class="s2">&quot;hours&quot;</span><span class="p">)</span>
<span class="n">string_to_duration</span><span class="p">(</span><span class="s2">&quot;3m&quot;</span><span class="p">,</span> <span class="n">target</span><span class="o">=</span><span class="s2">&quot;hours&quot;</span><span class="p">)</span>
<span class="n">string_to_duration</span><span class="p">(</span><span class="s2">&quot;3m&quot;</span><span class="p">,</span> <span class="n">target</span><span class="o">=</span><span class="s2">&quot;minutes&quot;</span><span class="p">)</span>
</code></pre></div>
<p>The code&nbsp;:</p>
<div class="highlight"><pre><span></span><code><span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">Literal</span>
<span class="k">def</span> <span class="nf">string_to_duration</span><span class="p">(</span><span class="n">value</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">target</span><span class="p">:</span> <span class="n">Literal</span><span class="p">[</span><span class="s2">&quot;days …</span></code></pre></div>
</section>
<section class="section index">
<time datetime="2023-09-27T00:00:00+02:00">27 septembre 2023</time> <a class='tag' href="https://blog.notmyidea.org/tag/python.html">python</a>
, <a class='tag' href="https://blog.notmyidea.org/tag/llm.html">llm</a>
, <a class='tag' href="https://blog.notmyidea.org/tag/bash.html">bash</a>
, <a class='tag' href="https://blog.notmyidea.org/tag/sqlite.html">sqlite</a>
<h1>
<a href="https://blog.notmyidea.org/llm-command-line-tips.html" id="page-title">llm command-line&nbsp;tips</a>
</h1>
<p>I&#8217;m using <a href="https://llm.datasette.io">llm</a> more and more, and today I had to find back prompts I used in the past. Here is a command I&#8217;ve been using, which allows me to filter the results based on what I want. It leverages <a href="https://sqlutils.datasette.io">sql-utils</a>, a cli tool which is able to …</p>
</section>
<section class="section index">
<time datetime="2023-08-17T00:00:00+02:00">17 août 2023</time> <a class='tag' href="https://blog.notmyidea.org/tag/python.html">python</a>
, <a class='tag' href="https://blog.notmyidea.org/tag/packaging.html">packaging</a>
, <a class='tag' href="https://blog.notmyidea.org/tag/zsh.html">zsh</a>
<h1>
<a href="https://blog.notmyidea.org/python-packaging-with-hatch-pipx-and-zsh-environment-variables.html" id="page-title">Python packaging with Hatch, pipx and Zsh environment&nbsp;variables</a>
</h1>
<p>It&#8217;s been a while I didn&#8217;t packaged something new. I recently remembered an old
package of mine that needed some attention :
<a href="https://gitlab.com/almet/debts">debts</a>. It&#8217;s now time to package it, so I
discovered <a href="https://hatch.pypa.io/">hatch</a></p>
<p>hatch new&nbsp;&#8212;init</p>
<p>This does the heavy-lifting for you, actually porting the <code>setup.py</code> files …</p>
</section>
<ul>
</ul>
</section>
<footer>
<a id="feed" href="/feeds/all.atom.xml">
<img alt="RSS Logo" src="/theme/rss.svg" />
</a>
</footer>
</div>
</body>
</html>