mirror of
https://github.com/almet/notmyidea.git
synced 2025-04-28 19:42:37 +02:00
130 lines
No EOL
8.7 KiB
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 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 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 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 duration</a>
|
|
</h1>
|
|
<p>I found myself wanting to convert a string to a duration (int), for some configuration.</p>
|
|
<p>Something you can call like this:</p>
|
|
<div class="highlight"><pre><span></span><code><span class="n">string_to_duration</span><span class="p">(</span><span class="s2">"1d"</span><span class="p">,</span> <span class="n">target</span><span class="o">=</span><span class="s2">"days"</span><span class="p">)</span>
|
|
<span class="n">string_to_duration</span><span class="p">(</span><span class="s2">"1d"</span><span class="p">,</span> <span class="n">target</span><span class="o">=</span><span class="s2">"hours"</span><span class="p">)</span>
|
|
<span class="n">string_to_duration</span><span class="p">(</span><span class="s2">"3m"</span><span class="p">,</span> <span class="n">target</span><span class="o">=</span><span class="s2">"hours"</span><span class="p">)</span>
|
|
<span class="n">string_to_duration</span><span class="p">(</span><span class="s2">"3m"</span><span class="p">,</span> <span class="n">target</span><span class="o">=</span><span class="s2">"minutes"</span><span class="p">)</span>
|
|
</code></pre></div>
|
|
|
|
<p>The code :</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">"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 tips</a>
|
|
</h1>
|
|
<p>I’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’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 variables</a>
|
|
</h1>
|
|
|
|
<p>It’s been a while I didn’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’s now time to package it, so I
|
|
discovered <a href="https://hatch.pypa.io/">hatch</a></p>
|
|
<p>hatch new —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> |