<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:googleplay="http://www.google.com/schemas/play-podcasts/1.0"><channel><title><![CDATA[Moustacios.Dev]]></title><description><![CDATA[Opinii și noutăți din tehnologie plus mini-tutoriale de programare]]></description><link>https://stack.moustacios.dev</link><image><url>https://substackcdn.com/image/fetch/$s_!FcUh!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa101a089-db77-42fc-b6b4-790342ebc7f2_764x764.png</url><title>Moustacios.Dev</title><link>https://stack.moustacios.dev</link></image><generator>Substack</generator><lastBuildDate>Tue, 07 Apr 2026 12:15:41 GMT</lastBuildDate><atom:link href="https://stack.moustacios.dev/feed" rel="self" type="application/rss+xml"/><copyright><![CDATA[Moustacios.dev]]></copyright><language><![CDATA[en]]></language><webMaster><![CDATA[moustacios@substack.com]]></webMaster><itunes:owner><itunes:email><![CDATA[moustacios@substack.com]]></itunes:email><itunes:name><![CDATA[adrian7]]></itunes:name></itunes:owner><itunes:author><![CDATA[adrian7]]></itunes:author><googleplay:owner><![CDATA[moustacios@substack.com]]></googleplay:owner><googleplay:email><![CDATA[moustacios@substack.com]]></googleplay:email><googleplay:author><![CDATA[adrian7]]></googleplay:author><itunes:block><![CDATA[Yes]]></itunes:block><item><title><![CDATA[NodeJS supportă typescript implicit]]></title><description><![CDATA[versiunea 23 renun&#539;&#259; la flag-ul --experimental-strip-types]]></description><link>https://stack.moustacios.dev/p/nodejs-supporta-typescript-implicit</link><guid isPermaLink="false">https://stack.moustacios.dev/p/nodejs-supporta-typescript-implicit</guid><dc:creator><![CDATA[Teo cel Mustăcios]]></dc:creator><pubDate>Tue, 14 Jan 2025 05:25:37 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!tjyZ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8cf5793-4566-4cad-99dc-69c5b97b2849_2494x638.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!tjyZ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8cf5793-4566-4cad-99dc-69c5b97b2849_2494x638.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!tjyZ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8cf5793-4566-4cad-99dc-69c5b97b2849_2494x638.png 424w, https://substackcdn.com/image/fetch/$s_!tjyZ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8cf5793-4566-4cad-99dc-69c5b97b2849_2494x638.png 848w, https://substackcdn.com/image/fetch/$s_!tjyZ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8cf5793-4566-4cad-99dc-69c5b97b2849_2494x638.png 1272w, https://substackcdn.com/image/fetch/$s_!tjyZ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8cf5793-4566-4cad-99dc-69c5b97b2849_2494x638.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!tjyZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8cf5793-4566-4cad-99dc-69c5b97b2849_2494x638.png" width="1456" height="372" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e8cf5793-4566-4cad-99dc-69c5b97b2849_2494x638.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:372,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:245085,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!tjyZ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8cf5793-4566-4cad-99dc-69c5b97b2849_2494x638.png 424w, https://substackcdn.com/image/fetch/$s_!tjyZ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8cf5793-4566-4cad-99dc-69c5b97b2849_2494x638.png 848w, https://substackcdn.com/image/fetch/$s_!tjyZ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8cf5793-4566-4cad-99dc-69c5b97b2849_2494x638.png 1272w, https://substackcdn.com/image/fetch/$s_!tjyZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8cf5793-4566-4cad-99dc-69c5b97b2849_2494x638.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Node 23 va putea rula fi&#537;ierele .ts f&#259;r&#259; extra configura&#539;ii.</p><p><a href="https://github.com/nodejs/node/pull/56350">Un PR</a> f&#259;r&#259; care elimin&#259; flag-ul <code>--experimental-strip-types</code> a fost  trimis de <a href="https://github.com/marco-ippolito">Marco Ippolito</a> &#238;n Node 23. Practic asta &#238;nseamn&#259; c&#259;: </p><ul><li><p>po&#539;i crea un fi&#537;ier <code>index.ts</code> cu sintax&#259; typescript</p></li><li><p>po&#539;i lansa <code>node index.ts</code> f&#259;r&#259; alte flag-uri</p></li><li><p>node va elimina declara&#539;iile de tip folosind <em>swc</em>, apoi va rula codul rezultat</p></li></ul><p>Suportul pentru typescript a fost &#238;n continu&#259; dezvoltare pentru node &#238;n ultimii 5 ani, dar datorit&#259; efortului voluntar al contributorilor, acum acesta va fi disponobil &#238;n versiunile Node 22 &#537;i Node 23.6. Ce &#238;nseamn&#259; asta mai pe larg?</p><h3>Cum &#238;l po&#539;i &#238;ncerca? </h3><p>Dac&#259; ai o versiune de node peste 22.6, po&#539;i rula fi&#537;iere typescript (.ts) folosind steagul --<em><strong>experimental</strong></em>-<em><strong>strip</strong></em>-<em><strong>types</strong></em>:</p><pre><code>node --experimental-strip-types index.ts</code></pre><p><a href="https://nodejs.org/download/nightly/v24.0.0-nightly20250111ad68d088a3/">Node nightly</a> &#537;i &#238;ncep&#226;nd cu versiunea 23.6 va putea rula implicit fi&#537;ierele cu sintaxa typescript, f&#259;r&#259; s&#259; mai adaugi steagul.</p><h3>Face node typecheck?</h3><p>Nu, nodejs nu va valida tipurile din fi&#537;ierele Typescript. Vei fi nevoit s&#259; rulezi tsc sau alt utilitar pentru type-check &#537;i sintax&#259; &#238;n alt proces: <code>tsc --watch </code>.</p><h3>Ce ar trebui s&#259; pun &#238;n tsconfig?</h3><pre><code># tsconfig.json (node &gt;= 23.6)
{
  "compilerOptions": {
    /* Base Options: */
    "esModuleInterop": true,
    "skipLibCheck": true,
    "target": "es2022",
    "allowJs": true,
    "resolveJsonModule": true,
    "moduleDetection": "force",
    "isolatedModules": true,
    "verbatimModuleSyntax": true,
    /* Strictness */
    "strict": true,
    "noUncheckedIndexedAccess": true,
    "noImplicitOverride": true,
    /* Node Stuff */
    "allowImportingTsExtensions": true,
    "module": "NodeNext",
    "noEmit": true,
    /* If your code doesn't run in the DOM: */
    "lib": [
      "es2022"
    ],
  }
}</code></pre><h3>Suport&#259; enums &#537;i namespaces?</h3><p>Enums &#537;i namespaces nu sunt suportate implicit. Pentru o list&#259; complet&#259; pute&#539;i vedea aici: <a href="https://nodejs.org/api/typescript.html#type-stripping">nodejs.org/api/typescript.html#type-stripping</a>. Dac&#259; vre&#539;i suport pentru alte caracteristici specifice typescript folosi&#539;i steagul <code>--experimental-transform-types</code> .</p><p>Dar nici <strong>runtime namespaces nu sunt suportate</strong> &#238;nc&#259;, doar type only (declare namespace).</p><h3>Este necesar&#259; transpilarea la JavaScript &#238;n produc&#539;ie?</h3><p><strong>Pentru aplica&#539;ii Node</strong>, dac&#259; livrezi codul pe o platform&#259; serverless atunci da, cold start-ul va fi semnificativ mai rapid pe codul transpilat. &#206;n schimb dac&#259; ai o apica&#539;ie pentru care nu este foarte important acest metric, atunci timpul ad&#259;ugat la prima pornire a aplica&#539;iei este nesemnificativ.</p><p>Un posibil impact de performan&#539;&#259; poate ap&#259;rea &#238;n cazul &#238;n care &#238;ncarci alt&#259; libr&#259;rie TypeScript &#238;n timpul rul&#259;rii aplica&#539;iei. Node va fi nevoit s&#259; transpileze &#537;i aceste libr&#259;rii.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://stack.moustacios.dev/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption"><em>Moustacios.Dev este o publica&#539;ie sus&#539;inut&#259; de voi, de comunitate. Pentru a primi post&#259;ri noi &#537;i pentru a-mi sus&#539;ine munca, v&#259; invit s&#259; v&#259; abona&#539;i:</em></p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p><strong>Pentru libr&#259;rii (&#537;i pachete npm): </strong>da, acestea necesit&#259; s&#259; fie transpilate la Javascript, altfel nu vor putea fi folosite &#238;n proiectele Javascript. De asemenea &#537;i cei care folosesc Typescript vor putea &#238;nc&#259;rca fi&#537;ierele cu delara&#539;iile de tipuri (<em>.d.ts</em>).</p><p><strong>Monorepo-uri: </strong>&#238;n cazul unei libr&#259;rii &#238;ntr-un monorepo recomandarea este s&#259; se fac&#259; traspilarea, din acelea&#537;i motive men&#539;ionate mai sus.</p><h3>Va fi disponibil sportul &#238;n versiuni mai vechi?</h3><p>Suportul implicit pentru typescript, va fi disponibil &#238;n Node 22, dar nu &#537;i &#238;n Node 20 sau mai vechi.</p><div><hr></div><p><em>Referin&#539;e:</em></p><ul><li><p>(en) <a href="https://www.totaltypescript.com/typescript-is-coming-to-node-23">www.totaltypescript.com/typescript-is-coming-to-node-23</a></p></li></ul>]]></content:encoded></item><item><title><![CDATA[sqlc - generează cod type-safe din SQL ]]></title><description><![CDATA[Nu te atrag ORM-urile, atunci sqlc este wingman-ul t&#259;u]]></description><link>https://stack.moustacios.dev/p/sqlc-genereaza-cod-type-safe-din</link><guid isPermaLink="false">https://stack.moustacios.dev/p/sqlc-genereaza-cod-type-safe-din</guid><dc:creator><![CDATA[Teo cel Mustăcios]]></dc:creator><pubDate>Tue, 19 Nov 2024 05:15:53 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!YBv8!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe04a634e-c2b3-44b0-9f22-7aaecf462d46_1366x768.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!YBv8!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe04a634e-c2b3-44b0-9f22-7aaecf462d46_1366x768.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!YBv8!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe04a634e-c2b3-44b0-9f22-7aaecf462d46_1366x768.png 424w, https://substackcdn.com/image/fetch/$s_!YBv8!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe04a634e-c2b3-44b0-9f22-7aaecf462d46_1366x768.png 848w, https://substackcdn.com/image/fetch/$s_!YBv8!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe04a634e-c2b3-44b0-9f22-7aaecf462d46_1366x768.png 1272w, https://substackcdn.com/image/fetch/$s_!YBv8!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe04a634e-c2b3-44b0-9f22-7aaecf462d46_1366x768.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!YBv8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe04a634e-c2b3-44b0-9f22-7aaecf462d46_1366x768.png" width="1366" height="768" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e04a634e-c2b3-44b0-9f22-7aaecf462d46_1366x768.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:768,&quot;width&quot;:1366,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:113012,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!YBv8!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe04a634e-c2b3-44b0-9f22-7aaecf462d46_1366x768.png 424w, https://substackcdn.com/image/fetch/$s_!YBv8!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe04a634e-c2b3-44b0-9f22-7aaecf462d46_1366x768.png 848w, https://substackcdn.com/image/fetch/$s_!YBv8!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe04a634e-c2b3-44b0-9f22-7aaecf462d46_1366x768.png 1272w, https://substackcdn.com/image/fetch/$s_!YBv8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe04a634e-c2b3-44b0-9f22-7aaecf462d46_1366x768.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Recunosc c&#259; sunt un adept conceptului de ORM<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-1" href="#footnote-1" target="_self">1</a>. Din framework-urile pe care le-am folosit am profitat de Eloquent<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-2" href="#footnote-2" target="_self">2</a>, query-builder-ul Fluent sau de Doctrine<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-3" href="#footnote-3" target="_self">3</a>. Dar acest articol nu este despre ORM-uri, ci mai degrab&#259; pentru cei care prefer&#259; s&#259; evite aceste libr&#259;rii &#537;i s&#259; scrie query-uri SQL de m&#226;n&#259; - oferindu-le un control mai mare &#537;i vizibilitate asupra cererii respective.</p><h3>SQLc - SQL compiler</h3><p>&#206;ns&#259; ogranizarea &#537;i cuplarea acestor query-uri cu codul, este de obicei subiectul dezbaterilor, mai ales pentru c&#259; multe g&#259;uri de securitate ca SQL injection au ca punct comun aceast&#259; practic&#259;. SQLc este o alternativ&#259; care p&#259;streaz&#259; beneficiile optimiz&#259;rii &#537;i scrierii de cereri SQL de m&#226;n&#259;, &#238;ns&#259; genereaz&#259; cod nativ &#238;n limbajul configurat pentru a fi folosit &#238;n aplica&#539;ie:</p><ul><li><p><em>evit&#259; posibilele issue-uri de securitate</em>: codul SQL este separat de aplica&#539;ie &#537;i codul generat nativ, cu tipuri &#537;i interfe&#539;e este cel folosit &#238;n aplica&#539;ie</p></li><li><p><em>organizeaz&#259; &#537;i separ&#259; eficient codul &#537;i configura&#539;ia</em>: un beneficiu notabil pentru audit-ul &#537;i depanarea query-urilor </p></li><li><p><em>codul poate fi re-generat &#537;i optimizat la nevoie</em> </p></li><li><p><em>ofer&#259; suport pentru mai multe motoare de baze de date prin configura&#539;ie</em></p></li><li><p><em>langauge agnostic</em></p></li></ul><p>SQLc este disponibil pentru limbajele Go, Typescript, Kotlin &#537;i Python, &#537;i poate fi folosit cu MySQL &#537;i PostgreSQL. Suportul pentru SQLite este &#238;n beta &#537;i exist&#259; implement&#259;ri neoficiale pentru limbajele C# &#537;i F#:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!6wOC!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F705b36f8-3d85-4dd3-b36c-cf7eca46d4fe_913x303.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!6wOC!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F705b36f8-3d85-4dd3-b36c-cf7eca46d4fe_913x303.png 424w, https://substackcdn.com/image/fetch/$s_!6wOC!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F705b36f8-3d85-4dd3-b36c-cf7eca46d4fe_913x303.png 848w, https://substackcdn.com/image/fetch/$s_!6wOC!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F705b36f8-3d85-4dd3-b36c-cf7eca46d4fe_913x303.png 1272w, https://substackcdn.com/image/fetch/$s_!6wOC!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F705b36f8-3d85-4dd3-b36c-cf7eca46d4fe_913x303.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!6wOC!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F705b36f8-3d85-4dd3-b36c-cf7eca46d4fe_913x303.png" width="913" height="303" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/705b36f8-3d85-4dd3-b36c-cf7eca46d4fe_913x303.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:303,&quot;width&quot;:913,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:49442,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!6wOC!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F705b36f8-3d85-4dd3-b36c-cf7eca46d4fe_913x303.png 424w, https://substackcdn.com/image/fetch/$s_!6wOC!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F705b36f8-3d85-4dd3-b36c-cf7eca46d4fe_913x303.png 848w, https://substackcdn.com/image/fetch/$s_!6wOC!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F705b36f8-3d85-4dd3-b36c-cf7eca46d4fe_913x303.png 1272w, https://substackcdn.com/image/fetch/$s_!6wOC!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F705b36f8-3d85-4dd3-b36c-cf7eca46d4fe_913x303.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!lk3o!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d89def2-ba03-4c30-9d5e-d3552e1986af_1080x202.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!lk3o!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d89def2-ba03-4c30-9d5e-d3552e1986af_1080x202.png 424w, https://substackcdn.com/image/fetch/$s_!lk3o!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d89def2-ba03-4c30-9d5e-d3552e1986af_1080x202.png 848w, https://substackcdn.com/image/fetch/$s_!lk3o!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d89def2-ba03-4c30-9d5e-d3552e1986af_1080x202.png 1272w, https://substackcdn.com/image/fetch/$s_!lk3o!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d89def2-ba03-4c30-9d5e-d3552e1986af_1080x202.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!lk3o!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d89def2-ba03-4c30-9d5e-d3552e1986af_1080x202.png" width="1080" height="202" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1d89def2-ba03-4c30-9d5e-d3552e1986af_1080x202.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:202,&quot;width&quot;:1080,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:45530,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!lk3o!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d89def2-ba03-4c30-9d5e-d3552e1986af_1080x202.png 424w, https://substackcdn.com/image/fetch/$s_!lk3o!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d89def2-ba03-4c30-9d5e-d3552e1986af_1080x202.png 848w, https://substackcdn.com/image/fetch/$s_!lk3o!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d89def2-ba03-4c30-9d5e-d3552e1986af_1080x202.png 1272w, https://substackcdn.com/image/fetch/$s_!lk3o!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d89def2-ba03-4c30-9d5e-d3552e1986af_1080x202.png 1456w" sizes="100vw"></picture><div></div></div></a></figure></div><h2>Instalarea &#537;i ini&#539;ializarea proiectului</h2><p>sqlc este un utilitar din linia de comand&#259;, a&#537;adar poate fi instalat cu brew, snap sau docker:</p><pre><code><em># Ubuntu</em>
sudo snap install sqlc

<em># MacOS
</em>brew install sqlc

<em># Docker
</em>docker pull sqlc/sqlc<em>

# go install (&gt;1.21)
</em>go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest</code></pre><p>&#536;i pentru windows desigur pute&#539;i desc&#259;rca un sqlc.exe<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-4" href="#footnote-4" target="_self">4</a>.</p><p>Am instalat sqlc, pe WSL foloind snap &#537;i voi folosi ultima versiune a limbajului <code>go </code>(<em>1.23</em>) dup&#259; care ini&#539;ializez un proiect cu mod init: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!MEID!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6dc51644-2344-4c1c-b12f-f47a16a7776f_1158x375.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!MEID!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6dc51644-2344-4c1c-b12f-f47a16a7776f_1158x375.png 424w, https://substackcdn.com/image/fetch/$s_!MEID!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6dc51644-2344-4c1c-b12f-f47a16a7776f_1158x375.png 848w, https://substackcdn.com/image/fetch/$s_!MEID!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6dc51644-2344-4c1c-b12f-f47a16a7776f_1158x375.png 1272w, https://substackcdn.com/image/fetch/$s_!MEID!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6dc51644-2344-4c1c-b12f-f47a16a7776f_1158x375.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!MEID!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6dc51644-2344-4c1c-b12f-f47a16a7776f_1158x375.png" width="1158" height="375" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6dc51644-2344-4c1c-b12f-f47a16a7776f_1158x375.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:375,&quot;width&quot;:1158,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:75926,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!MEID!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6dc51644-2344-4c1c-b12f-f47a16a7776f_1158x375.png 424w, https://substackcdn.com/image/fetch/$s_!MEID!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6dc51644-2344-4c1c-b12f-f47a16a7776f_1158x375.png 848w, https://substackcdn.com/image/fetch/$s_!MEID!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6dc51644-2344-4c1c-b12f-f47a16a7776f_1158x375.png 1272w, https://substackcdn.com/image/fetch/$s_!MEID!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6dc51644-2344-4c1c-b12f-f47a16a7776f_1158x375.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h2>Configurarea</h2><p>Utilitarul caut&#259; un fi&#537;ier <code>sqlc.(yaml|yml|json)</code> &#238;n directorul proiectului, &#537;i aici specific&#259;m c&#226;teva c&#259;i c&#259;tre fi&#537;ierele sql din care se va genera codul, generatorul folosit &#537;i desigur motorul pentru baza de date:</p><pre><code># ~/Workspace/sqlcdemo/sqlc.yml

---
version: "2"
sql:
  - engine: "mysql"
    queries: "queries.sql"
    schema: "schema.sql"
    gen:
      go:
        package: "moustacios"
        out: "moustacios"</code></pre><h2>Definirea schemei</h2><p>De&#537;i nu ruleaz&#259; migr&#259;ri, sqlc &#539;ine cont de structura bazei de date &#537;i va genera modele pe baza ei. Recomandarea este s&#259; definim schema &#238;n fi&#537;ierul <em>schema.sql</em>. Baza de date pentru acest tutorial va avea un singur tabel respectiv unul de <em>commments </em>&#537;i patru coloane: <code>id</code>, <code>email</code>, <code>comment_text </code>&#537;i <code>bot_probability</code>:</p><pre><code>-- ~/Workspace/sqlcdemo/schema.sql

CREATE TABLE comments (
  id              BIGINT  NOT NULL AUTO_INCREMENT PRIMARY KEY,
  email           VARCHAR(255)    NOT NULL,
  comment_text    TEXT            NOT NULL,
  bot_probability TINYINT         DEFAULT 0
);</code></pre><h2>Definirea interog&#259;rilor (queries)</h2><p>Urm&#259;torul pas, poate contraintuitiv, este s&#259; ne definim query-urile. &#536;i facem asta &#238;ntr-un fi&#537;ier denumit evident <em>queries.sql</em>. Vom defini c&#226;te o cerere pentru fiecare opera&#539;ie CRUD:</p><pre><code>-- ~/Workspace/sqlcdemo/queries.sql

-- name: GetComment :one
SELECT * FROM comments
WHERE id = ? LIMIT 1;

-- name: ListComments :many
SELECT * FROM comments
ORDER BY bot_probability DESC;

-- name: SaveComment :execresult
INSERT INTO comments (
  email, comment_text
) VALUES (
  ?, ?
);

-- name: DeleteComment :execresult
DELETE FROM comments
WHERE id = ?;

-- name: PurgeBotComments :execresult
DELETE FROM comments
WHERE bot_probability &gt; ?;</code></pre><p>Ve&#539;i observa adnot&#259;rile cu numele de interog&#259;ri &#537;i tipul de rezultat a&#537;teptat. Acestea ajut&#259; <code>sqlc </code>s&#259; genereze func&#539;ii &#537;i structuri sau obiecte specifice proiectului.</p><h2>Generarea de cod </h2><p>Odat&#259; ce avem cele trei fi&#537;iere: sqlc.yml, schema.sql &#537;i queries.sql putem rula comanda de generare de cod:</p><pre><code>sqlc generate</code></pre><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!CGT1!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03a5214d-d616-4eaa-9475-fde28147ce8a_1021x490.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!CGT1!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03a5214d-d616-4eaa-9475-fde28147ce8a_1021x490.png 424w, https://substackcdn.com/image/fetch/$s_!CGT1!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03a5214d-d616-4eaa-9475-fde28147ce8a_1021x490.png 848w, https://substackcdn.com/image/fetch/$s_!CGT1!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03a5214d-d616-4eaa-9475-fde28147ce8a_1021x490.png 1272w, https://substackcdn.com/image/fetch/$s_!CGT1!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03a5214d-d616-4eaa-9475-fde28147ce8a_1021x490.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!CGT1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03a5214d-d616-4eaa-9475-fde28147ce8a_1021x490.png" width="1021" height="490" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/03a5214d-d616-4eaa-9475-fde28147ce8a_1021x490.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:490,&quot;width&quot;:1021,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:40481,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!CGT1!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03a5214d-d616-4eaa-9475-fde28147ce8a_1021x490.png 424w, https://substackcdn.com/image/fetch/$s_!CGT1!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03a5214d-d616-4eaa-9475-fde28147ce8a_1021x490.png 848w, https://substackcdn.com/image/fetch/$s_!CGT1!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03a5214d-d616-4eaa-9475-fde28147ce8a_1021x490.png 1272w, https://substackcdn.com/image/fetch/$s_!CGT1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03a5214d-d616-4eaa-9475-fde28147ce8a_1021x490.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Comanda <code>sqlc generate </code>va genera structuri pentru modele, func&#539;ii pentru cereri &#537;i interfe&#539;e:</p><div class="image-gallery-embed" data-attrs="{&quot;gallery&quot;:{&quot;images&quot;:[{&quot;type&quot;:&quot;image/png&quot;,&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ad820ce0-0b3f-49cd-8d4e-7732b10391a6_2972x1440.png&quot;},{&quot;type&quot;:&quot;image/png&quot;,&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/137248f0-b898-4684-b6f2-ee08525f2a39_2972x3092.png&quot;},{&quot;type&quot;:&quot;image/png&quot;,&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/58dce19c-2569-4d51-a0af-e2c2241ffda7_2972x7268.png&quot;}],&quot;caption&quot;:&quot;Cod generat de sqlc&quot;,&quot;alt&quot;:&quot;&quot;,&quot;staticGalleryImage&quot;:{&quot;type&quot;:&quot;image/png&quot;,&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d0cb82a6-f1b7-48e5-91c3-9c6ec9b04467_1456x474.png&quot;}},&quot;isEditorNode&quot;:true}"></div><h3>&#206;n practic&#259;</h3><p>&#536;i acum e un simplu exerci&#539;iu de utilizare a acestui cod, &#238;n aplica&#539;ia noastr&#259; pentru a insera un comentariu, &#238;l list&#259;m &#537;i apoi &#537;tergem:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!rXXc!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a1f3c64-cbab-4cc7-882c-a5fddeb01da1_3216x6204.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!rXXc!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a1f3c64-cbab-4cc7-882c-a5fddeb01da1_3216x6204.png 424w, https://substackcdn.com/image/fetch/$s_!rXXc!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a1f3c64-cbab-4cc7-882c-a5fddeb01da1_3216x6204.png 848w, https://substackcdn.com/image/fetch/$s_!rXXc!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a1f3c64-cbab-4cc7-882c-a5fddeb01da1_3216x6204.png 1272w, https://substackcdn.com/image/fetch/$s_!rXXc!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a1f3c64-cbab-4cc7-882c-a5fddeb01da1_3216x6204.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!rXXc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a1f3c64-cbab-4cc7-882c-a5fddeb01da1_3216x6204.png" width="1456" height="2809" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5a1f3c64-cbab-4cc7-882c-a5fddeb01da1_3216x6204.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:2809,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:960815,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!rXXc!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a1f3c64-cbab-4cc7-882c-a5fddeb01da1_3216x6204.png 424w, https://substackcdn.com/image/fetch/$s_!rXXc!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a1f3c64-cbab-4cc7-882c-a5fddeb01da1_3216x6204.png 848w, https://substackcdn.com/image/fetch/$s_!rXXc!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a1f3c64-cbab-4cc7-882c-a5fddeb01da1_3216x6204.png 1272w, https://substackcdn.com/image/fetch/$s_!rXXc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a1f3c64-cbab-4cc7-882c-a5fddeb01da1_3216x6204.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Pentru a face build-ul rul&#259;m comanda de import a driverului de mysql &#537;i apoi build:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Py8A!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8880119c-46e9-42b0-b795-b0f19a5620eb_1169x311.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Py8A!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8880119c-46e9-42b0-b795-b0f19a5620eb_1169x311.png 424w, https://substackcdn.com/image/fetch/$s_!Py8A!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8880119c-46e9-42b0-b795-b0f19a5620eb_1169x311.png 848w, https://substackcdn.com/image/fetch/$s_!Py8A!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8880119c-46e9-42b0-b795-b0f19a5620eb_1169x311.png 1272w, https://substackcdn.com/image/fetch/$s_!Py8A!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8880119c-46e9-42b0-b795-b0f19a5620eb_1169x311.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Py8A!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8880119c-46e9-42b0-b795-b0f19a5620eb_1169x311.png" width="1169" height="311" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8880119c-46e9-42b0-b795-b0f19a5620eb_1169x311.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:311,&quot;width&quot;:1169,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:63943,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Py8A!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8880119c-46e9-42b0-b795-b0f19a5620eb_1169x311.png 424w, https://substackcdn.com/image/fetch/$s_!Py8A!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8880119c-46e9-42b0-b795-b0f19a5620eb_1169x311.png 848w, https://substackcdn.com/image/fetch/$s_!Py8A!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8880119c-46e9-42b0-b795-b0f19a5620eb_1169x311.png 1272w, https://substackcdn.com/image/fetch/$s_!Py8A!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8880119c-46e9-42b0-b795-b0f19a5620eb_1169x311.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Pentru a ne conecta la o baz&#259; de date &#537;i a rula efectiv interog&#259;rile de mysql voi folosi containerul mysql de docker cu urm&#259;toarea configura&#539;ie de <code>docker-compose.yml </code>:</p><pre><code># ~/Workspace/sqlcdemo/docker-compose.yml

services:

  db:
    image: mysql:lts
    restart: always
    ports:
      - "3306:3306"
    environment:
      MYSQL_ROOT_PASSWORD: secret
      MYSQL_DATABASE: sqlcdemo
      MYSQL_USER: sqlcdemo
      MYSQL_PASSWORD: secret

  adminer:
    image: adminer
    restart: always
    ports:
      - "8080:8080"</code></pre><p>&#536;i voi schimba username &#537;i parola &#238;n string-ul meu de conectare din fi&#537;ierul <code>main.go</code>:</p><pre><code>// main.go linia 18

db, err := sql.Open("mysql", "sqlcdemo:secret@tcp(localhost:3306)/sqlcdemo?parseTime=true")</code></pre><p>&#536;i rulez comanda de docker-compose &#537;i apoi build &#537;i run:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!9Ae6!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d417ad5-ad25-4eaa-bcbb-36282b0813db_1542x325.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!9Ae6!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d417ad5-ad25-4eaa-bcbb-36282b0813db_1542x325.png 424w, https://substackcdn.com/image/fetch/$s_!9Ae6!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d417ad5-ad25-4eaa-bcbb-36282b0813db_1542x325.png 848w, https://substackcdn.com/image/fetch/$s_!9Ae6!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d417ad5-ad25-4eaa-bcbb-36282b0813db_1542x325.png 1272w, https://substackcdn.com/image/fetch/$s_!9Ae6!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d417ad5-ad25-4eaa-bcbb-36282b0813db_1542x325.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!9Ae6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d417ad5-ad25-4eaa-bcbb-36282b0813db_1542x325.png" width="1456" height="307" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1d417ad5-ad25-4eaa-bcbb-36282b0813db_1542x325.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:307,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:64902,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!9Ae6!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d417ad5-ad25-4eaa-bcbb-36282b0813db_1542x325.png 424w, https://substackcdn.com/image/fetch/$s_!9Ae6!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d417ad5-ad25-4eaa-bcbb-36282b0813db_1542x325.png 848w, https://substackcdn.com/image/fetch/$s_!9Ae6!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d417ad5-ad25-4eaa-bcbb-36282b0813db_1542x325.png 1272w, https://substackcdn.com/image/fetch/$s_!9Ae6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d417ad5-ad25-4eaa-bcbb-36282b0813db_1542x325.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Pe github g&#259;si&#539;i <a href="https://github.com/moustacios/golang-tutorials/tree/main/sqlcdemo">codul complet din acest exemplu</a>. Acolo am ad&#259;ugat &#537;i o cerere de marcare a unul comentariu ca bot comment &#537;i apoi am folosit integogarea <code>PurgeBotComments </code>pentru a-l &#537;terge:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!nBL6!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ce68a43-354a-4cae-89c5-fcf09f713f81_1173x216.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!nBL6!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ce68a43-354a-4cae-89c5-fcf09f713f81_1173x216.png 424w, https://substackcdn.com/image/fetch/$s_!nBL6!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ce68a43-354a-4cae-89c5-fcf09f713f81_1173x216.png 848w, https://substackcdn.com/image/fetch/$s_!nBL6!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ce68a43-354a-4cae-89c5-fcf09f713f81_1173x216.png 1272w, https://substackcdn.com/image/fetch/$s_!nBL6!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ce68a43-354a-4cae-89c5-fcf09f713f81_1173x216.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!nBL6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ce68a43-354a-4cae-89c5-fcf09f713f81_1173x216.png" width="1173" height="216" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1ce68a43-354a-4cae-89c5-fcf09f713f81_1173x216.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:216,&quot;width&quot;:1173,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:32831,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!nBL6!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ce68a43-354a-4cae-89c5-fcf09f713f81_1173x216.png 424w, https://substackcdn.com/image/fetch/$s_!nBL6!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ce68a43-354a-4cae-89c5-fcf09f713f81_1173x216.png 848w, https://substackcdn.com/image/fetch/$s_!nBL6!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ce68a43-354a-4cae-89c5-fcf09f713f81_1173x216.png 1272w, https://substackcdn.com/image/fetch/$s_!nBL6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ce68a43-354a-4cae-89c5-fcf09f713f81_1173x216.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-1" href="#footnote-anchor-1" class="footnote-number" contenteditable="false" target="_self">1</a><div class="footnote-content"><p>(en) <a href="https://en.wikipedia.org/wiki/Object%E2%80%93relational_mapping">en.wikipedia.org/wiki/Object%E2%80%93relational_mapping</a></p></div></div><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-2" href="#footnote-anchor-2" class="footnote-number" contenteditable="false" target="_self">2</a><div class="footnote-content"><p>(en) <a href="https://laravel.com/docs/11.x/eloquent#introduction">laravel.com/docs/11.x/eloquent#introduction</a></p></div></div><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-3" href="#footnote-anchor-3" class="footnote-number" contenteditable="false" target="_self">3</a><div class="footnote-content"><p>(en) <a href="https://www.doctrine-project.org/">doctrine-project.org</a></p></div></div><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-4" href="#footnote-anchor-4" class="footnote-number" contenteditable="false" target="_self">4</a><div class="footnote-content"><p><a href="https://downloads.sqlc.dev/1.27.0/index.html">downloads.sqlc.dev/1.27.0/index.html</a></p></div></div>]]></content:encoded></item><item><title><![CDATA[Maybe? monad-ul care evită null-checks, cu PHP]]></title><description><![CDATA[Inspirat din limbajele de programare func&#539;ionale, paradigma &#8221;maybe&#8221; poate fi &#238;mprumutat&#259; &#537;i &#238;n PHP]]></description><link>https://stack.moustacios.dev/p/maybe-monad-ul-care-evita-null-checks</link><guid isPermaLink="false">https://stack.moustacios.dev/p/maybe-monad-ul-care-evita-null-checks</guid><dc:creator><![CDATA[Teo cel Mustăcios]]></dc:creator><pubDate>Tue, 12 Nov 2024 05:56:17 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/3751f41c-1819-485c-bc9d-e6205a965f29_851x315.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ha07!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F15a0062d-3757-4aca-a3ac-c932cc8b4edf_851x315.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ha07!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F15a0062d-3757-4aca-a3ac-c932cc8b4edf_851x315.png 424w, https://substackcdn.com/image/fetch/$s_!ha07!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F15a0062d-3757-4aca-a3ac-c932cc8b4edf_851x315.png 848w, https://substackcdn.com/image/fetch/$s_!ha07!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F15a0062d-3757-4aca-a3ac-c932cc8b4edf_851x315.png 1272w, https://substackcdn.com/image/fetch/$s_!ha07!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F15a0062d-3757-4aca-a3ac-c932cc8b4edf_851x315.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ha07!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F15a0062d-3757-4aca-a3ac-c932cc8b4edf_851x315.png" width="851" height="315" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/15a0062d-3757-4aca-a3ac-c932cc8b4edf_851x315.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:315,&quot;width&quot;:851,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:34129,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ha07!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F15a0062d-3757-4aca-a3ac-c932cc8b4edf_851x315.png 424w, https://substackcdn.com/image/fetch/$s_!ha07!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F15a0062d-3757-4aca-a3ac-c932cc8b4edf_851x315.png 848w, https://substackcdn.com/image/fetch/$s_!ha07!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F15a0062d-3757-4aca-a3ac-c932cc8b4edf_851x315.png 1272w, https://substackcdn.com/image/fetch/$s_!ha07!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F15a0062d-3757-4aca-a3ac-c932cc8b4edf_851x315.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Dac&#259; ave&#539;i o afinitate spre programarea func&#539;ional&#259;, atunci cred c&#259; o s&#259; v&#259; plac&#259; ideea de a &#238;mprumuta aspecte func&#539;ionale &#238;ntr-un limbaj orientat pe obiecte. &#206;n schimb, dac&#259; nu ave&#539;i experien&#539;&#259; cu limbajale func&#539;ionale (Haskell<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-1" href="#footnote-1" target="_self">1</a>, Scala<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-2" href="#footnote-2" target="_self">2</a> sau erlang), e o ocazie s&#259; afla&#539;i despre aceste limbaje &#537;i s&#259; aplica&#539;i o paradimg&#259; des folosit&#259; &#238;n acest domeniu: <strong>monad</strong>.</p><h2>Ce este un monad (monad&#259;)?</h2><p>&#206;n termeni simpli, o monad&#259; este un tipar de proiectare sau abstractizare, care ne permite s&#259; &#238;nl&#259;n&#539;uim calcule &#537;i s&#259; gestion&#259;m anumite aspecte ale acestora &#238;ntr-un mod structurat. Monada func&#539;ioneaz&#259; ca un "container" special care poate con&#539;ine valori &#537;i de asemenea, s&#259; defineasc&#259; "efecte secundare" asociate cu aceste valori.</p><h4>De se folosesc monadele?</h4><p><strong>Pentru gestionarea efectelor secundare:</strong> Monadele ne permit s&#259; trat&#259;m efecte secundare precum date din surse externe (I/O), excep&#539;ii &#537;i modificarea valorilor &#238;ntr-un mod pur func&#539;ional<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-3" href="#footnote-3" target="_self">3</a>.</p><p><strong>Structurarea codului:</strong> Monadele ajut&#259; s&#259; scriem cod mai clar &#537;i mai concis, facilit&#226;nd &#238;nl&#259;n&#539;uirea de opera&#539;ii &#537;i abstractizarea multor detalii de implementare.</p><p><strong>Compunerea func&#539;iilor:</strong> Monadele permit compunerea de func&#539;ii care opereaz&#259; pe valorile &#238;nchise &#238;n monade, cre&#226;nd astfel "pipeline-uri" de calcul.</p><h3>Monada maybe</h3><p>Aceasta reprezint&#259; o valoare care poate fi, fie <em>Just a</em> (o valoare prezent&#259;), fie <em>Nothing</em> (o valoare absent&#259;). Se folose&#537;te pentru a modela valori op&#539;ionale &#537;i pentru a evita erorile de tipul <code>null pointer</code>. Maybe ne permite &#238;nl&#259;n&#539;uirea de opera&#539;ii, &#537;i implicit returnarea &#8221;Nothning&#8221; sau o valoare implicite c&#226;nd opera&#539;iile nu sunt executate.</p><p>&#206;n pseudocod, putem defini monada Maybe astfel:</p><pre><code>data Maybe val = Just val | Nothing</code></pre><h2>Implementarea <em>Maybe </em>&#238;n PHP</h2><p>Aceast&#259; implementare ne ajut&#259; s&#259; evit&#259;m evalu&#259;rile de genul</p><pre><code>if (valoare) then:
  X
else:
  Y</code></pre><p>tipice limbajelor de program&#259;rie imperative. Iar monada <em>Maybe </em>este relativ u&#537;or de implementat. </p><p>Vom defini o clas&#259; care suport&#259; aceste 2 metode: <code>just </code>&#537;i <code>nothing </code>plus o metod&#259; de <code>map</code> &#537;i una <code>getOrElse </code>pentru &#238;nl&#259;n&#539;uire &#537;i respectiv un pas de ob&#539;inere a valorii cu suport pentru valori default sau implicite:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!rV2C!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46406031-bc2f-4756-acfa-6e29aea19bd4_3272x6204.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!rV2C!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46406031-bc2f-4756-acfa-6e29aea19bd4_3272x6204.png 424w, https://substackcdn.com/image/fetch/$s_!rV2C!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46406031-bc2f-4756-acfa-6e29aea19bd4_3272x6204.png 848w, https://substackcdn.com/image/fetch/$s_!rV2C!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46406031-bc2f-4756-acfa-6e29aea19bd4_3272x6204.png 1272w, https://substackcdn.com/image/fetch/$s_!rV2C!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46406031-bc2f-4756-acfa-6e29aea19bd4_3272x6204.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!rV2C!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46406031-bc2f-4756-acfa-6e29aea19bd4_3272x6204.png" width="1456" height="2761" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/46406031-bc2f-4756-acfa-6e29aea19bd4_3272x6204.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:2761,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:961416,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!rV2C!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46406031-bc2f-4756-acfa-6e29aea19bd4_3272x6204.png 424w, https://substackcdn.com/image/fetch/$s_!rV2C!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46406031-bc2f-4756-acfa-6e29aea19bd4_3272x6204.png 848w, https://substackcdn.com/image/fetch/$s_!rV2C!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46406031-bc2f-4756-acfa-6e29aea19bd4_3272x6204.png 1272w, https://substackcdn.com/image/fetch/$s_!rV2C!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46406031-bc2f-4756-acfa-6e29aea19bd4_3272x6204.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>A&#537;a cum am men&#539;ionat, avem cele dou&#259; metode statice: <code>Maybe::just</code> &#537;i <code>Maybe::nothing</code>. <code>just </code>creeaz&#259; un obiect <code>Maybe </code>cu o valoare implicit&#259;, care poate fi null, iar <code>nothing </code>creeaz&#259; un obiect <code>Maybe </code>cu valoare NULL.</p><p>Metoda <code>map() </code>prime&#537;te o func&#539;ie &#537;i o aplic&#259; valorii salvate pe obiectul <code>Maybe</code>. Dac&#259; aceast&#259; valoare este NULL, va returna <code>Maybe::nothing</code>, adic&#259; un obiect Maybe f&#259;r&#259; valoare asociat&#259;. Iar dac&#259; exist&#259; o valoare pe obiect, valoare returnat&#259; de aplicarea func&#539;iei este returnat&#259; ca obiect <code>Maybe prin Maybe::just</code>.</p><p>Mai departe putem folosi aceast&#259; func&#539;ionalitate &#238;ntr-un controller de exemplu, care returneaz&#259; JSON:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!VMhO!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf7941f7-b8cc-4208-bf1e-0d78d2a22132_2712x2704.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!VMhO!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf7941f7-b8cc-4208-bf1e-0d78d2a22132_2712x2704.png 424w, https://substackcdn.com/image/fetch/$s_!VMhO!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf7941f7-b8cc-4208-bf1e-0d78d2a22132_2712x2704.png 848w, https://substackcdn.com/image/fetch/$s_!VMhO!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf7941f7-b8cc-4208-bf1e-0d78d2a22132_2712x2704.png 1272w, https://substackcdn.com/image/fetch/$s_!VMhO!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf7941f7-b8cc-4208-bf1e-0d78d2a22132_2712x2704.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!VMhO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf7941f7-b8cc-4208-bf1e-0d78d2a22132_2712x2704.png" width="1456" height="1452" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/cf7941f7-b8cc-4208-bf1e-0d78d2a22132_2712x2704.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1452,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:447406,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!VMhO!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf7941f7-b8cc-4208-bf1e-0d78d2a22132_2712x2704.png 424w, https://substackcdn.com/image/fetch/$s_!VMhO!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf7941f7-b8cc-4208-bf1e-0d78d2a22132_2712x2704.png 848w, https://substackcdn.com/image/fetch/$s_!VMhO!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf7941f7-b8cc-4208-bf1e-0d78d2a22132_2712x2704.png 1272w, https://substackcdn.com/image/fetch/$s_!VMhO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf7941f7-b8cc-4208-bf1e-0d78d2a22132_2712x2704.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Acest controller, ob&#539;ine o valoare pentru email din <code>$request</code> &#537;i apeleaz&#259; un serviciu, UserService pentru a ob&#539;ine datele utilizatorului. <code>UserService </code>va returna un obiect Maybe, pe care apel&#259;m map pentru a extrage un array cu datele relevante (name, email).</p><p>Dup&#259; <code>map </code>este &#238;nl&#259;n&#539;uit&#259; metoda <code>getOrElse</code>, prin care ob&#539;inem fie valoarea procesat&#259; la pasul anterior, fie valorile trimise ca implicite (<code>&#8216;name&#8216;=&gt; &#8216;Unknown&#8216;, &#8216;email&#8216;=&gt;&#8217;Unavailable&#8217;</code>) &#238;n cazul &#238;n care Maybe este nothing - adic&#259; userul nu este g&#259;sit. </p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://stack.moustacios.dev/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption"><em>Moustacios.Dev este o publica&#539;ie sus&#539;inut&#259; de voi, de comunitate. Pentru a primi post&#259;ri noi &#537;i pentru a-mi sus&#539;ine munca, v&#259; invit s&#259; v&#259; abona&#539;i:</em></p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>Implementarea serviciului UserService:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!-eQ3!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff485a62b-c39b-4437-a06f-4d6af3f8b007_3304x2412.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!-eQ3!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff485a62b-c39b-4437-a06f-4d6af3f8b007_3304x2412.png 424w, https://substackcdn.com/image/fetch/$s_!-eQ3!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff485a62b-c39b-4437-a06f-4d6af3f8b007_3304x2412.png 848w, https://substackcdn.com/image/fetch/$s_!-eQ3!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff485a62b-c39b-4437-a06f-4d6af3f8b007_3304x2412.png 1272w, https://substackcdn.com/image/fetch/$s_!-eQ3!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff485a62b-c39b-4437-a06f-4d6af3f8b007_3304x2412.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!-eQ3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff485a62b-c39b-4437-a06f-4d6af3f8b007_3304x2412.png" width="1456" height="1063" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f485a62b-c39b-4437-a06f-4d6af3f8b007_3304x2412.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1063,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:416102,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!-eQ3!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff485a62b-c39b-4437-a06f-4d6af3f8b007_3304x2412.png 424w, https://substackcdn.com/image/fetch/$s_!-eQ3!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff485a62b-c39b-4437-a06f-4d6af3f8b007_3304x2412.png 848w, https://substackcdn.com/image/fetch/$s_!-eQ3!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff485a62b-c39b-4437-a06f-4d6af3f8b007_3304x2412.png 1272w, https://substackcdn.com/image/fetch/$s_!-eQ3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff485a62b-c39b-4437-a06f-4d6af3f8b007_3304x2412.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Aici cre&#259;m obiectul Maybe care va transmite valoarea din repository, <code>NULL</code> sau un obiect <code>User</code>.</p><h4>Dezavantajul obiectului Maybe</h4><p>&#206;n implementarea de mai sus, de&#537;i am evitat evaluarea unei valori NULL &#238;n controller &#537;i func&#539;ia noastr&#259; prime&#537;te garantat un obiect de tip <em>User</em>, tipul acestui argument este ascuns &#238;n valoarea obiectul Maybe. A&#537;adar din acest punct de vedere am introdus un nivel de abstractizare care ascunde tipul argumentului.</p><p>De asemenea, restul aplica&#539;iei noastre nu &#537;tie cum s&#259; intrac&#539;ioneze cu acest nou container de date, &#537;i pentru a rezolva asta ar fi nevoie s&#259; introducem <em>Maybe </em>sau <em>Optional </em>ca un tip de input / output pentru func&#539;iile care extrag date in alt&#259; surs&#259;.&#206;n consecin&#539;&#259; asta ar putea complica implementarea cu un nou nivel de abstractizare.</p><h3>Alte implement&#259;ri notabile:</h3><ul><li><p><a href="https://github.com/php-slang/php-slang">github.com/php-slang/php-slang</a></p></li><li><p><a href="https://github.com/php-fp/php-fp-maybe">github.com/php-fp/php-fp-maybe</a></p></li><li><p><a href="https://github.com/chippyash/Monad">github.com/chippyash/Monad</a></p></li></ul><p></p><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-1" href="#footnote-anchor-1" class="footnote-number" contenteditable="false" target="_self">1</a><div class="footnote-content"><p>(en) <a href="https://hackage.haskell.org/package/base-4.20.0.1/docs/Data-Maybe.html">hackage.haskell.org/package/base-4.20.0.1/docs/Data-Maybe.html</a></p></div></div><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-2" href="#footnote-anchor-2" class="footnote-number" contenteditable="false" target="_self">2</a><div class="footnote-content"><p>(en) <a href="https://www.scala-lang.org">scala-lang.org</a></p></div></div><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-3" href="#footnote-anchor-3" class="footnote-number" contenteditable="false" target="_self">3</a><div class="footnote-content"><p>(en) <a href="https://en.wikipedia.org/wiki/Pure_function">en.wikipedia.org/wiki/Pure_function</a></p></div></div>]]></content:encoded></item><item><title><![CDATA[Ce este un server proxy, plus tutorial în C#]]></title><description><![CDATA[Scriem un server proxy &#238;n limbajul C#]]></description><link>https://stack.moustacios.dev/p/ce-este-un-server-proxy-plus-tutorial</link><guid isPermaLink="false">https://stack.moustacios.dev/p/ce-este-un-server-proxy-plus-tutorial</guid><dc:creator><![CDATA[Teo cel Mustăcios]]></dc:creator><pubDate>Tue, 05 Nov 2024 05:45:43 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/7a0dfc26-e9d8-4d81-8d63-2ef4cc598393_1024x288.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!3Uz_!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc84166e9-24e3-4f64-9399-e2e1941cc860_1024x288.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!3Uz_!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc84166e9-24e3-4f64-9399-e2e1941cc860_1024x288.png 424w, https://substackcdn.com/image/fetch/$s_!3Uz_!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc84166e9-24e3-4f64-9399-e2e1941cc860_1024x288.png 848w, https://substackcdn.com/image/fetch/$s_!3Uz_!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc84166e9-24e3-4f64-9399-e2e1941cc860_1024x288.png 1272w, https://substackcdn.com/image/fetch/$s_!3Uz_!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc84166e9-24e3-4f64-9399-e2e1941cc860_1024x288.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!3Uz_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc84166e9-24e3-4f64-9399-e2e1941cc860_1024x288.png" width="1024" height="288" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c84166e9-24e3-4f64-9399-e2e1941cc860_1024x288.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:288,&quot;width&quot;:1024,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:485043,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!3Uz_!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc84166e9-24e3-4f64-9399-e2e1941cc860_1024x288.png 424w, https://substackcdn.com/image/fetch/$s_!3Uz_!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc84166e9-24e3-4f64-9399-e2e1941cc860_1024x288.png 848w, https://substackcdn.com/image/fetch/$s_!3Uz_!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc84166e9-24e3-4f64-9399-e2e1941cc860_1024x288.png 1272w, https://substackcdn.com/image/fetch/$s_!3Uz_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc84166e9-24e3-4f64-9399-e2e1941cc860_1024x288.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Dac&#259; a&#539;i intrat odat&#259; <em>google.com</em>, atunci a&#539;i folosit un server proxy. Aproape toate serviciile oferite de companiile mari din tehnologie sunt conectate prin acest tip de servere, care elimin&#259; grija gestion&#259;rii infrastructurii la nivel de re&#539;ea &#537;i datacenter. Dou&#259; dintre cele mai interesante proiecte de software-defined networking sunt Pingora<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-1" href="#footnote-1" target="_self">1</a> &#537;i Katran<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-2" href="#footnote-2" target="_self">2</a>. Primul este un set de libr&#259;rii sau mai bine spus framework, &#238;n Rust, destinat integr&#259;rii de servicii de re&#539;ea cu un focus pe protocolul HTTP/S. Katran &#238;n schimb este o libr&#259;rie &#238;n C++, destinat&#259; forwarding-ului &#537;i serverelor de load-balancing la nivelul de transport - TCP/UDP. Poate fi folosit ca un program &#238;n kernel (BPF<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-3" href="#footnote-3" target="_self">3</a>) &#537;i folose&#537;te XDP<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-4" href="#footnote-4" target="_self">4</a> pentru performan&#539;&#259;. </p><h3>Tipuri de proxy servers</h3><p>Sunt dou&#259; tipuri de servere proxy, respectiv <em>forward proxy</em> &#537;i <em>reverse proxy</em>.</p><ul><li><p><strong>Forward proxy</strong>: un server care ruleaz&#259; local sau pe re&#539;eaua local&#259; &#537;i prin care se face conexiunea c&#259;tre unele domenii, porturi sau protocoale. Poate fi folosit pentru a filtra traficul de pe internet, sau a genera rapoarte legate de trafic.</p></li><li><p><strong>Reverse proxy</strong>: un server care deserve&#537;te un alt server, de exemplu un load balancer care serve&#537;te trafic pe un singur domeniu dar &#238;n spate se conecteaz&#259; la alte servere prin rota&#539;ie pentru a reduce &#238;nc&#259;rcarea &#537;i a men&#539;ine serviciile disponibile. </p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!CFbu!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fafcd5fed-d822-482a-bae5-385f98d12ef6_2344x1874.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!CFbu!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fafcd5fed-d822-482a-bae5-385f98d12ef6_2344x1874.png 424w, https://substackcdn.com/image/fetch/$s_!CFbu!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fafcd5fed-d822-482a-bae5-385f98d12ef6_2344x1874.png 848w, https://substackcdn.com/image/fetch/$s_!CFbu!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fafcd5fed-d822-482a-bae5-385f98d12ef6_2344x1874.png 1272w, https://substackcdn.com/image/fetch/$s_!CFbu!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fafcd5fed-d822-482a-bae5-385f98d12ef6_2344x1874.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!CFbu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fafcd5fed-d822-482a-bae5-385f98d12ef6_2344x1874.png" width="1456" height="1164" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/afcd5fed-d822-482a-bae5-385f98d12ef6_2344x1874.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1164,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:350566,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!CFbu!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fafcd5fed-d822-482a-bae5-385f98d12ef6_2344x1874.png 424w, https://substackcdn.com/image/fetch/$s_!CFbu!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fafcd5fed-d822-482a-bae5-385f98d12ef6_2344x1874.png 848w, https://substackcdn.com/image/fetch/$s_!CFbu!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fafcd5fed-d822-482a-bae5-385f98d12ef6_2344x1874.png 1272w, https://substackcdn.com/image/fetch/$s_!CFbu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fafcd5fed-d822-482a-bae5-385f98d12ef6_2344x1874.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">inforgrafic reverse proxy &#537;i forward proxy</figcaption></figure></div><h3>Un local (forward) proxy &#238;n limbajul C#</h3><p>Pentru acest tutorial voi folosi editorul JetBrains Rider, dar pute&#539;i folosi orice editor. Desigur primul pas este s&#259; creez proiectul, pe care &#238;l voi numi <strong>mscproxy</strong>:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!bilE!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc4e51bf9-63af-4165-a0ad-6941a252970a_1403x1077.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!bilE!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc4e51bf9-63af-4165-a0ad-6941a252970a_1403x1077.png 424w, https://substackcdn.com/image/fetch/$s_!bilE!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc4e51bf9-63af-4165-a0ad-6941a252970a_1403x1077.png 848w, https://substackcdn.com/image/fetch/$s_!bilE!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc4e51bf9-63af-4165-a0ad-6941a252970a_1403x1077.png 1272w, https://substackcdn.com/image/fetch/$s_!bilE!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc4e51bf9-63af-4165-a0ad-6941a252970a_1403x1077.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!bilE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc4e51bf9-63af-4165-a0ad-6941a252970a_1403x1077.png" width="1403" height="1077" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c4e51bf9-63af-4165-a0ad-6941a252970a_1403x1077.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1077,&quot;width&quot;:1403,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:135562,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!bilE!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc4e51bf9-63af-4165-a0ad-6941a252970a_1403x1077.png 424w, https://substackcdn.com/image/fetch/$s_!bilE!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc4e51bf9-63af-4165-a0ad-6941a252970a_1403x1077.png 848w, https://substackcdn.com/image/fetch/$s_!bilE!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc4e51bf9-63af-4165-a0ad-6941a252970a_1403x1077.png 1272w, https://substackcdn.com/image/fetch/$s_!bilE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc4e51bf9-63af-4165-a0ad-6941a252970a_1403x1077.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Vom face un proxy pentru protocolul HTTP, a&#537;adar vom folosi un <em>HttpListener(3). </em>&#206;n <em>Program.cs </em>ad&#259;ug&#259;m urm&#259;toarele linii:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Lwps!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F24adf005-c50e-4e0a-8c78-7ccdc4c6ca5d_1728x885.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Lwps!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F24adf005-c50e-4e0a-8c78-7ccdc4c6ca5d_1728x885.png 424w, https://substackcdn.com/image/fetch/$s_!Lwps!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F24adf005-c50e-4e0a-8c78-7ccdc4c6ca5d_1728x885.png 848w, https://substackcdn.com/image/fetch/$s_!Lwps!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F24adf005-c50e-4e0a-8c78-7ccdc4c6ca5d_1728x885.png 1272w, https://substackcdn.com/image/fetch/$s_!Lwps!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F24adf005-c50e-4e0a-8c78-7ccdc4c6ca5d_1728x885.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Lwps!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F24adf005-c50e-4e0a-8c78-7ccdc4c6ca5d_1728x885.png" width="1456" height="746" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/24adf005-c50e-4e0a-8c78-7ccdc4c6ca5d_1728x885.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:746,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:169024,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Lwps!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F24adf005-c50e-4e0a-8c78-7ccdc4c6ca5d_1728x885.png 424w, https://substackcdn.com/image/fetch/$s_!Lwps!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F24adf005-c50e-4e0a-8c78-7ccdc4c6ca5d_1728x885.png 848w, https://substackcdn.com/image/fetch/$s_!Lwps!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F24adf005-c50e-4e0a-8c78-7ccdc4c6ca5d_1728x885.png 1272w, https://substackcdn.com/image/fetch/$s_!Lwps!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F24adf005-c50e-4e0a-8c78-7ccdc4c6ca5d_1728x885.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Serverul nostru va asculta pe adresa local&#259; (127.0.0.1) pe portul 7777. Este important ca portul ales s&#259; fie mai mare de 1024 pentrua evita zona privilegiat&#259; &#537;i conflicte cu alte servicii. Putem compila acest program (desigur nu uita&#539;i s&#259; ad&#259;uga&#539;i acoladele care lispesc din screenshot) &#537;i mesajul se va afi&#537;a &#238;n consol&#259;: </p><pre><code><em>Listening on port 7777 ...</em></code></pre><h4>Procesarea request-ului</h4><p>Serverul nostru va primi o cerere de la un client (browser) pe care mai apoi o va procesa &#537;i va returna r&#259;spunsul, o pagin&#259; web sau un mesaj de eroare. Vom avea nevoie s&#259; proces&#259;m mai multe cereri &#238;n paralel, de aceea apel&#259;m la fire de execu&#539;ie (threads):</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!V5Y0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2cc8be92-8086-4cde-9559-86de8fe69572_1414x726.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!V5Y0!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2cc8be92-8086-4cde-9559-86de8fe69572_1414x726.png 424w, https://substackcdn.com/image/fetch/$s_!V5Y0!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2cc8be92-8086-4cde-9559-86de8fe69572_1414x726.png 848w, https://substackcdn.com/image/fetch/$s_!V5Y0!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2cc8be92-8086-4cde-9559-86de8fe69572_1414x726.png 1272w, https://substackcdn.com/image/fetch/$s_!V5Y0!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2cc8be92-8086-4cde-9559-86de8fe69572_1414x726.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!V5Y0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2cc8be92-8086-4cde-9559-86de8fe69572_1414x726.png" width="1414" height="726" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2cc8be92-8086-4cde-9559-86de8fe69572_1414x726.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:726,&quot;width&quot;:1414,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:95393,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!V5Y0!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2cc8be92-8086-4cde-9559-86de8fe69572_1414x726.png 424w, https://substackcdn.com/image/fetch/$s_!V5Y0!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2cc8be92-8086-4cde-9559-86de8fe69572_1414x726.png 848w, https://substackcdn.com/image/fetch/$s_!V5Y0!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2cc8be92-8086-4cde-9559-86de8fe69572_1414x726.png 1272w, https://substackcdn.com/image/fetch/$s_!V5Y0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2cc8be92-8086-4cde-9559-86de8fe69572_1414x726.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Clasa <code>ProxyThreadRelay </code>implementeaz&#259; procesarea request-ului &#238;n contextul pasat de la <code>listener</code> &#537;i va fi rulat&#259; &#238;ntr-un fir de execu&#539;ie separat de programul (serverul) nostru care ascult&#259; pentru cereri noi. Aceasta este resposabil&#259; de transmiterea request-ului c&#259;tre server &#537;i are dou&#259; metode <code>processRequest()</code> &#537;i <code>asyncResponseCallBack()</code>:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!CKz7!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F62462efc-55a8-4610-83f5-19dad39121ac_1412x1182.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!CKz7!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F62462efc-55a8-4610-83f5-19dad39121ac_1412x1182.png 424w, https://substackcdn.com/image/fetch/$s_!CKz7!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F62462efc-55a8-4610-83f5-19dad39121ac_1412x1182.png 848w, https://substackcdn.com/image/fetch/$s_!CKz7!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F62462efc-55a8-4610-83f5-19dad39121ac_1412x1182.png 1272w, https://substackcdn.com/image/fetch/$s_!CKz7!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F62462efc-55a8-4610-83f5-19dad39121ac_1412x1182.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!CKz7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F62462efc-55a8-4610-83f5-19dad39121ac_1412x1182.png" width="1412" height="1182" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/62462efc-55a8-4610-83f5-19dad39121ac_1412x1182.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1182,&quot;width&quot;:1412,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:169555,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!CKz7!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F62462efc-55a8-4610-83f5-19dad39121ac_1412x1182.png 424w, https://substackcdn.com/image/fetch/$s_!CKz7!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F62462efc-55a8-4610-83f5-19dad39121ac_1412x1182.png 848w, https://substackcdn.com/image/fetch/$s_!CKz7!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F62462efc-55a8-4610-83f5-19dad39121ac_1412x1182.png 1272w, https://substackcdn.com/image/fetch/$s_!CKz7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F62462efc-55a8-4610-83f5-19dad39121ac_1412x1182.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Salv&#259;m contextul ca proprietate, iar &#238;n processRequest contruim un HttpWebRequest din url-ul specific contextului. Re-set&#259;m ni&#537;te parametrii (keepAlive &#537;i UserAgent) &#537;i la final lans&#259;m cererea cu pasarea metodei care va procesa r&#259;spunsul.</p><p>asyncResponseCallBack, dup&#259; cum &#238;i spune &#537;i prefixul este o metod&#259; asincron&#259;, care va fi chemat&#259; atunci c&#226;nd vine un r&#259;spuns de la serverul care prime&#537;te cererea &#238;naintat&#259; de proxy:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!8SMA!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae1a05e7-6c9c-471e-b6bc-4f3699d3622e_1865x1219.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!8SMA!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae1a05e7-6c9c-471e-b6bc-4f3699d3622e_1865x1219.png 424w, https://substackcdn.com/image/fetch/$s_!8SMA!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae1a05e7-6c9c-471e-b6bc-4f3699d3622e_1865x1219.png 848w, https://substackcdn.com/image/fetch/$s_!8SMA!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae1a05e7-6c9c-471e-b6bc-4f3699d3622e_1865x1219.png 1272w, https://substackcdn.com/image/fetch/$s_!8SMA!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae1a05e7-6c9c-471e-b6bc-4f3699d3622e_1865x1219.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!8SMA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae1a05e7-6c9c-471e-b6bc-4f3699d3622e_1865x1219.png" width="1456" height="952" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ae1a05e7-6c9c-471e-b6bc-4f3699d3622e_1865x1219.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:952,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:202108,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!8SMA!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae1a05e7-6c9c-471e-b6bc-4f3699d3622e_1865x1219.png 424w, https://substackcdn.com/image/fetch/$s_!8SMA!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae1a05e7-6c9c-471e-b6bc-4f3699d3622e_1865x1219.png 848w, https://substackcdn.com/image/fetch/$s_!8SMA!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae1a05e7-6c9c-471e-b6bc-4f3699d3622e_1865x1219.png 1272w, https://substackcdn.com/image/fetch/$s_!8SMA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fae1a05e7-6c9c-471e-b6bc-4f3699d3622e_1865x1219.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Aici citim r&#259;spunsul, &#238;l transform&#259;m &#238;ntr-un byte array &#537;i &#238;l copiem &#238;n <code>responseStream </code>care va fi trimis c&#259;tre clientul serverului nostru proxy. Aici am pus &#537;i un comentariu, unde putem modifica r&#259;spunsul &#238;n cazul &#238;n care acesta este <code>text/html</code>. </p><h4>RequestState </h4><p>Aceast&#259; clas&#259; este un container pentru <code>webRequest </code>&#537;i <code>context</code>, &#537;i ne ajut&#259; s&#259; pas&#259;m un obiect unic &#238;ntre cele dou&#259; metode de mai sus de la processRequest la asyncResponseCallBack:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!GU4Z!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F148a1692-1050-45aa-b619-970ba7576625_1350x501.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!GU4Z!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F148a1692-1050-45aa-b619-970ba7576625_1350x501.png 424w, https://substackcdn.com/image/fetch/$s_!GU4Z!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F148a1692-1050-45aa-b619-970ba7576625_1350x501.png 848w, https://substackcdn.com/image/fetch/$s_!GU4Z!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F148a1692-1050-45aa-b619-970ba7576625_1350x501.png 1272w, https://substackcdn.com/image/fetch/$s_!GU4Z!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F148a1692-1050-45aa-b619-970ba7576625_1350x501.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!GU4Z!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F148a1692-1050-45aa-b619-970ba7576625_1350x501.png" width="1350" height="501" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/148a1692-1050-45aa-b619-970ba7576625_1350x501.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:501,&quot;width&quot;:1350,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:61273,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!GU4Z!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F148a1692-1050-45aa-b619-970ba7576625_1350x501.png 424w, https://substackcdn.com/image/fetch/$s_!GU4Z!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F148a1692-1050-45aa-b619-970ba7576625_1350x501.png 848w, https://substackcdn.com/image/fetch/$s_!GU4Z!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F148a1692-1050-45aa-b619-970ba7576625_1350x501.png 1272w, https://substackcdn.com/image/fetch/$s_!GU4Z!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F148a1692-1050-45aa-b619-970ba7576625_1350x501.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h3>Conectarea cu proxy</h3><p>Prima men&#539;iune ar fi c&#259; proxy-ul nostru este doat HTTP, a&#537;adar nu ne vom putea conecta la servere care for&#539;eaz&#259; conexiuni prin HTTPS. Vom porni aplica&#539;ia &#537;i serverul nostru, care va asculta pe portul 7777, apoi folosim utilitarul <code>Invoke-WebRequest</code> din Powershell pentru a ne conecta prin proxy la www.example.com:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ablV!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8efb297-bbae-4f3c-be16-e859b451ee96_1794x276.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ablV!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8efb297-bbae-4f3c-be16-e859b451ee96_1794x276.png 424w, https://substackcdn.com/image/fetch/$s_!ablV!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8efb297-bbae-4f3c-be16-e859b451ee96_1794x276.png 848w, https://substackcdn.com/image/fetch/$s_!ablV!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8efb297-bbae-4f3c-be16-e859b451ee96_1794x276.png 1272w, https://substackcdn.com/image/fetch/$s_!ablV!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8efb297-bbae-4f3c-be16-e859b451ee96_1794x276.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ablV!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8efb297-bbae-4f3c-be16-e859b451ee96_1794x276.png" width="1456" height="224" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c8efb297-bbae-4f3c-be16-e859b451ee96_1794x276.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:224,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:47038,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ablV!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8efb297-bbae-4f3c-be16-e859b451ee96_1794x276.png 424w, https://substackcdn.com/image/fetch/$s_!ablV!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8efb297-bbae-4f3c-be16-e859b451ee96_1794x276.png 848w, https://substackcdn.com/image/fetch/$s_!ablV!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8efb297-bbae-4f3c-be16-e859b451ee96_1794x276.png 1272w, https://substackcdn.com/image/fetch/$s_!ablV!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8efb297-bbae-4f3c-be16-e859b451ee96_1794x276.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Iar &#238;n consola IDE-ului vor ap&#259;rea mesajele de log:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!xM03!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F663c7c68-6843-4e8e-9f7e-0de9fda86aff_2230x369.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!xM03!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F663c7c68-6843-4e8e-9f7e-0de9fda86aff_2230x369.png 424w, https://substackcdn.com/image/fetch/$s_!xM03!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F663c7c68-6843-4e8e-9f7e-0de9fda86aff_2230x369.png 848w, https://substackcdn.com/image/fetch/$s_!xM03!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F663c7c68-6843-4e8e-9f7e-0de9fda86aff_2230x369.png 1272w, https://substackcdn.com/image/fetch/$s_!xM03!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F663c7c68-6843-4e8e-9f7e-0de9fda86aff_2230x369.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!xM03!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F663c7c68-6843-4e8e-9f7e-0de9fda86aff_2230x369.png" width="1456" height="241" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/663c7c68-6843-4e8e-9f7e-0de9fda86aff_2230x369.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:241,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:69716,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!xM03!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F663c7c68-6843-4e8e-9f7e-0de9fda86aff_2230x369.png 424w, https://substackcdn.com/image/fetch/$s_!xM03!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F663c7c68-6843-4e8e-9f7e-0de9fda86aff_2230x369.png 848w, https://substackcdn.com/image/fetch/$s_!xM03!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F663c7c68-6843-4e8e-9f7e-0de9fda86aff_2230x369.png 1272w, https://substackcdn.com/image/fetch/$s_!xM03!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F663c7c68-6843-4e8e-9f7e-0de9fda86aff_2230x369.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://stack.moustacios.dev/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption"><em>Moustacios.Dev este o publica&#539;ie sus&#539;inut&#259; de voi, de comunitate. Pentru a primi post&#259;ri noi &#537;i pentru a-mi sus&#539;ine munca, v&#259; invit s&#259; v&#259; abona&#539;i:</em></p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-1" href="#footnote-anchor-1" class="footnote-number" contenteditable="false" target="_self">1</a><div class="footnote-content"><p>(en) <a href="https://blog.cloudflare.com/pingora-open-source">blog.cloudflare.com/pingora-open-source</a></p></div></div><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-2" href="#footnote-anchor-2" class="footnote-number" contenteditable="false" target="_self">2</a><div class="footnote-content"><p>(en) <a href="https://github.com/facebookincubator/katran">github.com/facebookincubator/katran</a></p></div></div><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-3" href="#footnote-anchor-3" class="footnote-number" contenteditable="false" target="_self">3</a><div class="footnote-content"><p>(en) <a href="https://www.tigera.io/learn/guides/ebpf/">www.tigera.io/learn/guides/ebpf/</a></p></div></div><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-4" href="#footnote-anchor-4" class="footnote-number" contenteditable="false" target="_self">4</a><div class="footnote-content"><p>(en) <a href="https://en.wikipedia.org/wiki/Express_Data_Path">en.wikipedia.org/wiki/Express_Data_Path</a></p></div></div>]]></content:encoded></item><item><title><![CDATA[UUID, ULID, CUID, sau nanoID?]]></title><description><![CDATA[Ce sunt toate astea care se termin&#259; cu ID &#537;i de ce avem nevoie de ele?]]></description><link>https://stack.moustacios.dev/p/uuid-ulid-cuid-sau-nanoid</link><guid isPermaLink="false">https://stack.moustacios.dev/p/uuid-ulid-cuid-sau-nanoid</guid><dc:creator><![CDATA[Teo cel Mustăcios]]></dc:creator><pubDate>Tue, 17 Sep 2024 06:49:51 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!ECbZ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3542dd61-4beb-4094-a399-a66b72bdb7b8_1230x690.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ECbZ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3542dd61-4beb-4094-a399-a66b72bdb7b8_1230x690.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ECbZ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3542dd61-4beb-4094-a399-a66b72bdb7b8_1230x690.jpeg 424w, https://substackcdn.com/image/fetch/$s_!ECbZ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3542dd61-4beb-4094-a399-a66b72bdb7b8_1230x690.jpeg 848w, https://substackcdn.com/image/fetch/$s_!ECbZ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3542dd61-4beb-4094-a399-a66b72bdb7b8_1230x690.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!ECbZ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3542dd61-4beb-4094-a399-a66b72bdb7b8_1230x690.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ECbZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3542dd61-4beb-4094-a399-a66b72bdb7b8_1230x690.jpeg" width="1230" height="690" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3542dd61-4beb-4094-a399-a66b72bdb7b8_1230x690.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:690,&quot;width&quot;:1230,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:30585,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ECbZ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3542dd61-4beb-4094-a399-a66b72bdb7b8_1230x690.jpeg 424w, https://substackcdn.com/image/fetch/$s_!ECbZ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3542dd61-4beb-4094-a399-a66b72bdb7b8_1230x690.jpeg 848w, https://substackcdn.com/image/fetch/$s_!ECbZ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3542dd61-4beb-4094-a399-a66b72bdb7b8_1230x690.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!ECbZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3542dd61-4beb-4094-a399-a66b72bdb7b8_1230x690.jpeg 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>&#536;tim cu to&#539;ii de la cursul de baze de date &#537;i MySQL c&#259; orice r&#226;nd ar trebui s&#259; fie identificat printr-un num&#259;r unic, respectiv un ID, care dac&#259; este &#537;i index primar face accesarea acelui r&#226;nd super rapid&#259;. Dac&#259; a&#539;i chiulit de la curs&#184; nu-i bai, dar v&#259; aten&#539;ionez c&#259; acest articol este mai tehnic! </p><h2>Ce-i un UUID?</h2><p>A&#537;adar, pe o baz&#259; de date rela&#539;ional&#259; avem identificatori ca &#537;i chei primare pentru a accesa acele valori f&#259;r&#259; a penaliza performan&#539;a liniar cu ad&#259;ugarea de r&#226;nduri noi. Care altfel, ar fi cel mai nefast scenariu pentru o baz&#259; de date!</p><p>Indec&#537;ii clasici, sunt de obicei numere pozitive (unsigned int sau bigint), tipuri destul de mari pentru a permite valori de ordinul miliardelor, &#537;i deci a sus&#539;ine un num&#259;r foarte mare de &#238;nregistr&#259;ri. &#206;ns&#259; aceste valori se repet&#259; de la tabel la tabel, avem indec&#537;ii 49, 50 &#537;i 51 pe tabela <em>users </em>&#537;i 49, 50 &#537;i 51 &#537;i pe tabela <em>admin_users</em>. ID-ul 21 poate apar&#539;ine la doi utilizatri, unul fiind admin. </p><p>Apoi, ace&#537;ti indec&#537;i sunt secven&#539;iali: <em>1, 2, 4, 6, 7, 9</em>; &#537;i nu se pot genera valori dac&#259; sistemele nu sunt conectate cu baza de date pentru a accesa secven&#539;a precedent&#259;, deci nu ofer&#259; <a href="https://stack.moustacios.dev/p/sisteme-de-baze-de-date-teorema-cap">toleran&#539;&#259; la parti&#539;ionare</a>. A&#537;a s-a n&#259;scut conceptul de <strong>UUID - Universally Unique ID</strong>.</p><p>Aceste valori sunt stocate &#238;n binar sau ca &#537;iruri de caractere, &#537;i sunt generate cu scopul de a identifica o &#238;ntregistrare unic&#259; pe unul sau mai multe seturi de date.</p><h3>Scenarii &#238;n care apel&#259;m la UUID-uri</h3><p>De cele mai multe ori uuid-urile sunt folosite pentru a oferi referin&#539;e &#238;ntre sisteme care fie sunt decuplate sau ne dorim s&#259; poat&#259; func&#539;iona independent unul de altul. </p><h5>Un frontend poate genera UUID-uri</h5><p>Cel mai mare avantaj al UUID-urilor este c&#259; pot genera unul f&#259;r&#259; a cunoa&#537;te secven&#539;a precedent&#259;, stocat&#259; pe tabela de date. &#206;n cazul MySQL de exemplu func&#539;ia <code>mysql_insert_id </code>este folosit&#259; pentru a determina ultima valoare secven&#539;ial&#259;, &#238;nainte de a insera un r&#226;nd nou, dar pentru asta e nevoie s&#259; fim conecta&#539;i la serverul MySQL. Spre deosebire, un UUID, poate fi generat din cod, chiar dac&#259; aplica&#539;ia nu este conectat&#259; la server. &#536;i de exemplu pot genera &#537;i afi&#537;a un URL pentru o imagine care urmeaz&#259; s&#259; fie prelucrat&#259; de server, &#238;nainte ca imaginea s&#259; fie efectiv &#238;nc&#259;rcat&#259;.</p><h5>Collec&#539;ii de date fault-tolerant</h5><p>Un alt scenariu este acela &#238;n care am mai multe aplica&#539;ii, &#537;i toate vor stoca date &#238;ntr-o colec&#539;ie distribuit&#259; pe mai multe ma&#537;ini sau noduri, pentru a prioritiza salvarea datelor, indiferent dac&#259; unul sau mai multe noduri sunt offline.</p><h5>Prevenirea de race-conditions &#537;i parti&#539;ionare</h5><p>Uneori avem nevoie de s&#259; putem stoca date &#238;ntr-un ritm sus&#539;inut &#537;i cu laten&#539;e foarte mici. De exemplu mesajele de log generate de o aplica&#539;ie sau tranzac&#539;ii monetare care este imperativ s&#259; fie stocate chiar dac&#259; &#238;nregistrarea este duplicat&#259; sau incomplet&#259;.  </p><h3>Standardul oficial UUID &#537;i copii lui</h3><p>RFC 9562<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-1" href="#footnote-1" target="_self">1</a> este specifica&#539;ia de facto pentru sistemele &#537;i libr&#259;riile care genereaz&#259; identificatori globali unici. Sunt mai multe versiuni &#238;n aceast&#259; specifica&#539;ie. Din p&#259;cate unele versiuni nu sunt compatibile &#238;ntre ele. Iar versiunea 2 este de evitat. Cea mai popular&#259; &#537;i mai stabil&#259; versiune este UUIDv4, &#537;i este cea recomandat&#259; la vremea acestui articol. </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!YVDg!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F865fa05e-2f06-4510-b5a1-2a6106dbb4bc_1008x847.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!YVDg!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F865fa05e-2f06-4510-b5a1-2a6106dbb4bc_1008x847.png 424w, https://substackcdn.com/image/fetch/$s_!YVDg!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F865fa05e-2f06-4510-b5a1-2a6106dbb4bc_1008x847.png 848w, https://substackcdn.com/image/fetch/$s_!YVDg!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F865fa05e-2f06-4510-b5a1-2a6106dbb4bc_1008x847.png 1272w, https://substackcdn.com/image/fetch/$s_!YVDg!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F865fa05e-2f06-4510-b5a1-2a6106dbb4bc_1008x847.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!YVDg!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F865fa05e-2f06-4510-b5a1-2a6106dbb4bc_1008x847.png" width="1008" height="847" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/865fa05e-2f06-4510-b5a1-2a6106dbb4bc_1008x847.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:847,&quot;width&quot;:1008,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:263628,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!YVDg!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F865fa05e-2f06-4510-b5a1-2a6106dbb4bc_1008x847.png 424w, https://substackcdn.com/image/fetch/$s_!YVDg!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F865fa05e-2f06-4510-b5a1-2a6106dbb4bc_1008x847.png 848w, https://substackcdn.com/image/fetch/$s_!YVDg!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F865fa05e-2f06-4510-b5a1-2a6106dbb4bc_1008x847.png 1272w, https://substackcdn.com/image/fetch/$s_!YVDg!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F865fa05e-2f06-4510-b5a1-2a6106dbb4bc_1008x847.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h5>Dincolo de standard</h5><p>Pe l&#226;ng&#259; RFC, sunt &#537;i alte specifica&#539;ii pentru UUID-uri. Desigur scopul unui generator este de a reduce coliziunile, dar &#238;n func&#539;ie de nevoile aplica&#539;iei se poate folosi un generator care admite o rat&#259; de coliziuni, oferind &#238;n schimb vitez&#259;, suport pentru odronare sau variante mai scurte &#537;i mai rapid de transmis. </p><p><strong>ULID</strong><a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-2" href="#footnote-2" target="_self">2</a>: este o alternativ&#259; care genereaz&#259; uuid-uri care sunt url-safe, f&#259;r&#259; caractere speciale &#537;i sortabile. Singura limitare este c&#259; se pot genera maxim 2<sup>80</sup> versiuni pe millisecond&#259;. </p><p><strong>NanoID</strong><a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-3" href="#footnote-3" target="_self">3</a>: ca &#537;i ulid, genereaz&#259; &#537;iruri url-safe, oferind vitez&#259; sporit&#259; de generare. Permite configurarea lungimii, cu riscul de a avea o &#537;ans&#259; mai mare de coliziuni, &#238;ns&#259; &#537;irurile generate nu ofer&#259; suport pentru ordonare.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://stack.moustacios.dev/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption"><em>Moustacios.Dev este o publica&#539;ie sus&#539;inut&#259; de voi, de comunitate. Pentru a primi post&#259;ri noi &#537;i pentru a-mi sus&#539;ine munca, v&#259; invit s&#259; v&#259; abona&#539;i:</em></p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p><strong>TypeID</strong><a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-4" href="#footnote-4" target="_self">4</a>: &#238;mbin&#259; sportul pentru ordonare cu un prefix, care indic&#259; tipul sau entitatea referen&#539;iat&#259;. </p><p>Alte versiuni notabile: <a href="https://github.com/paralleldrive/cuid2">CUID</a>, <a href="https://github.com/dustinrouillard/snowflake-id">Snowflake ID</a>, <a href="https://github.com/sqids">sqids</a>.</p><h4>UUID ca &#537;i cheie primar&#259;</h4><p>R&#259;spunsul scurt este <em>NU</em>, adic&#259; evita&#539;i folosirea de UUID-uri ca &#537;i chei primare. De&#537;i tenta&#539;ia e mare &#537;i cu siguran&#539;&#259; ve&#539;i g&#259;si pe web surse care decl&#259;r&#259; c&#259; versiunea lor este bun&#259; pentru chei primare. Dar pe m&#259;sur&#259; de setul de date cre&#537;te, accesul &#537;i inser&#539;ia va fi &#238;ngreunat&#259; deoarece baza de date nu poate indexa &#537;i balansa eficient &#238;n lipsa unor chei implicit sortabile. Totu&#537;i &#539;in s&#259; men&#539;iionez c&#259; asta este specific bazelor de date rela&#539;ionale (*SQL) care aplic&#259; indexare prin algoritmi binary tree sau B-Tree. &#206;n cazul bazelor de date NoSQL, indexarea se face prin algoritmi de hashing &#537;i aici cheile primare sunt UUID-uri.</p><p>A&#537;adar, r&#259;spunsul mai lung este &#238;n func&#539;ie de sistemul de baze de date folosit de aplica&#539;ie, dar pute&#539;i oric&#226;nd folosi UUID-uri ca &#537;i chei secundare.</p><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-1" href="#footnote-anchor-1" class="footnote-number" contenteditable="false" target="_self">1</a><div class="footnote-content"><p><a href="https://www.rfc-editor.org/rfc/rfc9562.html">(en) RFC 9562 Universally Unique IDentifiers (UUIDs)</a></p></div></div><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-2" href="#footnote-anchor-2" class="footnote-number" contenteditable="false" target="_self">2</a><div class="footnote-content"><p><a href="https://github.com/ulid/spec">(en) github.com/ulid/spec</a></p></div></div><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-3" href="#footnote-anchor-3" class="footnote-number" contenteditable="false" target="_self">3</a><div class="footnote-content"><p><a href="https://github.com/ai/nanoid">(en) github.com/ai/nanoid</a></p></div></div><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-4" href="#footnote-anchor-4" class="footnote-number" contenteditable="false" target="_self">4</a><div class="footnote-content"><p><a href="https://github.com/jetify-com/typeid">(en) github.com/jetify-com/typeid</a></p></div></div>]]></content:encoded></item><item><title><![CDATA[PHP Fibers - un exemplu practic]]></title><description><![CDATA[go are co-rutine, php are fibers]]></description><link>https://stack.moustacios.dev/p/php-fibers-un-exemplu-practic</link><guid isPermaLink="false">https://stack.moustacios.dev/p/php-fibers-un-exemplu-practic</guid><dc:creator><![CDATA[Teo cel Mustăcios]]></dc:creator><pubDate>Thu, 08 Aug 2024 04:59:03 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!4pYn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa98c8daf-94d9-4530-a5de-a9bd365584a9_1366x768.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!4pYn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa98c8daf-94d9-4530-a5de-a9bd365584a9_1366x768.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!4pYn!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa98c8daf-94d9-4530-a5de-a9bd365584a9_1366x768.png 424w, https://substackcdn.com/image/fetch/$s_!4pYn!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa98c8daf-94d9-4530-a5de-a9bd365584a9_1366x768.png 848w, https://substackcdn.com/image/fetch/$s_!4pYn!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa98c8daf-94d9-4530-a5de-a9bd365584a9_1366x768.png 1272w, https://substackcdn.com/image/fetch/$s_!4pYn!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa98c8daf-94d9-4530-a5de-a9bd365584a9_1366x768.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!4pYn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa98c8daf-94d9-4530-a5de-a9bd365584a9_1366x768.png" width="1366" height="768" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a98c8daf-94d9-4530-a5de-a9bd365584a9_1366x768.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:768,&quot;width&quot;:1366,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1938387,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!4pYn!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa98c8daf-94d9-4530-a5de-a9bd365584a9_1366x768.png 424w, https://substackcdn.com/image/fetch/$s_!4pYn!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa98c8daf-94d9-4530-a5de-a9bd365584a9_1366x768.png 848w, https://substackcdn.com/image/fetch/$s_!4pYn!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa98c8daf-94d9-4530-a5de-a9bd365584a9_1366x768.png 1272w, https://substackcdn.com/image/fetch/$s_!4pYn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa98c8daf-94d9-4530-a5de-a9bd365584a9_1366x768.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Odat&#259; cu versiunea 8.1, PHP a introdus <em>fibers<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-1" href="#footnote-1" target="_self">1</a>. </em>Dar fibers, nu trebuie confundat cu fire de execu&#539;ie, respectiv threads. A&#537;adar pentru a elimina confuzia, &#537;i a ne face o imagine despre conceptul de <em>asynchronous code</em>, o s&#259; v&#259; ar&#259;t &#238;n aceste r&#226;nduri c&#226;teva exemple practice: </p><h3>Ce sunt fibers? </h3><p>&#206;n PHP, fibers sunt o strategie de a gr&#259;bi execu&#539;ia unor task-uri, iar fibrele se pot executa &#537;i &#238;n paralel - de unde &#537;i confuzia cu fire de execu&#539;ie. &#206;ns&#259;, spre deosebire de threads, fibers nu execut&#259; cod PHP &#238;n paralel - PHP este single-threaded. Dar ne permit s&#259; &#8221;&#238;mpachet&#259;m&#8221; un task extern, care poate fi executat &#238;n paralel. </p><p><em>Fibers </em>sunt eficace doar dac&#259; se &#238;ndeplinesc urm&#259;toarele condi&#539;ii: </p><ul><li><p><strong>Interac&#539;ionezi cu resurse externe aplica&#539;iei</strong>, al c&#259;ror status poate fi procesat &#238;n paralel cu rularea aplica&#539;iei.  De exemplu un sub-proces sau sub-shell sau o cerere &#238;n re&#539;ea.</p></li><li><p><strong>Po&#539;i cere sau interac&#539;iona cu resursa, f&#259;r&#259; s&#259; blochezi execu&#539;ia codului</strong>. De exemplu o cerere c&#259;tre baza de date, de a c&#259;rui rezultat depinde o condi&#539;ie ulterioar&#259;, nu poate fi executat&#259; &#238;n paralel - codul a&#537;teapt&#259; rezultatul s&#259; continue.</p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!tMA1!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9753196-e79a-448b-ad70-0d19cf6044c2_2786x1619.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!tMA1!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9753196-e79a-448b-ad70-0d19cf6044c2_2786x1619.png 424w, https://substackcdn.com/image/fetch/$s_!tMA1!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9753196-e79a-448b-ad70-0d19cf6044c2_2786x1619.png 848w, https://substackcdn.com/image/fetch/$s_!tMA1!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9753196-e79a-448b-ad70-0d19cf6044c2_2786x1619.png 1272w, https://substackcdn.com/image/fetch/$s_!tMA1!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9753196-e79a-448b-ad70-0d19cf6044c2_2786x1619.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!tMA1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9753196-e79a-448b-ad70-0d19cf6044c2_2786x1619.png" width="1456" height="846" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b9753196-e79a-448b-ad70-0d19cf6044c2_2786x1619.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:846,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:256704,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!tMA1!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9753196-e79a-448b-ad70-0d19cf6044c2_2786x1619.png 424w, https://substackcdn.com/image/fetch/$s_!tMA1!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9753196-e79a-448b-ad70-0d19cf6044c2_2786x1619.png 848w, https://substackcdn.com/image/fetch/$s_!tMA1!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9753196-e79a-448b-ad70-0d19cf6044c2_2786x1619.png 1272w, https://substackcdn.com/image/fetch/$s_!tMA1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9753196-e79a-448b-ad70-0d19cf6044c2_2786x1619.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Fig 1. Succesiune de pa&#537;i care pot fi optimiza&#539;i folosind fibers</figcaption></figure></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!6igX!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc18d750-c32a-4081-97f9-49bfbe253d6c_2804x965.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!6igX!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc18d750-c32a-4081-97f9-49bfbe253d6c_2804x965.png 424w, https://substackcdn.com/image/fetch/$s_!6igX!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc18d750-c32a-4081-97f9-49bfbe253d6c_2804x965.png 848w, https://substackcdn.com/image/fetch/$s_!6igX!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc18d750-c32a-4081-97f9-49bfbe253d6c_2804x965.png 1272w, https://substackcdn.com/image/fetch/$s_!6igX!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc18d750-c32a-4081-97f9-49bfbe253d6c_2804x965.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!6igX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc18d750-c32a-4081-97f9-49bfbe253d6c_2804x965.png" width="1456" height="501" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/dc18d750-c32a-4081-97f9-49bfbe253d6c_2804x965.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:501,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:112842,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!6igX!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc18d750-c32a-4081-97f9-49bfbe253d6c_2804x965.png 424w, https://substackcdn.com/image/fetch/$s_!6igX!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc18d750-c32a-4081-97f9-49bfbe253d6c_2804x965.png 848w, https://substackcdn.com/image/fetch/$s_!6igX!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc18d750-c32a-4081-97f9-49bfbe253d6c_2804x965.png 1272w, https://substackcdn.com/image/fetch/$s_!6igX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc18d750-c32a-4081-97f9-49bfbe253d6c_2804x965.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Fig 2. Succesiunea nu poate fi optimizat&#259;</figcaption></figure></div><h2>Exemplu practic: generarea de video din imagini cu ffmpeg</h2><p>Pentru o demonstra&#539;ie, ne propunem s&#259; gener&#259;m c&#226;te un clip video (un reel) pentru imaginile de cu extensia jpg, salvate &#238;n trei directoare, folosind utilitarul <code>ffmpeg</code><a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-2" href="#footnote-2" target="_self">2</a>. </p><p>Imaginile mele sunt plasate, &#238;n directoarele <em>clip1</em>, <em>clip2</em>, &#537;i <em>clip3 </em>sub directorul assets al proiectlui: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!HRM2!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe357d154-3f4e-4933-93ea-eade1822390c_1963x1002.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!HRM2!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe357d154-3f4e-4933-93ea-eade1822390c_1963x1002.png 424w, https://substackcdn.com/image/fetch/$s_!HRM2!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe357d154-3f4e-4933-93ea-eade1822390c_1963x1002.png 848w, https://substackcdn.com/image/fetch/$s_!HRM2!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe357d154-3f4e-4933-93ea-eade1822390c_1963x1002.png 1272w, https://substackcdn.com/image/fetch/$s_!HRM2!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe357d154-3f4e-4933-93ea-eade1822390c_1963x1002.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!HRM2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe357d154-3f4e-4933-93ea-eade1822390c_1963x1002.png" width="1456" height="743" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e357d154-3f4e-4933-93ea-eade1822390c_1963x1002.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:743,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:161568,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!HRM2!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe357d154-3f4e-4933-93ea-eade1822390c_1963x1002.png 424w, https://substackcdn.com/image/fetch/$s_!HRM2!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe357d154-3f4e-4933-93ea-eade1822390c_1963x1002.png 848w, https://substackcdn.com/image/fetch/$s_!HRM2!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe357d154-3f4e-4933-93ea-eade1822390c_1963x1002.png 1272w, https://substackcdn.com/image/fetch/$s_!HRM2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe357d154-3f4e-4933-93ea-eade1822390c_1963x1002.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Pentru a converti fiecare dintre aceste colec&#539;ii de imagini &#238;ntr-un video, unul dup&#259; altul sincron, a&#537; putea folosi urm&#259;torul cod:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!post!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd2a7c57d-88a5-41bf-8927-df97fd29c04c_1943x1297.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!post!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd2a7c57d-88a5-41bf-8927-df97fd29c04c_1943x1297.png 424w, https://substackcdn.com/image/fetch/$s_!post!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd2a7c57d-88a5-41bf-8927-df97fd29c04c_1943x1297.png 848w, https://substackcdn.com/image/fetch/$s_!post!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd2a7c57d-88a5-41bf-8927-df97fd29c04c_1943x1297.png 1272w, https://substackcdn.com/image/fetch/$s_!post!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd2a7c57d-88a5-41bf-8927-df97fd29c04c_1943x1297.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!post!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd2a7c57d-88a5-41bf-8927-df97fd29c04c_1943x1297.png" width="1456" height="972" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d2a7c57d-88a5-41bf-8927-df97fd29c04c_1943x1297.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:972,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:208645,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!post!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd2a7c57d-88a5-41bf-8927-df97fd29c04c_1943x1297.png 424w, https://substackcdn.com/image/fetch/$s_!post!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd2a7c57d-88a5-41bf-8927-df97fd29c04c_1943x1297.png 848w, https://substackcdn.com/image/fetch/$s_!post!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd2a7c57d-88a5-41bf-8927-df97fd29c04c_1943x1297.png 1272w, https://substackcdn.com/image/fetch/$s_!post!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd2a7c57d-88a5-41bf-8927-df97fd29c04c_1943x1297.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Pe laptopul meu se execut&#259; destul de rapid, respectiv &#238;n 2.9 secunde: </p><pre><code>4 folders processed in 2.9 seconds</code></pre><h3>Un exec care nu blocheaz&#259;</h3><p><code>exec</code>-ul folosit mai sus, este o opera&#539;iune care blocheaz&#259; - se converte&#537;te fiecare foder unul dup&#259; altul. &#206;n ordinea definit&#259;. Pentru generarea clipului 4 (<em>clip4.mp4</em>), a&#537;tept&#259;m prelucrarea tuturor celor 3 foldere precedente. Pentru a folosi fibers, mai &#238;nt&#226;i este necesar s&#259; convertim aceste exec-uri la o variant&#259; care nu blocheaz&#259; &#537;i s&#259; o export&#259;m &#238;ntr-o func&#539;ie.</p><p>Avem nevoie de <code>proc_open</code><a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-3" href="#footnote-3" target="_self">3</a>: acesta nu blocheaz&#259; execu&#539;ia scriptului p&#226;n&#259; la finalizarea comenzii ffmpeg, ci lanseaz&#259; un shell pe l&#226;ng&#259; script-ul de php la care ne putem conecta, la nevoie pentru a verifica statusul comenzii: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!YD62!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Febc5854c-dd56-491f-97e9-479fd2670980_4616x6204.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!YD62!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Febc5854c-dd56-491f-97e9-479fd2670980_4616x6204.png 424w, https://substackcdn.com/image/fetch/$s_!YD62!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Febc5854c-dd56-491f-97e9-479fd2670980_4616x6204.png 848w, https://substackcdn.com/image/fetch/$s_!YD62!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Febc5854c-dd56-491f-97e9-479fd2670980_4616x6204.png 1272w, https://substackcdn.com/image/fetch/$s_!YD62!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Febc5854c-dd56-491f-97e9-479fd2670980_4616x6204.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!YD62!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Febc5854c-dd56-491f-97e9-479fd2670980_4616x6204.png" width="1456" height="1957" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ebc5854c-dd56-491f-97e9-479fd2670980_4616x6204.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1957,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1458678,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!YD62!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Febc5854c-dd56-491f-97e9-479fd2670980_4616x6204.png 424w, https://substackcdn.com/image/fetch/$s_!YD62!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Febc5854c-dd56-491f-97e9-479fd2670980_4616x6204.png 848w, https://substackcdn.com/image/fetch/$s_!YD62!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Febc5854c-dd56-491f-97e9-479fd2670980_4616x6204.png 1272w, https://substackcdn.com/image/fetch/$s_!YD62!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Febc5854c-dd56-491f-97e9-479fd2670980_4616x6204.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Ve&#539;i observa c&#259; din perspectiva itera&#539;iei, acest cod este tot unul blocant, deoarece am introdus un <code>while </code>&#537;i un <code>usleep</code>. Dar am introdus inten&#539;ionat aici bucata de cod blocant&#259;, care o vom elimina prin introducerea <em>fibers</em>. </p><h3>S&#259; &#8221;dep&#259;n&#259;m&#8221; cu fibre</h3><p>Acum c&#259; avem o func&#539;ie care nu blocheaz&#259;, puteam crea c&#226;te un <strong>fiber </strong>pentru fiecare director din care dorim s&#259; gener&#259;m clip: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!obC6!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7608c81d-8436-43f3-9015-c81dc0d36fd5_3680x1632.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!obC6!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7608c81d-8436-43f3-9015-c81dc0d36fd5_3680x1632.png 424w, https://substackcdn.com/image/fetch/$s_!obC6!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7608c81d-8436-43f3-9015-c81dc0d36fd5_3680x1632.png 848w, https://substackcdn.com/image/fetch/$s_!obC6!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7608c81d-8436-43f3-9015-c81dc0d36fd5_3680x1632.png 1272w, https://substackcdn.com/image/fetch/$s_!obC6!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7608c81d-8436-43f3-9015-c81dc0d36fd5_3680x1632.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!obC6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7608c81d-8436-43f3-9015-c81dc0d36fd5_3680x1632.png" width="1456" height="646" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7608c81d-8436-43f3-9015-c81dc0d36fd5_3680x1632.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:646,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:333732,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!obC6!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7608c81d-8436-43f3-9015-c81dc0d36fd5_3680x1632.png 424w, https://substackcdn.com/image/fetch/$s_!obC6!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7608c81d-8436-43f3-9015-c81dc0d36fd5_3680x1632.png 848w, https://substackcdn.com/image/fetch/$s_!obC6!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7608c81d-8436-43f3-9015-c81dc0d36fd5_3680x1632.png 1272w, https://substackcdn.com/image/fetch/$s_!obC6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7608c81d-8436-43f3-9015-c81dc0d36fd5_3680x1632.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Dac&#259; am pus fiecare generare &#238;ntr-o fibr&#259; se vor executa &#238;n paralel &#537;i mult mai rapid, nu? Ei nu &#238;nc&#259;, pentru c&#259; nu am eliminat partea blocant&#259; din func&#539;ia noastr&#259; <code>createFolderClip </code>&#537;i fibrele vor rula codul asincron doar cu <code>Fiber::suspend()</code>.</p><h4>PHP Asincron</h4><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Qjzx!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3f13994-686e-4acf-9928-1b04fdb2f1d5_2956x660.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Qjzx!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3f13994-686e-4acf-9928-1b04fdb2f1d5_2956x660.png 424w, https://substackcdn.com/image/fetch/$s_!Qjzx!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3f13994-686e-4acf-9928-1b04fdb2f1d5_2956x660.png 848w, https://substackcdn.com/image/fetch/$s_!Qjzx!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3f13994-686e-4acf-9928-1b04fdb2f1d5_2956x660.png 1272w, https://substackcdn.com/image/fetch/$s_!Qjzx!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3f13994-686e-4acf-9928-1b04fdb2f1d5_2956x660.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Qjzx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3f13994-686e-4acf-9928-1b04fdb2f1d5_2956x660.png" width="1456" height="325" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f3f13994-686e-4acf-9928-1b04fdb2f1d5_2956x660.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:325,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:124306,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Qjzx!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3f13994-686e-4acf-9928-1b04fdb2f1d5_2956x660.png 424w, https://substackcdn.com/image/fetch/$s_!Qjzx!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3f13994-686e-4acf-9928-1b04fdb2f1d5_2956x660.png 848w, https://substackcdn.com/image/fetch/$s_!Qjzx!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3f13994-686e-4acf-9928-1b04fdb2f1d5_2956x660.png 1272w, https://substackcdn.com/image/fetch/$s_!Qjzx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3f13994-686e-4acf-9928-1b04fdb2f1d5_2956x660.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>&#206;n locul lui <code>usleep </code>introducem <code>suspend</code>. &#536;i pentru a putea ob&#539;ine statusul f&#259;r&#259; s&#259; a&#537;tept&#259;m &#238;n foreach-ul care lanseaz&#259; fibrele, le ad&#259;ug&#259;m &#238;ntr-o list&#259; &#537;i le rezum&#259;m &#238;ntr-o bucl&#259;:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!OL_e!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1f473df4-d684-4c13-b019-7dabb607d9df_3680x3188.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!OL_e!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1f473df4-d684-4c13-b019-7dabb607d9df_3680x3188.png 424w, https://substackcdn.com/image/fetch/$s_!OL_e!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1f473df4-d684-4c13-b019-7dabb607d9df_3680x3188.png 848w, https://substackcdn.com/image/fetch/$s_!OL_e!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1f473df4-d684-4c13-b019-7dabb607d9df_3680x3188.png 1272w, https://substackcdn.com/image/fetch/$s_!OL_e!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1f473df4-d684-4c13-b019-7dabb607d9df_3680x3188.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!OL_e!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1f473df4-d684-4c13-b019-7dabb607d9df_3680x3188.png" width="1456" height="1261" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1f473df4-d684-4c13-b019-7dabb607d9df_3680x3188.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1261,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:649390,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!OL_e!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1f473df4-d684-4c13-b019-7dabb607d9df_3680x3188.png 424w, https://substackcdn.com/image/fetch/$s_!OL_e!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1f473df4-d684-4c13-b019-7dabb607d9df_3680x3188.png 848w, https://substackcdn.com/image/fetch/$s_!OL_e!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1f473df4-d684-4c13-b019-7dabb607d9df_3680x3188.png 1272w, https://substackcdn.com/image/fetch/$s_!OL_e!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1f473df4-d684-4c13-b019-7dabb607d9df_3680x3188.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><pre><code>4 folders processed in 0.7 seconds</code></pre><p>Acum pot converti cele 4 foldere &#238;n mai pu&#539;in de o secund&#259;! </p><h3>Paralelism, dar cu m&#259;sur&#259;</h3><p>Codul de mai sus a convertit doar 4 directoare. Toate au rulat &#238;n paralel, fiecare pe c&#226;te unul din ce 12 procesoare de care dispune ma&#537;ina mea. &#206;ns&#259; dac&#259; am generaliza codul s&#259; ruleze pe un num&#259;r variabil de directoare, va fi necesar s&#259; limit&#259;m num&#259;rul de fibre care sunt rulate &#238;n acela&#537;i timp, pentru a evita context switching<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-4" href="#footnote-4" target="_self">4</a>. &#206;n exemplul de mai sus am putea implementa asta acces&#226;nd <code>$fiber&#8594;resume()</code> doar pentru 12 fibre odat&#259;, &#537;i pe m&#259;sur&#259; ce acetea returneaz&#259;, s&#259; rezum&#259;m urm&#259;toarele.  </p><p>Pute&#539;i g&#259;si codul din exemple pe github: <a href="https://github.com/moustacios/php8-tutorials/tree/main/php8-fibers">https://github.com/moustacios/php8-tutorials/tree/main/php8-fibers</a></p><div><hr></div><p> </p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://stack.moustacios.dev/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption"><em>Moustacios.Dev este o publica&#539;ie sus&#539;inut&#259; de voi, de comunitate. Pentru a primi post&#259;ri noi &#537;i pentru a-mi sus&#539;ine munca, v&#259; invit s&#259; v&#259; abona&#539;i:</em></p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-1" href="#footnote-anchor-1" class="footnote-number" contenteditable="false" target="_self">1</a><div class="footnote-content"><p>(en) <a href="https://www.php.net/manual/en/language.fibers.php">www.php.net/manual/en/language.fibers.php</a></p></div></div><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-2" href="#footnote-anchor-2" class="footnote-number" contenteditable="false" target="_self">2</a><div class="footnote-content"><p><a href="http://www.ffmpeg.org">www.ffmpeg.org</a></p></div></div><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-3" href="#footnote-anchor-3" class="footnote-number" contenteditable="false" target="_self">3</a><div class="footnote-content"><p>(en) <a href="https://www.php.net/manual/en/function.proc-open.php">www.php.net/manual/en/function.proc-open.php</a></p></div></div><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-4" href="#footnote-anchor-4" class="footnote-number" contenteditable="false" target="_self">4</a><div class="footnote-content"><p>(en) <a href="http://en.wikipedia.org/wiki/Context_switch">en.wikipedia.org/wiki/Context_switch</a></p><p></p></div></div>]]></content:encoded></item><item><title><![CDATA[Estimări vs. agilitate]]></title><description><![CDATA[Cum &#238;mp&#259;c&#259;m &#537;i capra &#537;i varza, sau cum p&#259;str&#259;m agilitatea f&#259;r&#259; s&#259; arunc&#259;m &#238;n aer bugete &#537;i deadlines]]></description><link>https://stack.moustacios.dev/p/estimari-vs-agilitate</link><guid isPermaLink="false">https://stack.moustacios.dev/p/estimari-vs-agilitate</guid><dc:creator><![CDATA[Teo cel Mustăcios]]></dc:creator><pubDate>Tue, 30 Jul 2024 04:07:48 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!B7MU!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcbb583a1-3595-45c2-8ba3-3df7e8bb8fb1_3600x2400.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!B7MU!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcbb583a1-3595-45c2-8ba3-3df7e8bb8fb1_3600x2400.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!B7MU!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcbb583a1-3595-45c2-8ba3-3df7e8bb8fb1_3600x2400.jpeg 424w, https://substackcdn.com/image/fetch/$s_!B7MU!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcbb583a1-3595-45c2-8ba3-3df7e8bb8fb1_3600x2400.jpeg 848w, https://substackcdn.com/image/fetch/$s_!B7MU!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcbb583a1-3595-45c2-8ba3-3df7e8bb8fb1_3600x2400.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!B7MU!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcbb583a1-3595-45c2-8ba3-3df7e8bb8fb1_3600x2400.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!B7MU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcbb583a1-3595-45c2-8ba3-3df7e8bb8fb1_3600x2400.jpeg" width="1456" height="971" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/cbb583a1-3595-45c2-8ba3-3df7e8bb8fb1_3600x2400.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:971,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1328775,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!B7MU!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcbb583a1-3595-45c2-8ba3-3df7e8bb8fb1_3600x2400.jpeg 424w, https://substackcdn.com/image/fetch/$s_!B7MU!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcbb583a1-3595-45c2-8ba3-3df7e8bb8fb1_3600x2400.jpeg 848w, https://substackcdn.com/image/fetch/$s_!B7MU!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcbb583a1-3595-45c2-8ba3-3df7e8bb8fb1_3600x2400.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!B7MU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcbb583a1-3595-45c2-8ba3-3df7e8bb8fb1_3600x2400.jpeg 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Cred c&#259; una dintre cele mai dificile momente la &#238;nceputul unui sprint, sau al unui deliverable este acela al estim&#259;rilor. Am lucrat at&#226;t &#238;n proiecte care adoptau procese &#8221;agile&#8221; c&#226;t &#537;i &#238;n echipe cu waterfall sau pe cont propriu ca freelancer, unde nu prea ai ce tehnic&#259; s&#259; adop&#539;i. Dar &#238;n majoritatea cazurilor, cu c&#226;teva excep&#539;ii notabile - c&#226;nd am fost implicat &#238;n echipe de produs, am fost &#238;n situa&#539;ia de a da estim&#259;ri. </p><p>Eu m&#259; pozi&#539;ionez &#238;mpotriva estim&#259;rilor: cum s&#259; &#537;tii c&#226;t o s&#259; dureze ceva ce nu ai f&#259;cut niciodat&#259;? Acel modul sau feature va fi creat, fie cu ajutorul unor libr&#259;rii sau alte module, &#238;ns&#259; dac&#259; &#539;i-e dat s&#259;-l faci, e pentru c&#259; nu exist&#259; ceva identic. &#206;n concluzie orice estimare de timp va fi o &#238;ncercare de a prevedea viitorul - un exerci&#539;iu riscant &#539;in&#226;nd cont de faptul c&#259; de previziune depinde bugetul. Plus c&#259; sunt at&#226;tea variabile: poate e&#537;ti nevoit s&#259; &#238;&#539;i iei concediu, sau poate &#238;&#539;i dai seama c&#259; ai nevoie de mult mai mult timp, dar asta dup&#259; ce ai &#238;nceput implementarea, &#537;i s-a scurs deja jum&#259;tate din timpul alocat.</p><h3>#Deadlines</h3><p>O alt&#259; problem&#259;, mai ales pentru echipele agile, este c&#259; estim&#259;rile se transform&#259; &#238;n deadlines. Nu de pu&#539;ine ori mi s-a &#238;nt&#226;mplat s&#259; dau o estimare &#537;i apoi data respectiv&#259; s&#259; apar&#259; &#238;ntr-un comunicat de pres&#259;, sau toat&#259; compania s&#259; afle c&#259; din data X vor avea gata respectivul modul, sau s&#259; se felicite pentru aceast&#259; reu&#537;it&#259;. &#206;n aceste cazuri, mai ales pentru juniori este foarte greu s&#259; dea estim&#259;ri - deoarece au pu&#539;in&#259; experien&#539;&#259; pe proiect nu vor reu&#537;i s&#259; livreze &#238;n acela&#537;i timp ca un senior, &#537;i de multe ori vor fi pu&#537;i &#238;n situa&#539;ia de a da estim&#259;ri mai mici, pentru c&#259; un coleg senior este de alt&#259; p&#259;rere. Sau juniorii vor primi &#238;ntodeauna task-uri u&#537;oare, pentru a se &#238;nscrie &#238;n sprint, rat&#226;nd astfel oportunitatea de a &#238;nv&#259;&#539;a &#537;i a deveni mai experimenta&#539;i pe proiect.</p><p>Desigur, pe termen lung, echipa va deveni mai rigid&#259;, mai pu&#539;in dispus&#259; s&#259;-&#537;i asume riscuri &#537;i condus&#259; mai degrab&#259; de aceste deadline-uri. Pentru c&#259; cine se &#238;nscrie &#238;n <em>estimare</em>, este v&#259;zut ca un performer &#238;n ochii managerilor.   </p><h3>#NoEstimates</h3><p>Allen Holub<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-1" href="#footnote-1" target="_self">1</a> sus&#539;inea aceast&#259; cauz&#259; - dac&#259; estim&#259;rile nu se respect&#259;, ce rost mai are s&#259; le d&#259;m? Agile, nu este un proces dependent de timp, &#537;i de mult ori estim&#259;rile au de fapt rolul de a stabili direct costurile clientului, ceea ce &#238;i face pe manageri s&#259; fie obseda&#539;i de durat&#259; mai degrab&#259; dec&#226;t de rezultat. Iar aici este un conflict: devreme ce managerul dore&#537;te s&#259; &#537;tie c&#226;t &#238;l cost&#259; un modul, pe mine ca inginer m&#259; pasioneaz&#259; s&#259; livrez &#238;n produc&#539;ie acel modul - adic&#259; rezultatul este acel moment &#238;n viitor c&#226;nd am trecut de toate fazele pentru livrare &#238;n mediul de produc&#539;ie: arhitectur&#259;, inventariere cerin&#539;e &#537;i dependin&#539;e, evaluarea implement&#259;rii ini&#539;iale, testarea &#537;i demonstra&#539;ie. Fiecare dintre ace&#537;ti pa&#537;i va necesita o bucat&#259; de timp, &#537;i de cele mai multe ori depind de al&#539;i colegi s&#259; poat&#259; fi duse la bun sf&#226;r&#537;it. M&#259; preg&#259;tesc pentru acel moment din viitor, c&#226;nd voi putea livra modulul, &#238;ns&#259; c&#226;nd va fi acel moment este foarte greu de stabilit. E similar cu a cere unei persoane care tocmai a &#238;nceput cursurile de &#238;not, c&#226;t timp &#238;i ia p&#226;n&#259; s&#259; &#238;noate &#238;n mare.</p><p>Se poate agile f&#259;r&#259; estim&#259;ri!? Da se poate, &#537;i o s&#259; revin asupra subiectului &#238;ntr-un articol viitor. &#206;ns&#259; acum o s&#259; dezbat problema estim&#259;rilor, atunci c&#226;nd sunt necesare:</p><h3>#Bugete - dar de timp</h3><p>Din p&#259;cate, &#238;n multe situa&#539;ii nu putem aplica sfatul lui Allen Holub, &#537;i s&#259; renun&#539;&#259;m la estim&#259;ri. De exemplu, dac&#259; e&#537;ti freelancer clientul &#238;&#539;i va cere un buget, &#537;i vei fi nevoit s&#259; &#238;&#539;i faci un calcul de timp. La fel &#537;i la modelul <em>Time and Material</em>, practicat &#238;n companiile de outsourcing. Clientul se a&#537;teapt&#259; s&#259; &#537;tie, orientativ, c&#226;t va costa implementarea.</p><p>Dar, &#238;n acela&#537;i timp dorim s&#259; reducem presiunea &#537;i pericolul ca estim&#259;rile s&#259; se transforme &#238;n deadlines, mai ales pentru juniori sau teams leads care vor fi pu&#537;i &#238;n situa&#539;ia de a-i ajuta pe colegi &#238;n cazul &#238;n care au dificult&#226;&#539;i de a se &#238;ncadra &#238;n sprint.</p><p>O metod&#259; pe care am aplicat-o cu succes, este aceea de a crea bugete de timp, adic&#259; &#238;&#539;i rezervi un num&#259;r de ore/zile pentru un anumit task. Dar nu numai c&#259; indici acest lucru &#238;n sistemul de tracking cu story points de exemplu, ci &#537;i pontezi sau pui acel timp &#238;n avans pentru acel task. Aceast&#259; simpl&#259; opera&#539;ie, m&#259; face s&#259; m&#259; concentrez mai u&#537;or, pentru c&#259; nu mai am grija duratei - timpul e deja alocat. </p><p>Apoi dac&#259; azi am bugetat timp pentru un modul din acest sprint, atunci orice alte &#238;nt&#226;lniri sau task-uri la care le voi acorda timp &#238;n sprint, le voi ponta separat &#537;i &#238;mi voi da seama imediat dac&#259; aceste extra task-uri dep&#259;&#537;esc capacitatea rezervat&#259; de mine sau nu. &#206;mi va fi mai u&#537;or s&#259; comunic timpul pe care &#238;l pot aloca meeting-urilor sau suportului pentru colegi. &#536;i aceste interac&#539;iuni sunt foarte importante, pentru a fi eficace fiecare coleg din echip&#259; va avea nevoie de timp rezervat pentru ele.</p><p>Desigur, dac&#259; a luat mai pu&#539;in, la sf&#226;r&#537;it po&#539;i corecta pontajul s&#259; reflecte timpul efectiv, dar aceste corecturi se fac oricum la estim&#259;ri.</p><p>O alt&#259; men&#539;iune important&#259;, pentru bugetele de timp, este s&#259; nu rezervi timp pentru task-uri pe care nu le iei tu, deci fiecare coleg decide de c&#226;t timp are nevoie. &#536;i se evit&#259; bugetarea de timp pentru task-uri care nu sunt &#238;ncepute &#238;n sprint. Pe principiul dac&#259; nu este important atunci nu se estimeaz&#259;.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://stack.moustacios.dev/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption"><em>Moustacios.Dev este o publica&#539;ie sus&#539;inut&#259; de voi, de comunitate. Pentru a primi post&#259;ri noi &#537;i pentru a-mi sus&#539;ine munca, v&#259; invit s&#259; v&#259; abona&#539;i:</em></p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>Eu folosesc de aproape un an tehnica bugetelor de timp. De multe ori este combinat&#259; cu story points &#537;i se complementeaz&#259; chiar bine, deoarece evit&#259;m confuzia dintre dificulate &#537;i durat&#259;. Sper c&#259; &#238;i ajut&#259; &#537;i pe cei care fac freelancing, pentru c&#259; poate fi dificil s&#259; jonglezi cu mai mul&#539;i clien&#539;i, unde estim&#259;rile influen&#539;eaz&#259; &#238;n mod direct bugetele clien&#539;ilor.</p><p><em>(c) Photo by <a href="https://unsplash.com/@jasongoodman_youxventures?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Jason Goodman</a> on <a href="https://unsplash.com/photos/five-person-by-table-watching-turned-on-white-imac-vbxyFxlgpjM?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Unsplash</a></em></p><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-1" href="#footnote-anchor-1" class="footnote-number" contenteditable="false" target="_self">1</a><div class="footnote-content"><p><a href="https://www.youtube.com/watch?v=QVBlnCTu9Ms">(EN) #NoEstimates (Allen Holub)</a></p><p></p></div></div>]]></content:encoded></item><item><title><![CDATA[Poți să-mi recomanzi un laptop bun?!]]></title><description><![CDATA[Achizi&#539;ionarea unul laptop &#238;n ziua de azi e o aventur&#259;]]></description><link>https://stack.moustacios.dev/p/poti-sa-mi-recomanzi-un-laptop-bun</link><guid isPermaLink="false">https://stack.moustacios.dev/p/poti-sa-mi-recomanzi-un-laptop-bun</guid><dc:creator><![CDATA[Teo cel Mustăcios]]></dc:creator><pubDate>Thu, 04 Jul 2024 03:30:41 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!wPLA!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa35cd284-2de4-42a4-8398-0ac662d86edb_1152x640.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!wPLA!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa35cd284-2de4-42a4-8398-0ac662d86edb_1152x640.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!wPLA!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa35cd284-2de4-42a4-8398-0ac662d86edb_1152x640.jpeg 424w, https://substackcdn.com/image/fetch/$s_!wPLA!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa35cd284-2de4-42a4-8398-0ac662d86edb_1152x640.jpeg 848w, https://substackcdn.com/image/fetch/$s_!wPLA!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa35cd284-2de4-42a4-8398-0ac662d86edb_1152x640.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!wPLA!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa35cd284-2de4-42a4-8398-0ac662d86edb_1152x640.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!wPLA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa35cd284-2de4-42a4-8398-0ac662d86edb_1152x640.jpeg" width="1152" height="640" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a35cd284-2de4-42a4-8398-0ac662d86edb_1152x640.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:&quot;normal&quot;,&quot;height&quot;:640,&quot;width&quot;:1152,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!wPLA!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa35cd284-2de4-42a4-8398-0ac662d86edb_1152x640.jpeg 424w, https://substackcdn.com/image/fetch/$s_!wPLA!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa35cd284-2de4-42a4-8398-0ac662d86edb_1152x640.jpeg 848w, https://substackcdn.com/image/fetch/$s_!wPLA!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa35cd284-2de4-42a4-8398-0ac662d86edb_1152x640.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!wPLA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa35cd284-2de4-42a4-8398-0ac662d86edb_1152x640.jpeg 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Am &#537;i eu la &#8221;wishlist&#8221; vreo 15 modele de laptop-uri. Cu pre&#539;uri de la 3000 la 7000 de lei. Sunt foarte multe modele cu specifica&#539;ii  extrem de variate, &#537;i stau &#537;i m&#259; &#238;ntreb cum, un laptop cu 16 GB de RAM poate s&#259; coste la fel cu unul cu 40 de GB de RAM? O fi av&#226;nd procesor mai puternic, sau dureaz&#259; bateria mai mult, sau are plac&#259; video dedicat&#259;&#8230; . </p><p>&#536;i uite a&#537;a, m&#259; hlizesc la toate modelele &#537;i combina&#539;iile posibile cu foarte mare ezitare, pentru c&#259; mi-e foarte greu s&#259; m&#259; decid: iau unul cu mai mul&#539;i RAM dar f&#259;r&#259; plac&#259; video dedicat&#259;? sau unul cu plac&#259; &#537;i mai multe nuclee la procesor?</p><p>Ideea e c&#259;, dac&#259; de exemplu, &#238;ncepi de la o specifica&#539;ie cum am c&#259;utat eu cu minim 32 GB de RAM, o s&#259; vezi c&#259; acei rami pot s&#259; valoreze de la 3500 de lei &#238;n sus, iar limita e undeva pe la 7000 de lei. Respectiv o s&#259; g&#259;se&#537;ti laptopuri cu 32 de GB la dublu pre&#539; &#537;i desigur atunci de ce s&#259; nu-l iei pe cel mai ieftin?! S&#259; v&#259; dau &#537;i un exemplu: </p><p><em><a href="https://www.emag.ro/compare/DNQV1DYBM,DZPH5DYBM,D1400MYBM,DX8TN2YBM/">https://www.emag.ro/compare/DNQV1DYBM,DZPH5DYBM,D1400MYBM,DX8TN2YBM/</a></em></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!BFBH!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06e032de-cfad-4ecf-a67a-2060ca035343_1906x848.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!BFBH!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06e032de-cfad-4ecf-a67a-2060ca035343_1906x848.png 424w, https://substackcdn.com/image/fetch/$s_!BFBH!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06e032de-cfad-4ecf-a67a-2060ca035343_1906x848.png 848w, https://substackcdn.com/image/fetch/$s_!BFBH!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06e032de-cfad-4ecf-a67a-2060ca035343_1906x848.png 1272w, https://substackcdn.com/image/fetch/$s_!BFBH!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06e032de-cfad-4ecf-a67a-2060ca035343_1906x848.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!BFBH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06e032de-cfad-4ecf-a67a-2060ca035343_1906x848.png" width="1456" height="648" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/06e032de-cfad-4ecf-a67a-2060ca035343_1906x848.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:648,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:467248,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!BFBH!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06e032de-cfad-4ecf-a67a-2060ca035343_1906x848.png 424w, https://substackcdn.com/image/fetch/$s_!BFBH!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06e032de-cfad-4ecf-a67a-2060ca035343_1906x848.png 848w, https://substackcdn.com/image/fetch/$s_!BFBH!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06e032de-cfad-4ecf-a67a-2060ca035343_1906x848.png 1272w, https://substackcdn.com/image/fetch/$s_!BFBH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06e032de-cfad-4ecf-a67a-2060ca035343_1906x848.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Aceste modele au toate c&#226;te 32 GB de RAM, procesor cu 8 nuclee (cu o singur&#259; excep&#539;ie) &#537;i plac&#259; video dedicat&#259; cu 6GB de VRAM. Iar cel care are 12 nuclee la procesor, nu este cel mai scump. De obicei a&#537; zice c&#259; dac&#259; laptop-ul e de &#8221;gaming&#8221; &#537;ansa este s&#259; pl&#259;te&#537;ti mai mult doar pentru c&#226;teva gimmick-uri care nu influen&#539;eaz&#259; performan&#539;a. </p><p>Ei &#537;i uite a&#537;a, &#238;n loc s&#259; tot stau s&#259; compar &#537;i s&#259; m&#259; g&#226;ndesc, mi-am f&#259;cut o formul&#259;. Pornind de la ideea c&#259; ai lua toate specifica&#539;iile astea: num&#259;r de nuclee, capacitate SSD, capacitate RAM, VRAM &#537;i durata bateriei &#537;i le-ai contopi &#238;ntr-un coeficient pentru fiecare laptop ai putea s&#259; calculezi c&#226;t pl&#259;te&#537;ti pentru fiecare &#8221;upgrade&#8221; sau punct de performan&#539;&#259; &#238;n plus. Formula face abstrac&#539;ie de c&#226;teva elemente cum ar fi frecven&#539;a procesorului, pornind de la premiza c&#259; majoritatea au procesoare peste 3 GHz, sau de frecven&#539;a memoriei RAM. Iar stocarea - &#238;ntodeauna alege&#539;i SSD.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!xN44!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe1000917-c28a-4f18-b544-b8f40b065f1a_2414x1090.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!xN44!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe1000917-c28a-4f18-b544-b8f40b065f1a_2414x1090.png 424w, https://substackcdn.com/image/fetch/$s_!xN44!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe1000917-c28a-4f18-b544-b8f40b065f1a_2414x1090.png 848w, https://substackcdn.com/image/fetch/$s_!xN44!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe1000917-c28a-4f18-b544-b8f40b065f1a_2414x1090.png 1272w, https://substackcdn.com/image/fetch/$s_!xN44!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe1000917-c28a-4f18-b544-b8f40b065f1a_2414x1090.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!xN44!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe1000917-c28a-4f18-b544-b8f40b065f1a_2414x1090.png" width="1456" height="657" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e1000917-c28a-4f18-b544-b8f40b065f1a_2414x1090.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:657,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:309473,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!xN44!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe1000917-c28a-4f18-b544-b8f40b065f1a_2414x1090.png 424w, https://substackcdn.com/image/fetch/$s_!xN44!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe1000917-c28a-4f18-b544-b8f40b065f1a_2414x1090.png 848w, https://substackcdn.com/image/fetch/$s_!xN44!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe1000917-c28a-4f18-b544-b8f40b065f1a_2414x1090.png 1272w, https://substackcdn.com/image/fetch/$s_!xN44!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe1000917-c28a-4f18-b544-b8f40b065f1a_2414x1090.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">rezultate din wishlist-ul meu</figcaption></figure></div><p>De exemplu eu am comparat c&#226;teva modele cu o capacitate sensibil&#259; de memorie RAM, respecviv 48 sau 64 de GB, cu sau f&#259;r&#259; plac&#259; video dedicat&#259;. &#536;i aici poate o s&#259; ridica&#539;i spr&#226;ncenele - p&#259;i cum un laptop cu plac&#259; video separat &#537;i mai multe core-uri, are mai pu&#539;ine &#8221;puncte&#8221; dec&#226;t unul f&#259;r&#259;?! Deoarce Dell-ul are o baterie care &#539;ine 6 ore fa&#539;&#259; de acel Lenovo cu RTX. Iar diferen&#539;a este sensibil&#259; - de 3000 de RON &#238;ntre cele dou&#259;, doar pentru placa video &#537;i c&#226;teva core-uri &#238;n plus. Cu alte cuvinte pentru placa video extra, r&#259;m&#226;nem cu dou&#259; ore de baterie. Mai bine iau un desktop PC care vine cu 12 GB VRAM. Uite aici exemplul ca s&#259; nu zice&#539;i c&#259; bat c&#226;mpii:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!nBGH!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F529f3ac1-7672-403b-992c-2c763daf4d1f_1966x772.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!nBGH!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F529f3ac1-7672-403b-992c-2c763daf4d1f_1966x772.png 424w, https://substackcdn.com/image/fetch/$s_!nBGH!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F529f3ac1-7672-403b-992c-2c763daf4d1f_1966x772.png 848w, https://substackcdn.com/image/fetch/$s_!nBGH!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F529f3ac1-7672-403b-992c-2c763daf4d1f_1966x772.png 1272w, https://substackcdn.com/image/fetch/$s_!nBGH!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F529f3ac1-7672-403b-992c-2c763daf4d1f_1966x772.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!nBGH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F529f3ac1-7672-403b-992c-2c763daf4d1f_1966x772.png" width="1456" height="572" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/529f3ac1-7672-403b-992c-2c763daf4d1f_1966x772.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:572,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:423388,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!nBGH!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F529f3ac1-7672-403b-992c-2c763daf4d1f_1966x772.png 424w, https://substackcdn.com/image/fetch/$s_!nBGH!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F529f3ac1-7672-403b-992c-2c763daf4d1f_1966x772.png 848w, https://substackcdn.com/image/fetch/$s_!nBGH!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F529f3ac1-7672-403b-992c-2c763daf4d1f_1966x772.png 1272w, https://substackcdn.com/image/fetch/$s_!nBGH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F529f3ac1-7672-403b-992c-2c763daf4d1f_1966x772.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Am pornit de la ideea c&#259; RAMii sunt cel mai important factor, deoarece versatilitatea unui laptop depinde de c&#226;te aplica&#539;ii poate pune &#238;n background sau &#238;n sleep &#537;i sistemele de operare mai noi sunt optimizate pentru asta. Apoi capacitatea SSD-ului al doilea factor, pentru c&#259; ultimul lucru care &#539;i l-ai dori eeste s&#259; r&#259;m&#226;i f&#259;r&#259; spa&#539;iu pe disc c&#226;nd lucrezi la un proiect. Proiectele pe care lucrez eu au ata&#537;ate &#238;n mod normal c&#226;&#539;iva GB de assets. </p><p>Num&#259;rul de nuclee plus durata de via&#539;&#259; a baterie, sunt secundare, de obicei se influen&#539;eaz&#259; &#238;n mod direct - multe core-uri consum&#259; mai mult&#259; baterie iar la un laptop vom avea &#537;i thermal throttle. Deci cu ce te ajut&#259; mai multe core-uri dac&#259; le po&#539;i folosi doar c&#226;nd ai o priz&#259; aproape! </p><p>Iar VRAM-ul, de&#537;i balanseaz&#259; &#238;n jos e cel mai pu&#539;in semnificativ. V-am ar&#259;ttat &#537;i &#238;n exemplul de mai sus - pe un laptop, doar o plac&#259; video ajunge s&#259; te coste c&#226;t un desktop PC &#238;ntreg. Da dac&#259; ai ni&#537;te specifica&#539;ii foarte clare, gen, ai nevoie de CUDA cores sau dezvol&#539;i jocuri unde ai nevoie specific de ray-tracing, atunci poate merit&#259; investi&#539;ia. </p><p>Desigur ve&#539;i observa rezultate mai apropiate &#537;i mai relevante, c&#226;nd compara&#539;i laptop-uri cu configura&#539;ii similare. De exemplu dac&#259; folosi&#539;i suita Adobe pentru editare foto/video, ve&#539;i avea nevoie de o plac&#259; video dedicat&#259; cu minim 4 GB VRAM. Pentru Macbook-uri nu pot recomanda formula asta, deoarece acestea sunt o alt&#259; lig&#259;. Ideea e s&#259; afli care e cel mai ieftin produs comparat cu performan&#539;ele pe care le ofer&#259;, &#537;i c&#226;nd ai un buget stabilit zic c&#259; este foarte util&#259;.</p><p><strong>Pute&#539;i compara &#537;i voi folosind acest spreadsheet: <a href="https://docs.google.com/spreadsheets/d/1r1iqKo7aVsFkbnt0f9c6vLcCOa0jpT0IhjuCLz8765w">https://docs.google.com/spreadsheets/d/1r1iqKo7aVsFkbnt0f9c6vLcCOa0jpT0IhjuCLz8765w</a> . </strong></p><p>Fie desc&#259;rca&#539;i &#537;i edita&#539;i sau face&#539;i o copie. Sper s&#259; fie de folos.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://stack.moustacios.dev/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption"><em>Moustacios.Dev este o publica&#539;ie sus&#539;inut&#259; de voi, de comunitate. Pentru a primi post&#259;ri noi &#537;i pentru a-mi sus&#539;ine munca, v&#259; invit s&#259; v&#259; abona&#539;i:</em></p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p></p>]]></content:encoded></item><item><title><![CDATA[Git - alternative și utilități ]]></title><description><![CDATA[Explor&#259;m utilitare &#537;i alternative la sistemul de versionare git]]></description><link>https://stack.moustacios.dev/p/git-alternative-si-utilitati</link><guid isPermaLink="false">https://stack.moustacios.dev/p/git-alternative-si-utilitati</guid><dc:creator><![CDATA[Teo cel Mustăcios]]></dc:creator><pubDate>Thu, 27 Jun 2024 04:45:37 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!8YoM!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa19d652-efa7-4114-84ca-f5d665180225_744x400.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!8YoM!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa19d652-efa7-4114-84ca-f5d665180225_744x400.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!8YoM!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa19d652-efa7-4114-84ca-f5d665180225_744x400.jpeg 424w, https://substackcdn.com/image/fetch/$s_!8YoM!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa19d652-efa7-4114-84ca-f5d665180225_744x400.jpeg 848w, https://substackcdn.com/image/fetch/$s_!8YoM!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa19d652-efa7-4114-84ca-f5d665180225_744x400.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!8YoM!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa19d652-efa7-4114-84ca-f5d665180225_744x400.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!8YoM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa19d652-efa7-4114-84ca-f5d665180225_744x400.jpeg" width="744" height="400" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/fa19d652-efa7-4114-84ca-f5d665180225_744x400.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:400,&quot;width&quot;:744,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:51139,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!8YoM!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa19d652-efa7-4114-84ca-f5d665180225_744x400.jpeg 424w, https://substackcdn.com/image/fetch/$s_!8YoM!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa19d652-efa7-4114-84ca-f5d665180225_744x400.jpeg 848w, https://substackcdn.com/image/fetch/$s_!8YoM!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa19d652-efa7-4114-84ca-f5d665180225_744x400.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!8YoM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa19d652-efa7-4114-84ca-f5d665180225_744x400.jpeg 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>C&#226;nd vorbim de versionare pentru cod &#537;i software &#238;n general, utilitarul de facto &#238;n 2024 este &#238;nc&#259; <em>git</em>. Dar nu a fost &#238;ntodeauna a&#537;a. Cei care &#238;&#537;i amintesc &#238;nainte ca acesta s&#259; devin&#259; stabil &#537;i popular foloseam svn, mercurial sau cvs. Eu &#238;mi amintesc cu nostalgie de vremea c&#226;nd foloseam Tortoise SVN<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-1" href="#footnote-1" target="_self">1</a>.</p><p>&#206;n acest articol o s&#259; v&#259; spun &#537;i despre alternative la Git ca sistem de versionare, dar &#537;i despre c&#226;teva unelte care v&#259; pot u&#537;ura interac&#539;iunea cu git din linia de comand&#259;:</p><h3>Gitu</h3><p>&#206;nc&#259; de la versiunea 2, interfa&#539;a cli cu care vine git este destul de bun&#259;, dar nu chiar intuitiv&#259;. Iar pentru unele ac&#539;iuni rulezi acelea&#537;i comenzi repetitiv. Apoi pentru cazurile &#238;n care faci un <em>log </em>sau <em>diff</em> este extrem de util&#259; o interfa&#539;&#259; grafic&#259;. </p><p>Gitu este un utilitar din linia de comand&#259;, inspirat de Magit - extensia pentru Emacs, care &#238;&#539;i permite s&#259; execu&#539;i o serie de comenzi folosind macros - combina&#539;ii de taste. Acesta nu &#238;nlocuie&#537;te git, dar te ajut&#259; s&#259; sari peste comenzi repetitive, s&#259; vizualizezi istoricul &#537;i diff-urile cu o interfa&#539;&#259; &#537;i ofer&#259; sugestii pentru ac&#539;iuni &#238;n func&#539;ie de context. </p><p>Din p&#259;care suportul pentru WSL2 are c&#226;teva bug-uri &#537;i nu am reu&#537;it s&#259; &#238;l instalez cu cargo, dar &#238;l recomand pentru simplitate &#537;i portabilitate.</p><h3>Sapling</h3><p>Una dintre criticile men&#539;ionate des la adresa git, este c&#259; e dificil de scalat - la miloane de fi&#537;iere &#537;i mii de dezvoltatori. Google de exemplu, &#238;n mod faimos, folose&#537;te un sistem intern de versionare men&#539;inat pe forumuri ca <em>Piper</em>, care din p&#259;cate nu este open source. Cel pu&#539;in Meta au decis s&#259; publice codul sistemului lor de versionare - Sapling. Codul pentru componenta de client, este disponibil pe Github sub GPL. </p><p>Sunte multe de spus despre acest SCM, dar pentru a &#539;ine acest articol &#238;n limitele unei email voi nota urm&#259;toarele: </p><p>Acesta difer&#259; fundamental de git, ca mod de operare, dar totodat&#259; ofer&#259; interoperabilitate cu git &#537;i GitHub. &#206;&#539;i d&#259; posibilitatea s&#259; trimi&#539;i un pull request direct din cli, &#537;i s&#259; vizualizezi un log detaliat per branch. Tototad&#259; acesta descurajeaz&#259; branch-uri cu denumiri sugestive &#537;i &#238;ncurajeaz&#259; folosirea PR-urilor &#238;n loc, ca feature branches. Saplin nu are un staging area. Po&#539;i face un commit ca &#537;i cu git, iar acesta se va aplica la toate fi&#537;ierele urm&#259;rite. Po&#539;i ascunde sau &#8221;undo&#8221; commit-uri publice cu un nou commit &#537;i vine cu o interfa&#539;&#259; web care ofer&#259; un istoric interactiv (smartlog). </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!WN4R!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F81a01d62-e0a9-4831-8f8d-238cb8982fe4_2376x1856.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!WN4R!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F81a01d62-e0a9-4831-8f8d-238cb8982fe4_2376x1856.png 424w, https://substackcdn.com/image/fetch/$s_!WN4R!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F81a01d62-e0a9-4831-8f8d-238cb8982fe4_2376x1856.png 848w, https://substackcdn.com/image/fetch/$s_!WN4R!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F81a01d62-e0a9-4831-8f8d-238cb8982fe4_2376x1856.png 1272w, https://substackcdn.com/image/fetch/$s_!WN4R!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F81a01d62-e0a9-4831-8f8d-238cb8982fe4_2376x1856.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!WN4R!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F81a01d62-e0a9-4831-8f8d-238cb8982fe4_2376x1856.png" width="1456" height="1137" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/81a01d62-e0a9-4831-8f8d-238cb8982fe4_2376x1856.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1137,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:795173,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!WN4R!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F81a01d62-e0a9-4831-8f8d-238cb8982fe4_2376x1856.png 424w, https://substackcdn.com/image/fetch/$s_!WN4R!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F81a01d62-e0a9-4831-8f8d-238cb8982fe4_2376x1856.png 848w, https://substackcdn.com/image/fetch/$s_!WN4R!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F81a01d62-e0a9-4831-8f8d-238cb8982fe4_2376x1856.png 1272w, https://substackcdn.com/image/fetch/$s_!WN4R!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F81a01d62-e0a9-4831-8f8d-238cb8982fe4_2376x1856.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">sapling smartlog web ui</figcaption></figure></div><p>Smartlog, ofer&#259; o serie de avantaje peste <code>git log</code>, pe l&#226;ng&#259; componenta vizual&#259;, &#238;&#539;i ofer&#259; posibilitatea de a muta commit-uri (rebase) sau da checkout (goto) pe alt branch. </p><p>Din p&#259;care serverul sapling nu este open source, &#238;n consecin&#539;&#259; singura modalitate de a-l adopta este folosind interoperabilitatea cu github.</p><h3>Jujutsu</h3><p><em>JJ </em>este un sistem dezvoltat recent, &#238;n limbajul Rust, a c&#259;rui misiune principal&#259; este s&#259; decupleze layer-ul de stocare de cel de control al versiunilor. &#206;n acest fel, fiind mult mai u&#537;or de scalat. </p><p>O alt&#259; &#351;chimbare notabil&#259; fa&#539;&#259; de git, este c&#259; <em>jj </em>consider&#259; copia &#238;n lucru (working-copy) ca fiind un commit, elimin&#226;nd astfel erorile tipice opera&#539;iilor de checkout sau pull din git atunci c&#226;nd avem modific&#259;ri pe working-copy. Practic toate opera&#539;iile &#238;n jj, au afect asupra unui commit. Poate p&#259;rea contraintuitiv, &#238;ns&#259; rezultatul este c&#259; po&#539;i face mai multe versiuni locale pe branch-uri diferite de exemplu &#537;i s&#259; le testez f&#259;r&#259; a fi blocat de nevoia de a crea efectiv un commit. Git &#238;n acest scenariu te va alerta: &#8221;aten&#539;ie s&#259; nu pierzi vreun fi&#537;ier&#8221; - e nevoie s&#259; faci un commit &#238;nainte de checkout. Pe c&#226;nd <em>JJ</em> te las&#259; s&#259; schimbi branch-ul, eventual po&#539;i ad&#259;uga noi modific&#259;ri iar c&#226;nd e&#537;ti gata &#8221;salvezi&#8221; acel commit sau &#238;l adaugi la cel precedent cu squash.</p><p>Mai sunt c&#226;teva diferen&#539;e legate de ramuri (branches), &#537;i de conflicte, dar dac&#259; vi se pare interesant v&#259; recomand s&#259; citi&#539;i mai multe pe <a href="https://martinvonz.github.io/jj/latest/">pagina proiectului</a>. Partea cea mai bun&#259; este c&#259; suport&#259; repository-uri .git &#537;i deci poate fi folosit &#238;n paralel cu sistemul de versionare. </p><h4>Men&#539;iuni notabile:</h4><ul><li><p><a href="https://fossil-scm.org/">www.fossil-scm.org</a></p></li><li><p><a href="https://www.stacking.dev/">www.stacking.dev</a></p></li><li><p><a href="https://en.wikipedia.org/wiki/GNU_Bazaar">en.wikipedia.org/wiki/GNU_Bazaar</a></p></li><li><p><a href="https://pijul.org/">www.pijul.org</a></p></li><li><p><a href="https://git-cliff.org/">www.git-cliff.org</a></p></li><li><p><a href="https://github.com/dlvhdr/gh-dash">github.com/dlvhdr/gh-dash</a></p><p></p></li></ul><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://stack.moustacios.dev/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption"><em>Moustacios.Dev este o publica&#539;ie sus&#539;inut&#259; de voi, de comunitate. Pentru a primi post&#259;ri noi &#537;i pentru a-mi sus&#539;ine munca, v&#259; invit s&#259; v&#259; abona&#539;i:</em></p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p></p><p>Referin&#539;e:</p><ul><li><p><a href="http://github.com/altsem/gitu">github.com/altsem/gitu</a></p></li><li><p><a href="https://engineering.fb.com/2022/11/15/open-source/sapling-source-control-scalable/">engineering.fb.com/2022/11/15/open-source/sapling-source-control-scalable</a></p></li><li><p><a href="https://sapling-scm.com/">sapling-scm.com</a></p></li><li><p><a href="https://github.com/martinvonz/jj">github.com/martinvonz/jj</a></p></li></ul><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-1" href="#footnote-anchor-1" class="footnote-number" contenteditable="false" target="_self">1</a><div class="footnote-content"><p><a href="https://tortoisesvn.net/">(EN) Tortoise SVN</a></p></div></div>]]></content:encoded></item><item><title><![CDATA[Guidance - ghidează modele de limbaj prin cod]]></title><description><![CDATA[O paradigm&#259; de programare pentru controlul &#537;i ghidarea modelelor de limbaj (LLM)]]></description><link>https://stack.moustacios.dev/p/guidance-ghideaza-modele-de-limbaj</link><guid isPermaLink="false">https://stack.moustacios.dev/p/guidance-ghideaza-modele-de-limbaj</guid><dc:creator><![CDATA[Teo cel Mustăcios]]></dc:creator><pubDate>Thu, 30 May 2024 04:14:58 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!ZzGK!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd5ea6fc4-a0e7-4e4b-8001-54b4c66a9b81_1200x630.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ZzGK!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd5ea6fc4-a0e7-4e4b-8001-54b4c66a9b81_1200x630.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ZzGK!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd5ea6fc4-a0e7-4e4b-8001-54b4c66a9b81_1200x630.jpeg 424w, https://substackcdn.com/image/fetch/$s_!ZzGK!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd5ea6fc4-a0e7-4e4b-8001-54b4c66a9b81_1200x630.jpeg 848w, https://substackcdn.com/image/fetch/$s_!ZzGK!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd5ea6fc4-a0e7-4e4b-8001-54b4c66a9b81_1200x630.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!ZzGK!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd5ea6fc4-a0e7-4e4b-8001-54b4c66a9b81_1200x630.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ZzGK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd5ea6fc4-a0e7-4e4b-8001-54b4c66a9b81_1200x630.jpeg" width="1200" height="630" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d5ea6fc4-a0e7-4e4b-8001-54b4c66a9b81_1200x630.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:630,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:15267,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ZzGK!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd5ea6fc4-a0e7-4e4b-8001-54b4c66a9b81_1200x630.jpeg 424w, https://substackcdn.com/image/fetch/$s_!ZzGK!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd5ea6fc4-a0e7-4e4b-8001-54b4c66a9b81_1200x630.jpeg 848w, https://substackcdn.com/image/fetch/$s_!ZzGK!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd5ea6fc4-a0e7-4e4b-8001-54b4c66a9b81_1200x630.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!ZzGK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd5ea6fc4-a0e7-4e4b-8001-54b4c66a9b81_1200x630.jpeg 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Printre capacit&#259;&#539;ile modelelor de limbaj mai noi cum sunt llama2, sau mistral-7b se num&#259;r&#259; &#537;i acela de a ra&#539;iona &#238;ntr-o manier&#259; similar&#259; creierului uman. Astfel pot oferi r&#259;spunsuri la probleme de matematic&#259; de exemplu: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Asxv!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac56cd60-6efa-442f-9808-232606a85376_1054x577.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Asxv!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac56cd60-6efa-442f-9808-232606a85376_1054x577.png 424w, https://substackcdn.com/image/fetch/$s_!Asxv!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac56cd60-6efa-442f-9808-232606a85376_1054x577.png 848w, https://substackcdn.com/image/fetch/$s_!Asxv!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac56cd60-6efa-442f-9808-232606a85376_1054x577.png 1272w, https://substackcdn.com/image/fetch/$s_!Asxv!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac56cd60-6efa-442f-9808-232606a85376_1054x577.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Asxv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac56cd60-6efa-442f-9808-232606a85376_1054x577.png" width="1054" height="577" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ac56cd60-6efa-442f-9808-232606a85376_1054x577.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:577,&quot;width&quot;:1054,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:77694,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Asxv!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac56cd60-6efa-442f-9808-232606a85376_1054x577.png 424w, https://substackcdn.com/image/fetch/$s_!Asxv!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac56cd60-6efa-442f-9808-232606a85376_1054x577.png 848w, https://substackcdn.com/image/fetch/$s_!Asxv!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac56cd60-6efa-442f-9808-232606a85376_1054x577.png 1272w, https://substackcdn.com/image/fetch/$s_!Asxv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac56cd60-6efa-442f-9808-232606a85376_1054x577.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Gemini 1.5</figcaption></figure></div><p>Gemini, genereaz&#259; r&#259;spunsul &#238;nso&#539;it de o explica&#539;ie detaliat&#259; a pa&#537;ilor. &#206;ns&#259;, nu putem folosi acest r&#259;spuns pentru a fi citit de un alt program de exemplu, care ar fi responsabil de generarea unor rapoarte sau statistici, &#537;i tot ce are nevoie programul este num&#259;rul rezultat: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!KiT7!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19c5053f-582e-47c4-8c81-60adac8a50b1_1135x299.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!KiT7!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19c5053f-582e-47c4-8c81-60adac8a50b1_1135x299.png 424w, https://substackcdn.com/image/fetch/$s_!KiT7!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19c5053f-582e-47c4-8c81-60adac8a50b1_1135x299.png 848w, https://substackcdn.com/image/fetch/$s_!KiT7!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19c5053f-582e-47c4-8c81-60adac8a50b1_1135x299.png 1272w, https://substackcdn.com/image/fetch/$s_!KiT7!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19c5053f-582e-47c4-8c81-60adac8a50b1_1135x299.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!KiT7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19c5053f-582e-47c4-8c81-60adac8a50b1_1135x299.png" width="1135" height="299" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/19c5053f-582e-47c4-8c81-60adac8a50b1_1135x299.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:299,&quot;width&quot;:1135,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:45876,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!KiT7!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19c5053f-582e-47c4-8c81-60adac8a50b1_1135x299.png 424w, https://substackcdn.com/image/fetch/$s_!KiT7!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19c5053f-582e-47c4-8c81-60adac8a50b1_1135x299.png 848w, https://substackcdn.com/image/fetch/$s_!KiT7!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19c5053f-582e-47c4-8c81-60adac8a50b1_1135x299.png 1272w, https://substackcdn.com/image/fetch/$s_!KiT7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19c5053f-582e-47c4-8c81-60adac8a50b1_1135x299.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Gemini, afi&#537;eaz&#259; doar rezultatul.</figcaption></figure></div><p>Chiar &#537;i dac&#259; prime&#537;te intruc&#539;iunea, Gemini men&#539;ioneaz&#259; &#8221;voturi&#8221; la sf&#226;r&#537;it. </p><h3>Extragerea informa&#539;iei relevante</h3><p>Aceasta este una dintre aplicabilit&#259;&#539;ile pe care le are Guidance - s&#259; capteze doar partea relevant&#259; a r&#259;spunsului unui LLM:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ttjf!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6184612f-88d6-4d05-bdd8-fc400a113919_2418x678.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ttjf!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6184612f-88d6-4d05-bdd8-fc400a113919_2418x678.png 424w, https://substackcdn.com/image/fetch/$s_!ttjf!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6184612f-88d6-4d05-bdd8-fc400a113919_2418x678.png 848w, https://substackcdn.com/image/fetch/$s_!ttjf!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6184612f-88d6-4d05-bdd8-fc400a113919_2418x678.png 1272w, https://substackcdn.com/image/fetch/$s_!ttjf!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6184612f-88d6-4d05-bdd8-fc400a113919_2418x678.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ttjf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6184612f-88d6-4d05-bdd8-fc400a113919_2418x678.png" width="1456" height="408" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6184612f-88d6-4d05-bdd8-fc400a113919_2418x678.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:408,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:122503,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ttjf!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6184612f-88d6-4d05-bdd8-fc400a113919_2418x678.png 424w, https://substackcdn.com/image/fetch/$s_!ttjf!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6184612f-88d6-4d05-bdd8-fc400a113919_2418x678.png 848w, https://substackcdn.com/image/fetch/$s_!ttjf!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6184612f-88d6-4d05-bdd8-fc400a113919_2418x678.png 1272w, https://substackcdn.com/image/fetch/$s_!ttjf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6184612f-88d6-4d05-bdd8-fc400a113919_2418x678.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><pre><code><code>&#206;ntrebare: Dintr-o popula&#539;ie de 236754 de persoane, 14872 au r&#259;spuns la sondaj. Ce procentaj din popula&#539;ie a r&#259;spuns la sondaj?

R&#259;spuns (%): 6</code></code></pre><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ehc4!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa397359b-5e29-4ec5-851e-aa6d47c0ce5d_2352x290.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ehc4!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa397359b-5e29-4ec5-851e-aa6d47c0ce5d_2352x290.png 424w, https://substackcdn.com/image/fetch/$s_!ehc4!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa397359b-5e29-4ec5-851e-aa6d47c0ce5d_2352x290.png 848w, https://substackcdn.com/image/fetch/$s_!ehc4!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa397359b-5e29-4ec5-851e-aa6d47c0ce5d_2352x290.png 1272w, https://substackcdn.com/image/fetch/$s_!ehc4!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa397359b-5e29-4ec5-851e-aa6d47c0ce5d_2352x290.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ehc4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa397359b-5e29-4ec5-851e-aa6d47c0ce5d_2352x290.png" width="1456" height="180" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a397359b-5e29-4ec5-851e-aa6d47c0ce5d_2352x290.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:180,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:45720,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ehc4!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa397359b-5e29-4ec5-851e-aa6d47c0ce5d_2352x290.png 424w, https://substackcdn.com/image/fetch/$s_!ehc4!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa397359b-5e29-4ec5-851e-aa6d47c0ce5d_2352x290.png 848w, https://substackcdn.com/image/fetch/$s_!ehc4!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa397359b-5e29-4ec5-851e-aa6d47c0ce5d_2352x290.png 1272w, https://substackcdn.com/image/fetch/$s_!ehc4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa397359b-5e29-4ec5-851e-aa6d47c0ce5d_2352x290.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><pre><code><code>Titlu generat: "Reanimat &#537;i Rezervat: O Via&#539;&#259; de Zombie &#238;ntr-o Pensiune"</code></code></pre><h3>Next level - generare de JSON</h3><p>Folosind acest tool, putem &#8221;programa&#8221; un LLM s&#259; genereze un r&#259;spuns &#238;n formatul JSON. Pentru a face asta e nevoie s&#259; ajust&#259;m codul, ca s&#259; includ&#259; c&#226;teva indicii despre format:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!mjhz!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F31335842-4523-4036-b6d8-eb13a4ade037_2352x970.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!mjhz!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F31335842-4523-4036-b6d8-eb13a4ade037_2352x970.png 424w, https://substackcdn.com/image/fetch/$s_!mjhz!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F31335842-4523-4036-b6d8-eb13a4ade037_2352x970.png 848w, https://substackcdn.com/image/fetch/$s_!mjhz!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F31335842-4523-4036-b6d8-eb13a4ade037_2352x970.png 1272w, https://substackcdn.com/image/fetch/$s_!mjhz!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F31335842-4523-4036-b6d8-eb13a4ade037_2352x970.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!mjhz!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F31335842-4523-4036-b6d8-eb13a4ade037_2352x970.png" width="1456" height="600" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/31335842-4523-4036-b6d8-eb13a4ade037_2352x970.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:600,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:261729,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!mjhz!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F31335842-4523-4036-b6d8-eb13a4ade037_2352x970.png 424w, https://substackcdn.com/image/fetch/$s_!mjhz!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F31335842-4523-4036-b6d8-eb13a4ade037_2352x970.png 848w, https://substackcdn.com/image/fetch/$s_!mjhz!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F31335842-4523-4036-b6d8-eb13a4ade037_2352x970.png 1272w, https://substackcdn.com/image/fetch/$s_!mjhz!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F31335842-4523-4036-b6d8-eb13a4ade037_2352x970.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><pre><code>The following is a list of 10 big cities, starting with London in JSON format. The keys would be names of the cities and value should be their population size in millions:

{
    "London": 8.9,
    "New York": 8,
    "Tokyo": 13,
    "Mumbai": 20,
    "Delhi": 16,
    "Shanghai": 24,
    "SaoPaulo": 21,
    "MexicoCity": 21,
    "Osaka": 19,
    "Cairo": 20,
}</code></pre><p>Mai departe putem integra acest generator &#238;ntr-o func&#539;ie, pentru a crea un num&#259;r arbitrar de valori:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!_J1L!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ed33cf6-1fb2-4329-83cb-60c5ce2ff2d4_2560x922.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!_J1L!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ed33cf6-1fb2-4329-83cb-60c5ce2ff2d4_2560x922.png 424w, https://substackcdn.com/image/fetch/$s_!_J1L!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ed33cf6-1fb2-4329-83cb-60c5ce2ff2d4_2560x922.png 848w, https://substackcdn.com/image/fetch/$s_!_J1L!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ed33cf6-1fb2-4329-83cb-60c5ce2ff2d4_2560x922.png 1272w, https://substackcdn.com/image/fetch/$s_!_J1L!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ed33cf6-1fb2-4329-83cb-60c5ce2ff2d4_2560x922.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!_J1L!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ed33cf6-1fb2-4329-83cb-60c5ce2ff2d4_2560x922.png" width="1456" height="524" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1ed33cf6-1fb2-4329-83cb-60c5ce2ff2d4_2560x922.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:524,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:154885,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!_J1L!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ed33cf6-1fb2-4329-83cb-60c5ce2ff2d4_2560x922.png 424w, https://substackcdn.com/image/fetch/$s_!_J1L!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ed33cf6-1fb2-4329-83cb-60c5ce2ff2d4_2560x922.png 848w, https://substackcdn.com/image/fetch/$s_!_J1L!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ed33cf6-1fb2-4329-83cb-60c5ce2ff2d4_2560x922.png 1272w, https://substackcdn.com/image/fetch/$s_!_J1L!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ed33cf6-1fb2-4329-83cb-60c5ce2ff2d4_2560x922.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><pre><code>The following is a list of 6 big cities, starting with London in JSON format. The keys would be names of the cities and value should be their population size in millions:

{
    "London": 9,
    "NewYork": 8,
    "Tokyo": 13,
    "Mumbai": 20,
    "SaoPaulo": 21,
    "Delhi": 17,
}</code></pre><p>Aceast&#259; abordare poate fi extins&#259;, pentru a permite modelului de limbaj s&#259; foloseasc&#259; API-uri de unde s&#259; culeag&#259; date &#537;i s&#259; r&#259;spund&#259; la promt-uri &#238;n limbaj natural. </p><p>De asemenea <em>Guidance AI</em> poate fi folosit pentru a reduce din costurile de utilizare a unor modele a c&#259;ror cost depinde de num&#259;rul de token-uri folosite pentru generearea unui r&#259;spuns. Sau pentru a reduce &#8221;zgomotul&#8221; generat de o re&#539;ea neuronal&#259; cu scopul de a-l transmite unei alte re&#539;ele ca surs&#259;.</p><p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://stack.moustacios.dev/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Moustacios.Dev este o publica&#539;ie sus&#539;inut&#259; de voi, de comunitate. Pentru a primi post&#259;ri noi &#537;i pentru a-mi sus&#539;ine munca, v&#259; invit s&#259; v&#259; abona&#539;i:</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p></p><div><hr></div><p>Referin&#539;e:</p><ul><li><p><a href="https://github.com/guidance-ai/guidance">https://github.com/guidance-ai/guidance</a></p></li><li><p><a href="https://lightning.ai/lightning-ai/studios/structured-llm-output-and-function-calling-with-guidance">(EN) https://lightning.ai/lightning-ai/studios/structured-llm-output-and-function-calling-with-guidance</a></p></li></ul>]]></content:encoded></item><item><title><![CDATA[Alternative la registrul NPM!?]]></title><description><![CDATA[Registrul NPM &#537;i suprema&#539;ia sa are contestatarii s&#259;i]]></description><link>https://stack.moustacios.dev/p/alternative-la-registrul-npm</link><guid isPermaLink="false">https://stack.moustacios.dev/p/alternative-la-registrul-npm</guid><dc:creator><![CDATA[Teo cel Mustăcios]]></dc:creator><pubDate>Tue, 30 Apr 2024 04:07:33 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!C5wN!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4eca753-53b6-4b3d-8542-cacde3ad67c7_1920x1080.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!C5wN!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4eca753-53b6-4b3d-8542-cacde3ad67c7_1920x1080.webp" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!C5wN!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4eca753-53b6-4b3d-8542-cacde3ad67c7_1920x1080.webp 424w, https://substackcdn.com/image/fetch/$s_!C5wN!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4eca753-53b6-4b3d-8542-cacde3ad67c7_1920x1080.webp 848w, https://substackcdn.com/image/fetch/$s_!C5wN!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4eca753-53b6-4b3d-8542-cacde3ad67c7_1920x1080.webp 1272w, https://substackcdn.com/image/fetch/$s_!C5wN!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4eca753-53b6-4b3d-8542-cacde3ad67c7_1920x1080.webp 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!C5wN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4eca753-53b6-4b3d-8542-cacde3ad67c7_1920x1080.webp" width="1456" height="819" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d4eca753-53b6-4b3d-8542-cacde3ad67c7_1920x1080.webp&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:819,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:6388,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/webp&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!C5wN!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4eca753-53b6-4b3d-8542-cacde3ad67c7_1920x1080.webp 424w, https://substackcdn.com/image/fetch/$s_!C5wN!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4eca753-53b6-4b3d-8542-cacde3ad67c7_1920x1080.webp 848w, https://substackcdn.com/image/fetch/$s_!C5wN!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4eca753-53b6-4b3d-8542-cacde3ad67c7_1920x1080.webp 1272w, https://substackcdn.com/image/fetch/$s_!C5wN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4eca753-53b6-4b3d-8542-cacde3ad67c7_1920x1080.webp 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Proiectul<strong> Node Package Manager</strong> este, pe l&#226;ng&#259; utilitarul care descarc&#259; &#537;i rezolv&#259; calea c&#259;tre pachetele unui proiect Javascript, &#537;i registrul care g&#259;zduie&#537;te aceste pachete. &#536;i de&#537;i avem c&#226;teva alternative viabile la npm ca &#537;i dependency manager, cum ar fi yarn<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-1" href="#footnote-1" target="_self">1</a>, pnmp, deno sau bun<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-2" href="#footnote-2" target="_self">2</a>, la capitolul registru de pachete NPM nu are competitor. Desigur, faptul c&#259; npm vine ca &#238;n bundle-ul de instalare nodejs, &#537;i devreme ce npm folose&#537;te npmjs implicit  ca &#537;i registru, aceast&#259; str&#226;ns&#259; leg&#259;tur&#259; &#238;ntre cele dou&#259; proiecte le-a f&#259;cut aproape inseparabile. Din p&#259;cate din lipsa competi&#539;iei, ducem lipsa &#537;i de inova&#539;ie pe acest front - ultimul update seminificativ pe care l-a primit a fost suportul pentru provenine&#539;&#259; de acum 7 luni<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-3" href="#footnote-3" target="_self">3</a>.</p><p>Din fericire asta e pe cale s&#259; se schimbe, &#537;i, cel pu&#539;in p&#226;n&#259; acum avem anun&#539;a&#539;i doi competitori la registrul de pachete:</p><h3>JSR</h3><p>Creat de echipa din spatele proiectului Deno &#537;i totodat&#259; de Ryan Dahl, creatorul nodejs, acest ecosistem (package manager &#537;i registry), &#238;&#537;i propune s&#259; rezolve multe dintre dificult&#259;&#539;ile de a publica pachete Typescript cu npm. A&#537;adar ofer&#259; suport nativ pentru acest limbaj: va genera automat documenta&#539;ii &#537;i defini&#539;iile de tipuri - fi&#537;ierele d.ts &#537;i desigur pote fi folosit cu pachete &#238;n Javascript &#238;n locul NPM. </p><p>Din p&#259;cate pentru unii dar din fericire pentru al&#539;ii care nu depind de libr&#259;rii cu <code>CommonJS sau versiuni vechi de Node</code>, JSR va suporta doar module standard EcmaScript (ESM), care sunt deja standard<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-4" href="#footnote-4" target="_self">4</a>.</p><p>O alt&#259; not&#259; important&#259; este generarea defini&#539;iilor pentru tipuri,  care este un proces ce consum&#259; resurse. JSR va genera defini&#539;ii doar pentru acele tipuri definite explicit. &#8221;Slow types&#8221; vor fi &#238;nlocuite cu any iar documenta&#539;ia generat&#259; s-ar putea s&#259; le omit&#259;<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-5" href="#footnote-5" target="_self">5</a>. </p><h3>VLT (Volt)</h3><p>Despre acest proiect avem mai pu&#539;ine detalii, dar unul important de men&#539;ionat este c&#259; a fost anun&#539;at de c&#259;tre creatorul NPM - Isaac Z. Schlueter<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-6" href="#footnote-6" target="_self">6</a>. Iar unul dintre articolele pe care le-am g&#259;sit pe blogul proiectului descrie bug-ul numit <em>manifest confusion</em>, pe care dac&#259; e&#537;ti pasionat sau responsabil de securitate &#539;i-l recomand: <em><a href="https://blog.vlt.sh/blog/the-massive-hole-in-the-npm-ecosystem">The massive bug at the heart of the npm ecosystem</a>.</em></p><p>A&#537;adar se pare c&#259; acest proiect va pune un accent mai mare pe securitatea pachetelor &#537;i ecosistemului ceea ce este un lucru bun.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://stack.moustacios.dev/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Moustacios.Dev este o publica&#539;ie sus&#539;inut&#259; de voi, de comunitate. Pentru a primi post&#259;ri noi &#537;i pentru a-mi sus&#539;ine munca, v&#259; invit s&#259; v&#259; abona&#539;i:</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-1" href="#footnote-anchor-1" class="footnote-number" contenteditable="false" target="_self">1</a><div class="footnote-content"><p><a href="https://yarnpkg.com/">[EN] Yarn package manager</a></p></div></div><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-2" href="#footnote-anchor-2" class="footnote-number" contenteditable="false" target="_self">2</a><div class="footnote-content"><p><a href="https://bun.sh/">[EN] Bun runtime</a></p></div></div><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-3" href="#footnote-anchor-3" class="footnote-number" contenteditable="false" target="_self">3</a><div class="footnote-content"><p><a href="https://github.blog/changelog/2023-09-26-npm-provenance-general-availability/">[EN] npm provenance general availability</a></p></div></div><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-4" href="#footnote-anchor-4" class="footnote-number" contenteditable="false" target="_self">4</a><div class="footnote-content"><p><a href="https://jsr.io/docs/publishing-packages#esm-only">[EN] JSR / Publishing / ESM Only</a></p></div></div><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-5" href="#footnote-anchor-5" class="footnote-number" contenteditable="false" target="_self">5</a><div class="footnote-content"><p><a href="https://jsr.io/docs/about-slow-types#about-slow-types">[EN] JSR / Docs / Slow types</a></p></div></div><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-6" href="#footnote-anchor-6" class="footnote-number" contenteditable="false" target="_self">6</a><div class="footnote-content"><p><a href="https://github.com/isaacs">Isaac Z. Schleuter on GitHub</a></p><p></p></div></div>]]></content:encoded></item><item><title><![CDATA[Sudo pentru Windows]]></title><description><![CDATA[Comanda sudo va fi disponibil&#259; &#537;i pe sistemele Windows]]></description><link>https://stack.moustacios.dev/p/sudo-pentru-windows</link><guid isPermaLink="false">https://stack.moustacios.dev/p/sudo-pentru-windows</guid><dc:creator><![CDATA[Teo cel Mustăcios]]></dc:creator><pubDate>Tue, 16 Apr 2024 04:15:22 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/87afcee8-24da-4e5a-9215-6d6cc5548e31_1400x933.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Comanda sudo de pe sistemele Linux este indispensabil&#259; pentru administrarea &#537;i executarea programelor cu permisiuni elevate, &#238;ns&#259; pe Windows singura alternativ&#259; era &#8221;<em>Run as administrator</em>&#8221;<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-1" href="#footnote-1" target="_self">1</a>, din meniul click dreapta: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!G--x!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc98604aa-62c1-4edc-85bc-8fbeed2fe9f3_1200x510.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!G--x!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc98604aa-62c1-4edc-85bc-8fbeed2fe9f3_1200x510.png 424w, https://substackcdn.com/image/fetch/$s_!G--x!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc98604aa-62c1-4edc-85bc-8fbeed2fe9f3_1200x510.png 848w, https://substackcdn.com/image/fetch/$s_!G--x!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc98604aa-62c1-4edc-85bc-8fbeed2fe9f3_1200x510.png 1272w, https://substackcdn.com/image/fetch/$s_!G--x!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc98604aa-62c1-4edc-85bc-8fbeed2fe9f3_1200x510.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!G--x!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc98604aa-62c1-4edc-85bc-8fbeed2fe9f3_1200x510.png" width="1200" height="510" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c98604aa-62c1-4edc-85bc-8fbeed2fe9f3_1200x510.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:510,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:217813,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!G--x!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc98604aa-62c1-4edc-85bc-8fbeed2fe9f3_1200x510.png 424w, https://substackcdn.com/image/fetch/$s_!G--x!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc98604aa-62c1-4edc-85bc-8fbeed2fe9f3_1200x510.png 848w, https://substackcdn.com/image/fetch/$s_!G--x!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc98604aa-62c1-4edc-85bc-8fbeed2fe9f3_1200x510.png 1272w, https://substackcdn.com/image/fetch/$s_!G--x!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc98604aa-62c1-4edc-85bc-8fbeed2fe9f3_1200x510.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Noua comand&#259; <code>sudo </code>este disponibil&#259; &#238;ncep&#226;nd cu Windows 11 build 26045 sau mai recent, fiind necesar&#259; activarea ei din meniul de Settings &gt; Developer Features.</p><p>Aceasta nu este un port al comenzii omonime din linux, &#537;i nici o versiune emulat&#259;, deoarece modul de func&#539;ionare a permisiunilor &#238;ntre cele dou&#259; sisteme este fundamental diferit. A&#537;adar sunt dou&#259; utilitare cu op&#539;iuni diferite. De asemenea, noul sudo nu este un &#238;nlocuitor pentru runas, care permite rularea sub orice user, inclusiv unul cu drepturi de administrare. Utilitatul sudo este limitat la comanda/procesul pe care &#238;l prime&#537;te ca argument &#537;i ruleaz&#259; doar cu drepturi de administrator.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Wg_U!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc972fa67-8b98-4485-8f7a-a01a0e7a902b_1419x726.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Wg_U!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc972fa67-8b98-4485-8f7a-a01a0e7a902b_1419x726.png 424w, https://substackcdn.com/image/fetch/$s_!Wg_U!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc972fa67-8b98-4485-8f7a-a01a0e7a902b_1419x726.png 848w, https://substackcdn.com/image/fetch/$s_!Wg_U!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc972fa67-8b98-4485-8f7a-a01a0e7a902b_1419x726.png 1272w, https://substackcdn.com/image/fetch/$s_!Wg_U!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc972fa67-8b98-4485-8f7a-a01a0e7a902b_1419x726.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Wg_U!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc972fa67-8b98-4485-8f7a-a01a0e7a902b_1419x726.png" width="1419" height="726" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c972fa67-8b98-4485-8f7a-a01a0e7a902b_1419x726.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:726,&quot;width&quot;:1419,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:132163,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Wg_U!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc972fa67-8b98-4485-8f7a-a01a0e7a902b_1419x726.png 424w, https://substackcdn.com/image/fetch/$s_!Wg_U!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc972fa67-8b98-4485-8f7a-a01a0e7a902b_1419x726.png 848w, https://substackcdn.com/image/fetch/$s_!Wg_U!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc972fa67-8b98-4485-8f7a-a01a0e7a902b_1419x726.png 1272w, https://substackcdn.com/image/fetch/$s_!Wg_U!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc972fa67-8b98-4485-8f7a-a01a0e7a902b_1419x726.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Sintaxa, este asemn&#259;n&#259;toare cu cea din linux <code>sudo [comand&#259;]</code>:</p><pre><code>sudo netstat -ab</code></pre><p>Putem configurara cum va rula sudo o comand&#259;:</p><ul><li><p><em>&#206;ntr-o fereastr&#259; nou&#259; (</em><code>forceNewWindow</code><em>)</em>: va rula aplica&#539;ia &#238;ntr-o fereastr&#259; de terminal nou&#259;, imit&#226;nd comportamentul comenzii <code>runas /user:admin</code></p></li><li><p><em>Input closed (</em><code>disableInput</code><em>)</em>: va rula comanda cu permisiuni elevate &#238;n terminal, dar f&#259;r&#259; input. Altfel spus procesul lansat cu sudo nu are access la input-ul din terminal &#537;i nu vei putea interac&#539;iona cu el. Acest mod ofer&#259; posibilitatea de a mitiga unele riscuri de securitate<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-2" href="#footnote-2" target="_self">2</a>.</p></li><li><p><em>Inline (</em><code>normal</code><em>)</em>: similar cu comportamentul sudo de pe alte platforme, va rula comanda cu permisiuni elevate, oferind totodat&#259; access la stdin/stdout din terminal.</p></li></ul><p>Aceste moduri pot fi rotite cu op&#539;iunea configEnable:</p><pre><code>sudo config --enable &lt;forceNewWindow|disableInput|normal&gt;</code></pre><h4>Gsudo</h4><p>Gsudo este un proiect open-source similar, care emulleaz&#259; sudo pentru Windows. Poate fi instalat cu scoop sau winget &#537;i dispune de mai multe op&#539;iuni dec&#226;t varianta oficial&#259;: <a href="https://github.com/gerardog/gsudo">gerardog/gsudo</a>. A&#537;adar dac&#259; dori&#539;i op&#539;iuni de selec&#539;ie a unui utilizator, Local System accounts sau montarea de network drives folosi&#539;i <code>gsudo</code>.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://stack.moustacios.dev/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Moustacios.Dev este o publica&#539;ie sus&#539;inut&#259; de voi, de comunitate. Pentru a primi post&#259;ri noi &#537;i pentru a-mi sus&#539;ine munca, v&#259; invit s&#259; v&#259; abona&#539;i:</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-1" href="#footnote-anchor-1" class="footnote-number" contenteditable="false" target="_self">1</a><div class="footnote-content"><p><a href="https://learn.microsoft.com/en-us/windows/terminal/faq#how-do-i-run-a-shell-in-windows-terminal-in-administrator-mode">How do I run a shell in Windows Terminal in administrator mode? (EN)</a></p></div></div><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-2" href="#footnote-anchor-2" class="footnote-number" contenteditable="false" target="_self">2</a><div class="footnote-content"><p><a href="https://learn.microsoft.com/en-us/windows/sudo/#security-considerations">Sudo for Windows / Security Considerations (EN)</a></p></div></div>]]></content:encoded></item><item><title><![CDATA[Mountaineer: Python plus ReactJS într-un framework]]></title><description><![CDATA[Dou&#259; framework-uri &#238;ntr-unul singur - bateriile sunt incluse!]]></description><link>https://stack.moustacios.dev/p/mountaineer-python-plus-reactjs-intr</link><guid isPermaLink="false">https://stack.moustacios.dev/p/mountaineer-python-plus-reactjs-intr</guid><dc:creator><![CDATA[Teo cel Mustăcios]]></dc:creator><pubDate>Wed, 10 Apr 2024 04:15:24 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!qX0d!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87c36782-fdb9-4329-bdb2-995580c6191a_2048x622.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!qX0d!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87c36782-fdb9-4329-bdb2-995580c6191a_2048x622.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!qX0d!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87c36782-fdb9-4329-bdb2-995580c6191a_2048x622.png 424w, https://substackcdn.com/image/fetch/$s_!qX0d!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87c36782-fdb9-4329-bdb2-995580c6191a_2048x622.png 848w, https://substackcdn.com/image/fetch/$s_!qX0d!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87c36782-fdb9-4329-bdb2-995580c6191a_2048x622.png 1272w, https://substackcdn.com/image/fetch/$s_!qX0d!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87c36782-fdb9-4329-bdb2-995580c6191a_2048x622.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!qX0d!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87c36782-fdb9-4329-bdb2-995580c6191a_2048x622.png" width="1456" height="442" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/87c36782-fdb9-4329-bdb2-995580c6191a_2048x622.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:442,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:675789,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!qX0d!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87c36782-fdb9-4329-bdb2-995580c6191a_2048x622.png 424w, https://substackcdn.com/image/fetch/$s_!qX0d!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87c36782-fdb9-4329-bdb2-995580c6191a_2048x622.png 848w, https://substackcdn.com/image/fetch/$s_!qX0d!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87c36782-fdb9-4329-bdb2-995580c6191a_2048x622.png 1272w, https://substackcdn.com/image/fetch/$s_!qX0d!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87c36782-fdb9-4329-bdb2-995580c6191a_2048x622.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Nu am foarte mult&#259; experien&#539;&#259; cu Python, &#238;ns&#259; cred c&#259; pot recunoa&#537;te un framework web cu poten&#539;ial atunci c&#226;nd &#238;l v&#259;d. Mountaineer, p&#259;streaz&#259; structura MVC cu care ne-am obi&#537;nuit, &#238;ns&#259; a renun&#539;at complet la tempate-uri generate &#238;n backend &#537;i deleag&#259; aceast&#259; &#8221;corvoad&#259;&#8221; c&#259;tre un alt framework deja matur - React; Care pe l&#226;ng&#259; client-side rendering, este configurat implicit s&#259; fac&#259; server-side rendering la html. </p><p>A&#537;adar, acest framework este o alipire &#238;ntre FastAPI &#537;i ReactJS, dar nu doar at&#226;t, deoarece c&#259; vine cu tooling &#537;i suport pentru data binding bidirec&#539;ional din modele c&#259;tre frontend-ul de React. </p><h2>Structura unui proiect</h2><pre><code><code>.
&#9500;&#9472;&#9472; README.md
&#9500;&#9472;&#9472; docker-compose.yml
&#9500;&#9472;&#9472; poetry.lock
&#9500;&#9472;&#9472; pyproject.toml
&#9492;&#9472;&#9472; webapp
    &#9500;&#9472;&#9472; __init__.py
    &#9500;&#9472;&#9472; app.py
    &#9500;&#9472;&#9472; cli.py
    &#9500;&#9472;&#9472; config.py
    &#9500;&#9472;&#9472; controllers
    &#9474;   &#9500;&#9472;&#9472; __init__.py
    &#9474;   &#9500;&#9472;&#9472; detail.py
    &#9474;   &#9492;&#9472;&#9472; home.py
    &#9500;&#9472;&#9472; main.py
    &#9500;&#9472;&#9472; models
    &#9474;   &#9500;&#9472;&#9472; __init__.py
    &#9474;   &#9492;&#9472;&#9472; detail.py
    &#9492;&#9472;&#9472; views
        &#9500;&#9472;&#9472; app
        &#9474;   &#9500;&#9472;&#9472; detail
        &#9474;   &#9474;   &#9492;&#9472;&#9472; page.tsx
        &#9474;   &#9500;&#9472;&#9472; home
        &#9474;   &#9474;   &#9492;&#9472;&#9472; page.tsx
        &#9474;   &#9492;&#9472;&#9472; main.css
        &#9500;&#9472;&#9472; package.json
        &#9500;&#9472;&#9472; postcss.config.js
        &#9492;&#9472;&#9472; tailwind.config.js</code></code></pre><p>Top-level, avem fi&#537;ierul de configrare, un lockfile pentru Poetry<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-1" href="#footnote-1" target="_self">1</a> specific proiectului &#537;i un docker-compose, unde definim servicii externe. Implicit tool-ul de generare de cod, folose&#537;te PostgreSQL ca baz&#259; de date. </p><p>Apoi, sursele aplica&#539;iei, sunt organizate &#238;n cele trei categorii: <em>models</em>, <em>controllers </em>&#537;i <em>views</em>. Tot ce &#539;ine de React este &#238;n localizat &#238;n views, unde avem un package.json &#537;i fi&#537;ierul de configurare Tailwind<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-2" href="#footnote-2" target="_self">2</a>. Aici avem nevoie de node/npm pentru instalearea pachetelor specifice.   </p><h2>SSR cu React &#537;i useServer</h2><p>Pentru data binding &#537;i server side rendering, mountaineer folose&#537;te un hook special: <em>useServer</em>, care ofer&#259; componentelor UI datele definite &#238;n modele &#537;i leag&#259; ac&#539;iunile &#238;n backend: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!L1X6!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F195424d5-972d-4065-bf36-357671244de6_3656x4468.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!L1X6!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F195424d5-972d-4065-bf36-357671244de6_3656x4468.png 424w, https://substackcdn.com/image/fetch/$s_!L1X6!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F195424d5-972d-4065-bf36-357671244de6_3656x4468.png 848w, https://substackcdn.com/image/fetch/$s_!L1X6!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F195424d5-972d-4065-bf36-357671244de6_3656x4468.png 1272w, https://substackcdn.com/image/fetch/$s_!L1X6!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F195424d5-972d-4065-bf36-357671244de6_3656x4468.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!L1X6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F195424d5-972d-4065-bf36-357671244de6_3656x4468.png" width="1456" height="1779" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/195424d5-972d-4065-bf36-357671244de6_3656x4468.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1779,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:932476,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!L1X6!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F195424d5-972d-4065-bf36-357671244de6_3656x4468.png 424w, https://substackcdn.com/image/fetch/$s_!L1X6!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F195424d5-972d-4065-bf36-357671244de6_3656x4468.png 848w, https://substackcdn.com/image/fetch/$s_!L1X6!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F195424d5-972d-4065-bf36-357671244de6_3656x4468.png 1272w, https://substackcdn.com/image/fetch/$s_!L1X6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F195424d5-972d-4065-bf36-357671244de6_3656x4468.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Acestea vor fi autocompletate de c&#259;tre IDE, iar state-ul este &#238;ntodeauna sincronizat, folosind un decorator special &#537;i anume <code>@sideeffect</code>, &#238;n controller:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!D6nA!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcceb3bee-7bc0-4cae-83f0-88a7b333de82_3656x2136.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!D6nA!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcceb3bee-7bc0-4cae-83f0-88a7b333de82_3656x2136.png 424w, https://substackcdn.com/image/fetch/$s_!D6nA!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcceb3bee-7bc0-4cae-83f0-88a7b333de82_3656x2136.png 848w, https://substackcdn.com/image/fetch/$s_!D6nA!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcceb3bee-7bc0-4cae-83f0-88a7b333de82_3656x2136.png 1272w, https://substackcdn.com/image/fetch/$s_!D6nA!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcceb3bee-7bc0-4cae-83f0-88a7b333de82_3656x2136.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!D6nA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcceb3bee-7bc0-4cae-83f0-88a7b333de82_3656x2136.png" width="1456" height="851" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/cceb3bee-7bc0-4cae-83f0-88a7b333de82_3656x2136.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:851,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:433745,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!D6nA!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcceb3bee-7bc0-4cae-83f0-88a7b333de82_3656x2136.png 424w, https://substackcdn.com/image/fetch/$s_!D6nA!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcceb3bee-7bc0-4cae-83f0-88a7b333de82_3656x2136.png 848w, https://substackcdn.com/image/fetch/$s_!D6nA!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcceb3bee-7bc0-4cae-83f0-88a7b333de82_3656x2136.png 1272w, https://substackcdn.com/image/fetch/$s_!D6nA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcceb3bee-7bc0-4cae-83f0-88a7b333de82_3656x2136.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://stack.moustacios.dev/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">&#206;nscrie-te pentru nout&#259;&#539;i:</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>Mountaineer detecteaz&#259; prezen&#539;a func&#539;iei cu efect secundar &#537;i evalueaz&#259; semn&#259;tura acesteia. Apoi o expune c&#259;tre frontend ca o func&#539;ie asincron&#259;.</p><p><em>HomeController</em>, expune func&#539;ia <code>add_todo </code>iar la ad&#259;ugarea unui item, componenta &#238;&#537;i va re&#238;nc&#259;rca lista, f&#259;r&#259; a fi nevoie de extra cod. </p><p>Aceast&#259; caracteristic&#259; se extinde cu suportul pentru SSR - state-ul r&#259;m&#226;ne pe server &#537;i aplica&#539;ia poate fi utilizat&#259; &#537;i c&#226;nd javascript este dezactivat.</p><h3>SQLModel + Pydantic</h3><p>Modelele se definesc &#238;n directorul <code>models</code>, &#537;i fiecare model este &#537;i un obiect Pyhton. Pydantic asigur&#259; validarea &#537;i suportul pentru adnot&#259;ri &#238;n IDE:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!7Dla!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5078d330-5e65-469d-bf82-aa652649777b_3656x1260.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!7Dla!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5078d330-5e65-469d-bf82-aa652649777b_3656x1260.png 424w, https://substackcdn.com/image/fetch/$s_!7Dla!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5078d330-5e65-469d-bf82-aa652649777b_3656x1260.png 848w, https://substackcdn.com/image/fetch/$s_!7Dla!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5078d330-5e65-469d-bf82-aa652649777b_3656x1260.png 1272w, https://substackcdn.com/image/fetch/$s_!7Dla!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5078d330-5e65-469d-bf82-aa652649777b_3656x1260.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!7Dla!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5078d330-5e65-469d-bf82-aa652649777b_3656x1260.png" width="1456" height="502" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5078d330-5e65-469d-bf82-aa652649777b_3656x1260.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:502,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:248119,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!7Dla!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5078d330-5e65-469d-bf82-aa652649777b_3656x1260.png 424w, https://substackcdn.com/image/fetch/$s_!7Dla!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5078d330-5e65-469d-bf82-aa652649777b_3656x1260.png 848w, https://substackcdn.com/image/fetch/$s_!7Dla!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5078d330-5e65-469d-bf82-aa652649777b_3656x1260.png 1272w, https://substackcdn.com/image/fetch/$s_!7Dla!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5078d330-5e65-469d-bf82-aa652649777b_3656x1260.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Aceast&#259; conven&#539;ie p&#259;streaz&#259; compatibilitatea cu SQLAlchemy, facilit&#226;nd migrarea de &#238;ntre cele dou&#259; ORM-uri dar &#537;i integrarea cu FastAPI.</p><p>Framework-ul este la versiunea 0.4, a&#537;adar nu este &#238;nc&#259; recomandat pentru proiecte deja &#238;n produc&#539;ie, &#238;ns&#259; pentru un hobby project sau un MVP mi se pare potrivit. </p><p>Pute&#539;i afla mai multe despre Mountaineer pe pagina proiectului: <a href="https://mountaineer.sh/">www.mountaineer.sh</a> sau pe github: <a href="https://github.com/piercefreeman/mountaineer">piercefreeman/mountaineer</a>.</p><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-1" href="#footnote-anchor-1" class="footnote-number" contenteditable="false" target="_self">1</a><div class="footnote-content"><p><a href="https://python-poetry.org/docs/">Poetry - Python dependency management and packaging</a> (EN)</p></div></div><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-2" href="#footnote-anchor-2" class="footnote-number" contenteditable="false" target="_self">2</a><div class="footnote-content"><p><a href="https://tailwindcss.com/">Tailwind CSS</a> (EN)</p></div></div>]]></content:encoded></item><item><title><![CDATA[Language nerds: PHP local dev server]]></title><description><![CDATA[Interpreterul PHP dispune de un web server, foarte util pentru development]]></description><link>https://stack.moustacios.dev/p/language-nerds-php-local-dev-server</link><guid isPermaLink="false">https://stack.moustacios.dev/p/language-nerds-php-local-dev-server</guid><dc:creator><![CDATA[Teo cel Mustăcios]]></dc:creator><pubDate>Thu, 04 Apr 2024 04:45:35 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!8AcS!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0fa5ccc-9414-4613-9cfa-f8e5e4b41ed5_6174x3473.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!8AcS!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0fa5ccc-9414-4613-9cfa-f8e5e4b41ed5_6174x3473.webp" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!8AcS!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0fa5ccc-9414-4613-9cfa-f8e5e4b41ed5_6174x3473.webp 424w, https://substackcdn.com/image/fetch/$s_!8AcS!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0fa5ccc-9414-4613-9cfa-f8e5e4b41ed5_6174x3473.webp 848w, https://substackcdn.com/image/fetch/$s_!8AcS!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0fa5ccc-9414-4613-9cfa-f8e5e4b41ed5_6174x3473.webp 1272w, https://substackcdn.com/image/fetch/$s_!8AcS!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0fa5ccc-9414-4613-9cfa-f8e5e4b41ed5_6174x3473.webp 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!8AcS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0fa5ccc-9414-4613-9cfa-f8e5e4b41ed5_6174x3473.webp" width="1456" height="819" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e0fa5ccc-9414-4613-9cfa-f8e5e4b41ed5_6174x3473.webp&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:819,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1253304,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/webp&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!8AcS!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0fa5ccc-9414-4613-9cfa-f8e5e4b41ed5_6174x3473.webp 424w, https://substackcdn.com/image/fetch/$s_!8AcS!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0fa5ccc-9414-4613-9cfa-f8e5e4b41ed5_6174x3473.webp 848w, https://substackcdn.com/image/fetch/$s_!8AcS!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0fa5ccc-9414-4613-9cfa-f8e5e4b41ed5_6174x3473.webp 1272w, https://substackcdn.com/image/fetch/$s_!8AcS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe0fa5ccc-9414-4613-9cfa-f8e5e4b41ed5_6174x3473.webp 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>&#206;nc&#259; de la versiune 5.4, PHP dispune de un web server pentru depanarea &#537;i rularea scripturilor sub PHP SAPI. &#206;l po&#539;i folosi ca s&#259; testezi rapid rularea unui script din borwser sau la o cerere Ajax:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!n7TJ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6ab7a1c-29ef-48b6-b25e-c023fb07d234_2972x580.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!n7TJ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6ab7a1c-29ef-48b6-b25e-c023fb07d234_2972x580.png 424w, https://substackcdn.com/image/fetch/$s_!n7TJ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6ab7a1c-29ef-48b6-b25e-c023fb07d234_2972x580.png 848w, https://substackcdn.com/image/fetch/$s_!n7TJ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6ab7a1c-29ef-48b6-b25e-c023fb07d234_2972x580.png 1272w, https://substackcdn.com/image/fetch/$s_!n7TJ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6ab7a1c-29ef-48b6-b25e-c023fb07d234_2972x580.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!n7TJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6ab7a1c-29ef-48b6-b25e-c023fb07d234_2972x580.png" width="1456" height="284" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e6ab7a1c-29ef-48b6-b25e-c023fb07d234_2972x580.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:284,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:107652,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!n7TJ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6ab7a1c-29ef-48b6-b25e-c023fb07d234_2972x580.png 424w, https://substackcdn.com/image/fetch/$s_!n7TJ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6ab7a1c-29ef-48b6-b25e-c023fb07d234_2972x580.png 848w, https://substackcdn.com/image/fetch/$s_!n7TJ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6ab7a1c-29ef-48b6-b25e-c023fb07d234_2972x580.png 1272w, https://substackcdn.com/image/fetch/$s_!n7TJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6ab7a1c-29ef-48b6-b25e-c023fb07d234_2972x580.png 1456w" sizes="100vw"></picture><div></div></div></a></figure></div><p>Dar pe l&#226;ng&#259; asta, mai putem configura un director, din care s&#259; fie ales un index.php sau index.html, cu fi&#537;iere statice &#537;i non-statice, sau chiar s&#259; rut&#259;m cererile &#238;n func&#539;ie de cale. Sintaxa pentru acest utilizar este urm&#259;toarea:</p><pre><code>php -S [domeniu|ip]:[port] [-t dosar] [script]</code></pre><p>De exemplu, pentru a servi un director, folosim op&#539;iunea <em>-t </em>urmat&#259; de calea acestuia:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!14NZ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a34cb56-0679-425a-a912-eaabf04d2f95_2972x580.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!14NZ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a34cb56-0679-425a-a912-eaabf04d2f95_2972x580.png 424w, https://substackcdn.com/image/fetch/$s_!14NZ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a34cb56-0679-425a-a912-eaabf04d2f95_2972x580.png 848w, https://substackcdn.com/image/fetch/$s_!14NZ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a34cb56-0679-425a-a912-eaabf04d2f95_2972x580.png 1272w, https://substackcdn.com/image/fetch/$s_!14NZ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a34cb56-0679-425a-a912-eaabf04d2f95_2972x580.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!14NZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a34cb56-0679-425a-a912-eaabf04d2f95_2972x580.png" width="1456" height="284" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5a34cb56-0679-425a-a912-eaabf04d2f95_2972x580.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:284,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:111434,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!14NZ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a34cb56-0679-425a-a912-eaabf04d2f95_2972x580.png 424w, https://substackcdn.com/image/fetch/$s_!14NZ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a34cb56-0679-425a-a912-eaabf04d2f95_2972x580.png 848w, https://substackcdn.com/image/fetch/$s_!14NZ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a34cb56-0679-425a-a912-eaabf04d2f95_2972x580.png 1272w, https://substackcdn.com/image/fetch/$s_!14NZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a34cb56-0679-425a-a912-eaabf04d2f95_2972x580.png 1456w" sizes="100vw"></picture><div></div></div></a></figure></div><p>Toate fi&#537;ierele din <em>server/public</em> vor fi servite direct (imagini sau html), iar fi&#537;ierele cu extensia <em>.php</em> vor fi executate. </p><h4>Rutarea cererilor</h4><p>Putem crea un ruter pentru a simula o aplica&#539;ie care direc&#539;ioneaz&#259; cererile c&#259;tre alte func&#539;ii sau fi&#537;iere, &#238;n func&#539;ie de cale:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!VNJW!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F201fa747-f0f7-40b8-915b-7ce5dda467d7_2972x2816.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!VNJW!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F201fa747-f0f7-40b8-915b-7ce5dda467d7_2972x2816.png 424w, https://substackcdn.com/image/fetch/$s_!VNJW!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F201fa747-f0f7-40b8-915b-7ce5dda467d7_2972x2816.png 848w, https://substackcdn.com/image/fetch/$s_!VNJW!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F201fa747-f0f7-40b8-915b-7ce5dda467d7_2972x2816.png 1272w, https://substackcdn.com/image/fetch/$s_!VNJW!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F201fa747-f0f7-40b8-915b-7ce5dda467d7_2972x2816.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!VNJW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F201fa747-f0f7-40b8-915b-7ce5dda467d7_2972x2816.png" width="1456" height="1380" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/201fa747-f0f7-40b8-915b-7ce5dda467d7_2972x2816.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1380,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:452392,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!VNJW!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F201fa747-f0f7-40b8-915b-7ce5dda467d7_2972x2816.png 424w, https://substackcdn.com/image/fetch/$s_!VNJW!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F201fa747-f0f7-40b8-915b-7ce5dda467d7_2972x2816.png 848w, https://substackcdn.com/image/fetch/$s_!VNJW!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F201fa747-f0f7-40b8-915b-7ce5dda467d7_2972x2816.png 1272w, https://substackcdn.com/image/fetch/$s_!VNJW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F201fa747-f0f7-40b8-915b-7ce5dda467d7_2972x2816.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Iar &#238;ncep&#226;nd cu versiunea 7.4, putem configura un num&#259;r de instan&#539;e (workers) care s&#259; fie lansate individual folosind variabila <code>PHP_CLI_SERVER_WORKERS</code>. Astfel putem testa cu cereri concurente c&#259;tre acela&#537;i script. &#206;n cazul &#238;n care avem un singur worker, cererile vor a&#537;tepta una dup&#259; cealalt&#259;. A&#537;adar e bine s&#259; configur&#259;m cel pu&#539;in 2 workeri dac&#259; pe l&#226;ng&#259; scriptul de php mai servim &#537;i alte resurse &#238;n pagin&#259; cum ar fi fi&#537;iere css, javascript sau imagini:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Z1Cu!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5441bcb8-d7e1-4192-83b1-695f7462bea3_2972x484.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Z1Cu!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5441bcb8-d7e1-4192-83b1-695f7462bea3_2972x484.png 424w, https://substackcdn.com/image/fetch/$s_!Z1Cu!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5441bcb8-d7e1-4192-83b1-695f7462bea3_2972x484.png 848w, https://substackcdn.com/image/fetch/$s_!Z1Cu!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5441bcb8-d7e1-4192-83b1-695f7462bea3_2972x484.png 1272w, https://substackcdn.com/image/fetch/$s_!Z1Cu!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5441bcb8-d7e1-4192-83b1-695f7462bea3_2972x484.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Z1Cu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5441bcb8-d7e1-4192-83b1-695f7462bea3_2972x484.png" width="1456" height="237" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5441bcb8-d7e1-4192-83b1-695f7462bea3_2972x484.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:237,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:79628,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Z1Cu!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5441bcb8-d7e1-4192-83b1-695f7462bea3_2972x484.png 424w, https://substackcdn.com/image/fetch/$s_!Z1Cu!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5441bcb8-d7e1-4192-83b1-695f7462bea3_2972x484.png 848w, https://substackcdn.com/image/fetch/$s_!Z1Cu!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5441bcb8-d7e1-4192-83b1-695f7462bea3_2972x484.png 1272w, https://substackcdn.com/image/fetch/$s_!Z1Cu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5441bcb8-d7e1-4192-83b1-695f7462bea3_2972x484.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://stack.moustacios.dev/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Salut, &#238;&#539;i mul&#539;umesc c&#259; te-ai oprit pe blog. Dac&#259; e&#537;ti pasionat de tehnologie &#537;i programare, te invit s&#259; te &#238;nscrii la newsletter:</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><div><hr></div><p><em>Referin&#539;e</em></p><ul><li><p><a href="https://www.php.net/manual/en/features.commandline.webserver.php#features.commandline.webserver">[EN] Built-in web server</a></p></li><li><p><a href="https://codingshower.com/serve-local-directory-with-php-web-server/">[EN] Run a PHP Web Server to Quickly Serve Local Files</a></p></li></ul><p></p>]]></content:encoded></item><item><title><![CDATA[Consola din navigator. Avertisment!]]></title><description><![CDATA[C&#226;nd deschizi consola din navigator, &#537;i hopa!]]></description><link>https://stack.moustacios.dev/p/consola-din-navigator-avertisment</link><guid isPermaLink="false">https://stack.moustacios.dev/p/consola-din-navigator-avertisment</guid><dc:creator><![CDATA[Teo cel Mustăcios]]></dc:creator><pubDate>Wed, 14 Feb 2024 05:49:09 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!8DxT!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fadd3f07d-0bc3-4606-8e6f-5b25fbaebf43_2023x534.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!8DxT!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fadd3f07d-0bc3-4606-8e6f-5b25fbaebf43_2023x534.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!8DxT!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fadd3f07d-0bc3-4606-8e6f-5b25fbaebf43_2023x534.png 424w, https://substackcdn.com/image/fetch/$s_!8DxT!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fadd3f07d-0bc3-4606-8e6f-5b25fbaebf43_2023x534.png 848w, https://substackcdn.com/image/fetch/$s_!8DxT!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fadd3f07d-0bc3-4606-8e6f-5b25fbaebf43_2023x534.png 1272w, https://substackcdn.com/image/fetch/$s_!8DxT!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fadd3f07d-0bc3-4606-8e6f-5b25fbaebf43_2023x534.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!8DxT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fadd3f07d-0bc3-4606-8e6f-5b25fbaebf43_2023x534.png" width="1456" height="384" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/add3f07d-0bc3-4606-8e6f-5b25fbaebf43_2023x534.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:384,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:89226,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!8DxT!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fadd3f07d-0bc3-4606-8e6f-5b25fbaebf43_2023x534.png 424w, https://substackcdn.com/image/fetch/$s_!8DxT!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fadd3f07d-0bc3-4606-8e6f-5b25fbaebf43_2023x534.png 848w, https://substackcdn.com/image/fetch/$s_!8DxT!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fadd3f07d-0bc3-4606-8e6f-5b25fbaebf43_2023x534.png 1272w, https://substackcdn.com/image/fetch/$s_!8DxT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fadd3f07d-0bc3-4606-8e6f-5b25fbaebf43_2023x534.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Dac&#259; sunte&#539;i dezvoltatori web, a&#539;i folosit cu siguran&#539;&#259; consola din Chrome sau din alte navigatoare pentru a depana codul Javascript sau integr&#259;ri cu serviciile ter&#539;e. Depanarea cu ajutorul consolei este o activitate banal&#259; pentru un programator. </p><h3>Boo boo!</h3><p>&#206;ns&#259; pentru cei care nu sunt programatori, deschiderea consolei pe anumite saituri foarte populare, &#238;i poate speria. Este consola chiar periculoas&#259;!? &#536;i mai bine s&#259; te fere&#537;ti de ea?</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!uqfP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6aebd892-99f6-4453-bacc-2ad8dc86f474_793x1008.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!uqfP!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6aebd892-99f6-4453-bacc-2ad8dc86f474_793x1008.png 424w, https://substackcdn.com/image/fetch/$s_!uqfP!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6aebd892-99f6-4453-bacc-2ad8dc86f474_793x1008.png 848w, https://substackcdn.com/image/fetch/$s_!uqfP!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6aebd892-99f6-4453-bacc-2ad8dc86f474_793x1008.png 1272w, https://substackcdn.com/image/fetch/$s_!uqfP!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6aebd892-99f6-4453-bacc-2ad8dc86f474_793x1008.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!uqfP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6aebd892-99f6-4453-bacc-2ad8dc86f474_793x1008.png" width="200" height="254.22446406052964" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6aebd892-99f6-4453-bacc-2ad8dc86f474_793x1008.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1008,&quot;width&quot;:793,&quot;resizeWidth&quot;:200,&quot;bytes&quot;:839851,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!uqfP!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6aebd892-99f6-4453-bacc-2ad8dc86f474_793x1008.png 424w, https://substackcdn.com/image/fetch/$s_!uqfP!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6aebd892-99f6-4453-bacc-2ad8dc86f474_793x1008.png 848w, https://substackcdn.com/image/fetch/$s_!uqfP!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6aebd892-99f6-4453-bacc-2ad8dc86f474_793x1008.png 1272w, https://substackcdn.com/image/fetch/$s_!uqfP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6aebd892-99f6-4453-bacc-2ad8dc86f474_793x1008.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Ei, nu chiar. Consola este un utilitar pentru depanarea paginilor web, &#537;i &#238;n special al codului Javascript, care faciliteaz&#259; componentele interactive de pe un sait web. &#206;n acest scop, consola are acces la toate informa&#539;iile pe care le transmi&#539;i unui sait, inclusiv cookie-uri, stocarea local&#259; sau istoric. Desigur &#537;i tu ca utilizator al aplica&#539;iei de browser (navigator) ai access la toate aceste informa&#539;ii fiind stocate la tine pe calculator. </p><p>Dar fiind un utilitar pentru depanare consola, de asemenea permite transmiterea acestor informa&#539;ii c&#259;tre alte saituri. Cookies &#537;i localStorage sunt date private, care pot fi folosite pentru clonarea sesiunii unui utilizator - similar cu opera&#539;iunea de clonare a unui card bancar. &#536;i cum v&#259; pute&#539;i g&#226;ndi, are fi p&#259;cat ca aceste informa&#539;ii s&#259; ajung&#259; &#238;n posesia unor persoane r&#259;u-inten&#539;ionate. </p><p>De aceea avertismentul asta v&#259; &#537;i spune: </p><blockquote><p><code>Aceasta este o func&#355;ie de browser destinat&#259; dezvoltatorilor. Dac&#259; cineva &#355;i-a spus s&#259; copiezi ceva aici pentru a activa o alt&#259; func&#355;ie Facebook sau pentru a &#8222;sparge&#8221; contul cuiva, este o &#238;n&#351;el&#259;torie &#351;i &#238;i vei oferi acces la contul t&#259;u de Facebook.</code></p></blockquote><p>Cu alte cuvinte, dac&#259; nu ave&#539;i de f&#259;cut depanare, fie c&#259; sunte&#539;i dezvoltator sau nu, &#537;i cineva v&#259; ofer&#259; indica&#539;ii s&#259; deschide&#539;i consola s&#259; s&#259; copia&#539;i ceva coduri acolo, este cel mai probabil o &#238;n&#537;el&#259;torie, oric&#226;t de prietenoas&#259; ar putea p&#259;rea persoana respectiv&#259;. Facebook &#537;i alte platforme populare se confrunt&#259; zilnic cu mii de astfel de &#238;ncerc&#259;ri de &#8221;furt a creden&#539;ielelor&#8221; sau credential theft cum sunt denumite.</p><h3>Ce face un programator, de obicei &#238;n consol&#259;</h3><p>Cea mai frecvent&#259; activitate, unde consola vine &#238;n ajutor este depanarea erorilor, rezultate prin rularea diverselor scripturi:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Do6l!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75298480-2ec5-42b9-883a-5f9b2e7a5d59_1348x510.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Do6l!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75298480-2ec5-42b9-883a-5f9b2e7a5d59_1348x510.png 424w, https://substackcdn.com/image/fetch/$s_!Do6l!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75298480-2ec5-42b9-883a-5f9b2e7a5d59_1348x510.png 848w, https://substackcdn.com/image/fetch/$s_!Do6l!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75298480-2ec5-42b9-883a-5f9b2e7a5d59_1348x510.png 1272w, https://substackcdn.com/image/fetch/$s_!Do6l!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75298480-2ec5-42b9-883a-5f9b2e7a5d59_1348x510.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Do6l!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75298480-2ec5-42b9-883a-5f9b2e7a5d59_1348x510.png" width="1348" height="510" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/75298480-2ec5-42b9-883a-5f9b2e7a5d59_1348x510.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:510,&quot;width&quot;:1348,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:100120,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Do6l!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75298480-2ec5-42b9-883a-5f9b2e7a5d59_1348x510.png 424w, https://substackcdn.com/image/fetch/$s_!Do6l!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75298480-2ec5-42b9-883a-5f9b2e7a5d59_1348x510.png 848w, https://substackcdn.com/image/fetch/$s_!Do6l!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75298480-2ec5-42b9-883a-5f9b2e7a5d59_1348x510.png 1272w, https://substackcdn.com/image/fetch/$s_!Do6l!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75298480-2ec5-42b9-883a-5f9b2e7a5d59_1348x510.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Erori din consol&#259;</figcaption></figure></div><p>De asemenea unele scripturi, care colecteaz&#259; statistici sau metrici de performan&#539;&#259; nu au un efect vizibil pe pagin&#259; &#537;i atunci singura indica&#539;ie c&#259; au rulat se vede doar prin mesaje de informa&#539;ie &#238;n consol&#259;.</p><p>O alt&#259; ac&#539;iune frecvent&#259;, este rularea de cod Javascript - pentru a depana direct func&#539;ii sau obiecte specifice scripturilor. &#206;ns&#259;, fiind in instrument destinat dezvoltatorilor, consola nu are limit&#259;ri, sau sandboxing, &#537;i poate rula orice cod Javascript:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!XzPK!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff99bd21-46ac-4dc9-b569-04dfa5f491f6_2348x1061.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!XzPK!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff99bd21-46ac-4dc9-b569-04dfa5f491f6_2348x1061.png 424w, https://substackcdn.com/image/fetch/$s_!XzPK!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff99bd21-46ac-4dc9-b569-04dfa5f491f6_2348x1061.png 848w, https://substackcdn.com/image/fetch/$s_!XzPK!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff99bd21-46ac-4dc9-b569-04dfa5f491f6_2348x1061.png 1272w, https://substackcdn.com/image/fetch/$s_!XzPK!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff99bd21-46ac-4dc9-b569-04dfa5f491f6_2348x1061.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!XzPK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff99bd21-46ac-4dc9-b569-04dfa5f491f6_2348x1061.png" width="1456" height="658" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ff99bd21-46ac-4dc9-b569-04dfa5f491f6_2348x1061.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:658,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:203637,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!XzPK!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff99bd21-46ac-4dc9-b569-04dfa5f491f6_2348x1061.png 424w, https://substackcdn.com/image/fetch/$s_!XzPK!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff99bd21-46ac-4dc9-b569-04dfa5f491f6_2348x1061.png 848w, https://substackcdn.com/image/fetch/$s_!XzPK!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff99bd21-46ac-4dc9-b569-04dfa5f491f6_2348x1061.png 1272w, https://substackcdn.com/image/fetch/$s_!XzPK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff99bd21-46ac-4dc9-b569-04dfa5f491f6_2348x1061.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>A&#537;adar putem &#238;nc&#259;rca scripturi din surse externe, rula func&#539;ii de care citesc datele din storage-ul local sau vedea con&#539;inutul modulelor cookie. Detalii importante pentru un programator care depaneaz&#259;, dar la fel de pre&#539;ioase pentru un hacker care dore&#537;te s&#259; ob&#539;in&#259; controlul asupra unui cont de utilizator.</p><p>A&#537;adar consola este ca un cu&#539;it de p&#226;ine, indispensabil la mas&#259;, dar din neaten&#539;ie, te po&#539;i &#537;i t&#259;ia. </p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://stack.moustacios.dev/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">&#206;nscrie-te la newsletter-ul nostru:</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><div><hr></div><p>Referin&#539;e:</p><ul><li><p><a href="https://hurricanelabs.com/blog/console-wars-part-1-hacks-for-hackers/">[EN] Console Wars Part 1: Hacks for Hackers</a></p></li><li><p><a href="https://opensource.com/article/17/8/using-javascript-hack-web">[EN] Using JavaScript to hack the web</a></p></li></ul>]]></content:encoded></item><item><title><![CDATA[Strategii pentru autentificarea pe un REST API: Basic Auth și API Keys]]></title><description><![CDATA[Dou&#259; scheme simple de autentificare pentru API-uri]]></description><link>https://stack.moustacios.dev/p/strategii-pentru-autentificarea-pe</link><guid isPermaLink="false">https://stack.moustacios.dev/p/strategii-pentru-autentificarea-pe</guid><dc:creator><![CDATA[Teo cel Mustăcios]]></dc:creator><pubDate>Tue, 06 Feb 2024 05:07:56 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!YGXO!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27fb35e1-f378-42f2-9758-e39273ad12c7_3124x1681.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!YGXO!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27fb35e1-f378-42f2-9758-e39273ad12c7_3124x1681.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!YGXO!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27fb35e1-f378-42f2-9758-e39273ad12c7_3124x1681.png 424w, https://substackcdn.com/image/fetch/$s_!YGXO!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27fb35e1-f378-42f2-9758-e39273ad12c7_3124x1681.png 848w, https://substackcdn.com/image/fetch/$s_!YGXO!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27fb35e1-f378-42f2-9758-e39273ad12c7_3124x1681.png 1272w, https://substackcdn.com/image/fetch/$s_!YGXO!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27fb35e1-f378-42f2-9758-e39273ad12c7_3124x1681.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!YGXO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27fb35e1-f378-42f2-9758-e39273ad12c7_3124x1681.png" width="1456" height="783" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/27fb35e1-f378-42f2-9758-e39273ad12c7_3124x1681.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:783,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:656983,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!YGXO!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27fb35e1-f378-42f2-9758-e39273ad12c7_3124x1681.png 424w, https://substackcdn.com/image/fetch/$s_!YGXO!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27fb35e1-f378-42f2-9758-e39273ad12c7_3124x1681.png 848w, https://substackcdn.com/image/fetch/$s_!YGXO!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27fb35e1-f378-42f2-9758-e39273ad12c7_3124x1681.png 1272w, https://substackcdn.com/image/fetch/$s_!YGXO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27fb35e1-f378-42f2-9758-e39273ad12c7_3124x1681.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Atunci c&#226;nd proiect&#259;m un API, una dintre cele mai importante decizii este metoda de autentificare pentru clien&#539;i. Fie aplica&#539;ii interne - mobile sau desktop, sau dezvoltate de un public mai larg pentru API-uri deschise. </p><p>&#206;n ultimul deceniu, API-urile REST au devenit o abordare arhitectural&#259; de facto pentru platformele moderne de aplica&#539;ii web &#537;i mobile. Prin separarea nivelului de date &#537;i cel de prezentare, au permis sistemelor s&#259; scaleze la ordinul de milioane de utilizatori. &#206;ns&#259; odat&#259; cu cre&#537;terea, distribu&#539;ia &#537;i accesul la date a ajutat la stabilirea unor standarde, cu beneficii &#537;i limit&#259;ri de securitate bine cunoscute. &#206;n acest articol voi discuta despre dou&#259; dintre acestea: </p><h3>Basic HTTP authentication</h3><p>A&#537;a cum &#238;i spune numele aceast&#259; metod&#259; de autentificare este una care folose&#537;te un mecanism foarte simplu: user &#537;i parol&#259; trimise prin header-ul HTTP <em>Authorization</em>. Aceast&#259; metod&#259; are avantajul de a fi foarte simplu de implementat, at&#226;t pe partea de server c&#226;t &#537;i pe cea de client prin ad&#259;ugarea header-ului &#238;n cererile HTTP:</p><pre><code>X-Client-Version: 1.34
Authorization: Basic YmFzaWMtYXV0aA==</code></pre><p>Din p&#259;cate aceast&#259; metod&#259; prezint&#259; c&#226;teva dezavantaje, &#537;i a&#537; dori s&#259; &#238;ncep cu cele de securitate: utilizatorul &#537;i parola sunt trimise decriptate. Mai exact transpuse &#238;n base64. De aceea aceast&#259; schem&#259; de autentificare este viabil&#259; doar sub HTTPS -  protocol care cripteaz&#259; datele &#238;n tranzit. O alt&#259; inconvenien&#539;&#259; a acestei scheme este faptul c&#259; pentru fiecare utilizator este nevoie s&#259; creezi o parol&#259;, &#537;i deci dac&#259; ai trei aplica&#539;ii pentru aceea&#537;i organiza&#539;ie care au nevoie de acces la API, va fi nevoie s&#259; generezi trei utilizatori diferi&#539;i. </p><p>Cu toate acestea, &#539;in&#226;nd cont de u&#537;urin&#539;a &#238;n implementare &#537;i de faptul c&#259; poate fi gestionat&#259; pe server, este o strategia viabil&#259; c&#226;nd este combinat&#259; cu alte nivele de securitate: HTTPS &#537;i access prin VPN, iar num&#259;rul de utilizatori ai API-ului este foarte mic, p&#226;n&#259; la 100 de clien&#539;i.</p><h3>Chei (API keys)</h3><p>Cheile de acces, sunt o variant&#259; mai flexibil&#259; &#537;i prezint&#259; dou&#259; avantaje fa&#539;&#259; de Basic auth: </p><ul><li><p>pot fi generate &#537;i revocate f&#259;r&#259; a fi necesar s&#259; gener&#259;m un utilizator nou </p></li><li><p>pot fi criptate de client, &#537;i deci trimise criptate</p></li></ul><p>Implementarea &#537;i gestionarea acestei strategii necesit&#259; cod pentru validarea cheilor, sau se poate folosi o solu&#539;ie de API Gateway. Pentru clien&#539;i autentificarea este la fel de simpl&#259; ca &#537;i &#238;n cazul basic auth:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!HxfH!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F477e05b7-9444-4134-b872-be65170aeafd_2972x776.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!HxfH!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F477e05b7-9444-4134-b872-be65170aeafd_2972x776.png 424w, https://substackcdn.com/image/fetch/$s_!HxfH!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F477e05b7-9444-4134-b872-be65170aeafd_2972x776.png 848w, https://substackcdn.com/image/fetch/$s_!HxfH!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F477e05b7-9444-4134-b872-be65170aeafd_2972x776.png 1272w, https://substackcdn.com/image/fetch/$s_!HxfH!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F477e05b7-9444-4134-b872-be65170aeafd_2972x776.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!HxfH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F477e05b7-9444-4134-b872-be65170aeafd_2972x776.png" width="1456" height="380" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/477e05b7-9444-4134-b872-be65170aeafd_2972x776.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:380,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:116812,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!HxfH!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F477e05b7-9444-4134-b872-be65170aeafd_2972x776.png 424w, https://substackcdn.com/image/fetch/$s_!HxfH!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F477e05b7-9444-4134-b872-be65170aeafd_2972x776.png 848w, https://substackcdn.com/image/fetch/$s_!HxfH!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F477e05b7-9444-4134-b872-be65170aeafd_2972x776.png 1272w, https://substackcdn.com/image/fetch/$s_!HxfH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F477e05b7-9444-4134-b872-be65170aeafd_2972x776.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Desigur, &#238;n cazul &#238;n care este necesar&#259; criptarea creden&#539;ialelor se mai adaug&#259; &#537;i un pas de criptare:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!TIkj!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e1ad695-2adf-4b96-b60c-395dae605f46_2972x872.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!TIkj!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e1ad695-2adf-4b96-b60c-395dae605f46_2972x872.png 424w, https://substackcdn.com/image/fetch/$s_!TIkj!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e1ad695-2adf-4b96-b60c-395dae605f46_2972x872.png 848w, https://substackcdn.com/image/fetch/$s_!TIkj!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e1ad695-2adf-4b96-b60c-395dae605f46_2972x872.png 1272w, https://substackcdn.com/image/fetch/$s_!TIkj!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e1ad695-2adf-4b96-b60c-395dae605f46_2972x872.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!TIkj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e1ad695-2adf-4b96-b60c-395dae605f46_2972x872.png" width="1456" height="427" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1e1ad695-2adf-4b96-b60c-395dae605f46_2972x872.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:427,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:141935,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!TIkj!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e1ad695-2adf-4b96-b60c-395dae605f46_2972x872.png 424w, https://substackcdn.com/image/fetch/$s_!TIkj!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e1ad695-2adf-4b96-b60c-395dae605f46_2972x872.png 848w, https://substackcdn.com/image/fetch/$s_!TIkj!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e1ad695-2adf-4b96-b60c-395dae605f46_2972x872.png 1272w, https://substackcdn.com/image/fetch/$s_!TIkj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e1ad695-2adf-4b96-b60c-395dae605f46_2972x872.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>La fel ca &#238;n cazul basic auth, creden&#539;ialele pot fi interceptate dac&#259; nu sunt criptate, &#537;i de aceea &#537;i autentificarea prin cheie API este considerat&#259; sigur&#259; doar dac&#259; se comunic&#259; prin HTTPS.</p><p>Printre alte limit&#259;ri ale acestor dou&#259; strategii se num&#259;r&#259; &#537;i faptul c&#259; prin design nu suport&#259; extinderea cu alte mecanisme de autentificare cum ar fi Multi-factor (MFA).</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://stack.moustacios.dev/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">&#206;nscrie-te la newsletter-ul Moustacios.dev: </p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>Voi reveni &#238;ntr-un articol viitor cu alte dou&#259; strategii de autentificare, respectiv HMAC &#537;i OAuth. Acestea folosesc chei de criptare &#537;i ofer&#259; nivele superioare de securitate. </p><div><hr></div><p>Referin&#539;e:</p><ul><li><p><a href="https://www.ibm.com/docs/en/cics-ts/5.4?topic=concepts-http-basic-authentication">[EN] HTTP basic authentication</a></p></li><li><p><a href="https://coding-boot-camp.github.io/full-stack/apis/how-to-use-api-keys">[EN] How to Use API Keys</a></p></li></ul><div><hr></div><p><em>Atribu&#539;ii:</em></p><ul><li><p>Imaginea articolului a fost desc&#259;rcat&#259; de pe <a href="https://www.freepik.com/free-vector/gradient-api-illustration_25561272.htm#query=computer%20api&amp;position=9&amp;from_view=search&amp;track=ais&amp;uuid=051f87e6-2356-4209-bea1-0c3945fcd2be">Freepik</a>.</p></li></ul>]]></content:encoded></item><item><title><![CDATA[Comenzi linux pentru depanarea rețelei: ip și nmcli]]></title><description><![CDATA[Depanarea re&#539;elei pe sistemele linux, cu unelte din linia de comand&#259;]]></description><link>https://stack.moustacios.dev/p/comenzi-linux-pentru-depanarea-retelei</link><guid isPermaLink="false">https://stack.moustacios.dev/p/comenzi-linux-pentru-depanarea-retelei</guid><dc:creator><![CDATA[Teo cel Mustăcios]]></dc:creator><pubDate>Tue, 30 Jan 2024 06:05:34 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!_7tB!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93882b7d-0cbf-45a7-b394-2a238451a027_2688x1536.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!_7tB!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93882b7d-0cbf-45a7-b394-2a238451a027_2688x1536.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!_7tB!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93882b7d-0cbf-45a7-b394-2a238451a027_2688x1536.jpeg 424w, https://substackcdn.com/image/fetch/$s_!_7tB!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93882b7d-0cbf-45a7-b394-2a238451a027_2688x1536.jpeg 848w, https://substackcdn.com/image/fetch/$s_!_7tB!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93882b7d-0cbf-45a7-b394-2a238451a027_2688x1536.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!_7tB!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93882b7d-0cbf-45a7-b394-2a238451a027_2688x1536.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!_7tB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93882b7d-0cbf-45a7-b394-2a238451a027_2688x1536.jpeg" width="1456" height="832" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/93882b7d-0cbf-45a7-b394-2a238451a027_2688x1536.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:832,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:458249,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!_7tB!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93882b7d-0cbf-45a7-b394-2a238451a027_2688x1536.jpeg 424w, https://substackcdn.com/image/fetch/$s_!_7tB!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93882b7d-0cbf-45a7-b394-2a238451a027_2688x1536.jpeg 848w, https://substackcdn.com/image/fetch/$s_!_7tB!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93882b7d-0cbf-45a7-b394-2a238451a027_2688x1536.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!_7tB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F93882b7d-0cbf-45a7-b394-2a238451a027_2688x1536.jpeg 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Configurarea &#537;i depanarea re&#539;elei sunt sarcini cruciale pe care un administrator de sistem le va efectua &#238;n mod frecvent. &#536;i desigur, deseori vor ap&#259;rea probleme de conectivitate &#238;ntre ma&#537;ini. V&#259; invit s&#259; &#238;nv&#259;&#539;&#259;m despre dou&#259; comenzi pentru linux, care ne ajut&#259; s&#259; depan&#259;m conectivitatea cu internetul sau cu alte ma&#537;ini din re&#539;ea.</p><h3>IP </h3><p>Comanda <code>ip </code>este una cu multe func&#539;ionalit&#259;&#539;i care ne ajut&#259; s&#259; afl&#259;m informa&#539;ii &#537;i s&#259; modific&#259;m configura&#539;ii pentru diverse obiecte &#537;i interfe&#539;e de re&#539;ea identificate de sistemul linux, incluz&#226;nd adrese de IP, rute sau tabele ARP. Sintaxa comenzii este urm&#259;toarea:</p><pre><code>ip &lt;OBIECT&gt; [COMAND&#258;]</code></pre><p>De exemplu pentru a afi&#537;a statusul conexiunii pe toate dispozitivele de re&#539;ea, rul&#259;m <code>ip link show </code>:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!85ad!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0126dbec-4cf8-4027-8e16-7c5074c5cd70_2972x1064.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!85ad!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0126dbec-4cf8-4027-8e16-7c5074c5cd70_2972x1064.png 424w, https://substackcdn.com/image/fetch/$s_!85ad!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0126dbec-4cf8-4027-8e16-7c5074c5cd70_2972x1064.png 848w, https://substackcdn.com/image/fetch/$s_!85ad!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0126dbec-4cf8-4027-8e16-7c5074c5cd70_2972x1064.png 1272w, https://substackcdn.com/image/fetch/$s_!85ad!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0126dbec-4cf8-4027-8e16-7c5074c5cd70_2972x1064.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!85ad!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0126dbec-4cf8-4027-8e16-7c5074c5cd70_2972x1064.png" width="1456" height="521" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0126dbec-4cf8-4027-8e16-7c5074c5cd70_2972x1064.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:521,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:258512,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!85ad!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0126dbec-4cf8-4027-8e16-7c5074c5cd70_2972x1064.png 424w, https://substackcdn.com/image/fetch/$s_!85ad!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0126dbec-4cf8-4027-8e16-7c5074c5cd70_2972x1064.png 848w, https://substackcdn.com/image/fetch/$s_!85ad!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0126dbec-4cf8-4027-8e16-7c5074c5cd70_2972x1064.png 1272w, https://substackcdn.com/image/fetch/$s_!85ad!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0126dbec-4cf8-4027-8e16-7c5074c5cd70_2972x1064.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Comanda ip poate configura &#537;i afi&#537;a detalii despre urm&#259;toarele obiecte:</p><ul><li><p><code>link </code>controleaz&#259; statusul network device-urilor (din linux)</p></li><li><p><code>address </code>pentru a manipula adresele IP ale device-urilor</p></li><li><p><code>route</code> pentru intr&#259;rile &#238;n tabelul de rutare (routing table)</p></li><li><p><code>neighbor</code> pentru intr&#259;rile &#238;n tabelul ARP</p></li></ul><p>C&#226;teva exemple:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!oIBv!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d9c0582-3f43-4880-a7c7-fadd4f0b7ac7_2972x1456.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!oIBv!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d9c0582-3f43-4880-a7c7-fadd4f0b7ac7_2972x1456.png 424w, https://substackcdn.com/image/fetch/$s_!oIBv!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d9c0582-3f43-4880-a7c7-fadd4f0b7ac7_2972x1456.png 848w, https://substackcdn.com/image/fetch/$s_!oIBv!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d9c0582-3f43-4880-a7c7-fadd4f0b7ac7_2972x1456.png 1272w, https://substackcdn.com/image/fetch/$s_!oIBv!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d9c0582-3f43-4880-a7c7-fadd4f0b7ac7_2972x1456.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!oIBv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d9c0582-3f43-4880-a7c7-fadd4f0b7ac7_2972x1456.png" width="1456" height="713" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1d9c0582-3f43-4880-a7c7-fadd4f0b7ac7_2972x1456.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:713,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:348656,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!oIBv!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d9c0582-3f43-4880-a7c7-fadd4f0b7ac7_2972x1456.png 424w, https://substackcdn.com/image/fetch/$s_!oIBv!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d9c0582-3f43-4880-a7c7-fadd4f0b7ac7_2972x1456.png 848w, https://substackcdn.com/image/fetch/$s_!oIBv!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d9c0582-3f43-4880-a7c7-fadd4f0b7ac7_2972x1456.png 1272w, https://substackcdn.com/image/fetch/$s_!oIBv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1d9c0582-3f43-4880-a7c7-fadd4f0b7ac7_2972x1456.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Yatb!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa67c199f-cf0e-4cde-861d-d46700649fa2_2972x1456.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Yatb!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa67c199f-cf0e-4cde-861d-d46700649fa2_2972x1456.png 424w, https://substackcdn.com/image/fetch/$s_!Yatb!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa67c199f-cf0e-4cde-861d-d46700649fa2_2972x1456.png 848w, https://substackcdn.com/image/fetch/$s_!Yatb!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa67c199f-cf0e-4cde-861d-d46700649fa2_2972x1456.png 1272w, https://substackcdn.com/image/fetch/$s_!Yatb!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa67c199f-cf0e-4cde-861d-d46700649fa2_2972x1456.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Yatb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa67c199f-cf0e-4cde-861d-d46700649fa2_2972x1456.png" width="1456" height="713" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a67c199f-cf0e-4cde-861d-d46700649fa2_2972x1456.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:713,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:383263,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Yatb!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa67c199f-cf0e-4cde-861d-d46700649fa2_2972x1456.png 424w, https://substackcdn.com/image/fetch/$s_!Yatb!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa67c199f-cf0e-4cde-861d-d46700649fa2_2972x1456.png 848w, https://substackcdn.com/image/fetch/$s_!Yatb!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa67c199f-cf0e-4cde-861d-d46700649fa2_2972x1456.png 1272w, https://substackcdn.com/image/fetch/$s_!Yatb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa67c199f-cf0e-4cde-861d-d46700649fa2_2972x1456.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!oBRJ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1201c9e9-900e-47ab-9111-2eb39b9309fb_2972x1356.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!oBRJ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1201c9e9-900e-47ab-9111-2eb39b9309fb_2972x1356.png 424w, https://substackcdn.com/image/fetch/$s_!oBRJ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1201c9e9-900e-47ab-9111-2eb39b9309fb_2972x1356.png 848w, https://substackcdn.com/image/fetch/$s_!oBRJ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1201c9e9-900e-47ab-9111-2eb39b9309fb_2972x1356.png 1272w, https://substackcdn.com/image/fetch/$s_!oBRJ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1201c9e9-900e-47ab-9111-2eb39b9309fb_2972x1356.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!oBRJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1201c9e9-900e-47ab-9111-2eb39b9309fb_2972x1356.png" width="1456" height="664" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1201c9e9-900e-47ab-9111-2eb39b9309fb_2972x1356.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:664,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:292814,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!oBRJ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1201c9e9-900e-47ab-9111-2eb39b9309fb_2972x1356.png 424w, https://substackcdn.com/image/fetch/$s_!oBRJ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1201c9e9-900e-47ab-9111-2eb39b9309fb_2972x1356.png 848w, https://substackcdn.com/image/fetch/$s_!oBRJ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1201c9e9-900e-47ab-9111-2eb39b9309fb_2972x1356.png 1272w, https://substackcdn.com/image/fetch/$s_!oBRJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1201c9e9-900e-47ab-9111-2eb39b9309fb_2972x1356.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Comanda IP este una dintre cele mai la &#238;ndem&#226;n&#259;, foarte util&#259; pentru depanare. Dar pentru configurare, ofer&#259; o interfa&#539;&#259; de access la un nivel inferior, fa&#539;&#259; de alte unelte. Pentru a configura o re&#539;ea, avem la dispozi&#539;ie o unealt&#259; mai avansat&#259; &#537;i anume nmcli:</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://stack.moustacios.dev/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Dac&#259; e&#537;ti pasionat de linux, cloud sau networking te invit s&#259; te &#238;nscrii ;) </p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><h3>nmcli</h3><p>Network Manager este un proces (daemon) disponibil pe majoritatea distribu&#539;iilor de linux, iar scopul s&#259;u este de a oferi o interfa&#539;&#259; de nivel superior pentru a face configurarea re&#539;elei mai facil&#259; &#537;i mai u&#537;or de automatizat. </p><p>Cel mai probabil, dac&#259; folose&#537;ti un desktop linux, ai interac&#539;ionat deja cu interfa&#539;a grafic&#259; a Network Manager (GUI), &#238;ns&#259; pentru servere, vom folosi clientul din linia de comand&#259;, respectiv nmcli. Sintaxa este urm&#259;toarea:</p><pre><code>nmcli &lt;OBJECT&gt; [COMMAND] [ARGUMENTS]</code></pre><p>Pentru parametrul <code>object </code>putem folosi dintre urm&#259;toarele:</p><ul><li><p><code>general</code> - afi&#537;eaz&#259; mesaj de status &#537;i permisiunile</p></li><li><p><code>networking</code> - afi&#537;eaz&#259;, activeaz&#259; &#537;i dezactiveaz&#259; re&#539;eaua</p></li><li><p><code>radio</code> - afi&#537;eaz&#259;, activeaz&#259; &#537;i dezactiveaz&#259; WiFi &#537;i WWAN</p></li><li><p><code>device</code> - afi&#537;eaz&#259; sau dezactiveaz&#259; device-urile de re&#539;ea</p></li><li><p><code>connection</code> - pentru configurarea pofilelor Network Manager</p></li></ul><p>Acest utilitar ofer&#259; foarte multe op&#539;iuni, imposibil de acoperit &#238;ntr-un blog. Pentru asta v&#259; recomand s&#259; consulta&#539;i man pages: <code>man nmcli-examples</code></p><p>La ce putem folosi nmcli:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!WUK3!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f9fc28a-8ca0-4d79-8246-e76ed2951b5f_2972x872.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!WUK3!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f9fc28a-8ca0-4d79-8246-e76ed2951b5f_2972x872.png 424w, https://substackcdn.com/image/fetch/$s_!WUK3!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f9fc28a-8ca0-4d79-8246-e76ed2951b5f_2972x872.png 848w, https://substackcdn.com/image/fetch/$s_!WUK3!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f9fc28a-8ca0-4d79-8246-e76ed2951b5f_2972x872.png 1272w, https://substackcdn.com/image/fetch/$s_!WUK3!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f9fc28a-8ca0-4d79-8246-e76ed2951b5f_2972x872.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!WUK3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f9fc28a-8ca0-4d79-8246-e76ed2951b5f_2972x872.png" width="1456" height="427" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7f9fc28a-8ca0-4d79-8246-e76ed2951b5f_2972x872.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:427,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:163244,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!WUK3!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f9fc28a-8ca0-4d79-8246-e76ed2951b5f_2972x872.png 424w, https://substackcdn.com/image/fetch/$s_!WUK3!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f9fc28a-8ca0-4d79-8246-e76ed2951b5f_2972x872.png 848w, https://substackcdn.com/image/fetch/$s_!WUK3!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f9fc28a-8ca0-4d79-8246-e76ed2951b5f_2972x872.png 1272w, https://substackcdn.com/image/fetch/$s_!WUK3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f9fc28a-8ca0-4d79-8246-e76ed2951b5f_2972x872.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!lzZP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb83c7ad8-2ced-4296-b056-dd5a0d76e9ca_2972x1844.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!lzZP!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb83c7ad8-2ced-4296-b056-dd5a0d76e9ca_2972x1844.png 424w, https://substackcdn.com/image/fetch/$s_!lzZP!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb83c7ad8-2ced-4296-b056-dd5a0d76e9ca_2972x1844.png 848w, https://substackcdn.com/image/fetch/$s_!lzZP!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb83c7ad8-2ced-4296-b056-dd5a0d76e9ca_2972x1844.png 1272w, https://substackcdn.com/image/fetch/$s_!lzZP!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb83c7ad8-2ced-4296-b056-dd5a0d76e9ca_2972x1844.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!lzZP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb83c7ad8-2ced-4296-b056-dd5a0d76e9ca_2972x1844.png" width="1456" height="903" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b83c7ad8-2ced-4296-b056-dd5a0d76e9ca_2972x1844.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:903,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:429348,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!lzZP!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb83c7ad8-2ced-4296-b056-dd5a0d76e9ca_2972x1844.png 424w, https://substackcdn.com/image/fetch/$s_!lzZP!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb83c7ad8-2ced-4296-b056-dd5a0d76e9ca_2972x1844.png 848w, https://substackcdn.com/image/fetch/$s_!lzZP!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb83c7ad8-2ced-4296-b056-dd5a0d76e9ca_2972x1844.png 1272w, https://substackcdn.com/image/fetch/$s_!lzZP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb83c7ad8-2ced-4296-b056-dd5a0d76e9ca_2972x1844.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Putem edita un profil de conexiune &#537;i &#238;n mod interactiv folosind <code>nmcli connection edit [nume-conexiune]</code>. Comanda <code>set </code>ne permite s&#259; configur&#259;m parametri, <code>print </code>va afi&#537;a valorile setate, iar <code>save </code>va salva noile valori. Pentru a ie&#537;i din modul interactiv utiliz&#259;m comanda <code>quit</code>:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!_5Ij!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F92517433-4697-4622-9d6d-3911b4569c58_2972x1356.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!_5Ij!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F92517433-4697-4622-9d6d-3911b4569c58_2972x1356.png 424w, https://substackcdn.com/image/fetch/$s_!_5Ij!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F92517433-4697-4622-9d6d-3911b4569c58_2972x1356.png 848w, https://substackcdn.com/image/fetch/$s_!_5Ij!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F92517433-4697-4622-9d6d-3911b4569c58_2972x1356.png 1272w, https://substackcdn.com/image/fetch/$s_!_5Ij!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F92517433-4697-4622-9d6d-3911b4569c58_2972x1356.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!_5Ij!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F92517433-4697-4622-9d6d-3911b4569c58_2972x1356.png" width="1456" height="664" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/92517433-4697-4622-9d6d-3911b4569c58_2972x1356.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:664,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:285780,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!_5Ij!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F92517433-4697-4622-9d6d-3911b4569c58_2972x1356.png 424w, https://substackcdn.com/image/fetch/$s_!_5Ij!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F92517433-4697-4622-9d6d-3911b4569c58_2972x1356.png 848w, https://substackcdn.com/image/fetch/$s_!_5Ij!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F92517433-4697-4622-9d6d-3911b4569c58_2972x1356.png 1272w, https://substackcdn.com/image/fetch/$s_!_5Ij!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F92517433-4697-4622-9d6d-3911b4569c58_2972x1356.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>De asemenea modul interactiv beneficiaz&#259; &#537;i de completare automat&#259;, la ap&#259;sarea tastei TAB.</p><p>Acestea sunt doar dou&#259; dintre utilitarele disponibile pe linux, pentru configurarea &#537;i depanarea re&#539;elei. La acestea se adaug&#259; nslookup, ss &#537;i tracepath, dintre cele mai notabile. &#536;i desigur universalul ping.</p><div><hr></div><p>Referin&#539;e:</p><ul><li><p><a href="https://www.redhat.com/en/resources/network-automation-for-everyone-ebook">[EN] RedHat: Network Automation for Everyone</a></p></li><li><p><a href="https://devopscube.com/list-linux-networking-troubleshooting-and-commands-beginners/">[EN] 17 Best Linux Networking and Troubleshooting Commands</a></p></li></ul>]]></content:encoded></item><item><title><![CDATA[Cybermonth: despre supply chain attacks]]></title><description><![CDATA[Decembrie - luna dedicat&#259; securit&#259;&#539;ii.]]></description><link>https://stack.moustacios.dev/p/cybermonth-despre-supply-chain-attacks</link><guid isPermaLink="false">https://stack.moustacios.dev/p/cybermonth-despre-supply-chain-attacks</guid><dc:creator><![CDATA[Teo cel Mustăcios]]></dc:creator><pubDate>Thu, 14 Dec 2023 05:10:10 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/f83a88a0-4d87-4e2e-9036-9cc583a62b26_938x450.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!5LUx!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e70dfff-6858-469a-b747-d38b86f85434_500x209.gif" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!5LUx!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e70dfff-6858-469a-b747-d38b86f85434_500x209.gif 424w, https://substackcdn.com/image/fetch/$s_!5LUx!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e70dfff-6858-469a-b747-d38b86f85434_500x209.gif 848w, https://substackcdn.com/image/fetch/$s_!5LUx!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e70dfff-6858-469a-b747-d38b86f85434_500x209.gif 1272w, https://substackcdn.com/image/fetch/$s_!5LUx!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e70dfff-6858-469a-b747-d38b86f85434_500x209.gif 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!5LUx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e70dfff-6858-469a-b747-d38b86f85434_500x209.gif" width="500" height="209" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4e70dfff-6858-469a-b747-d38b86f85434_500x209.gif&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:false,&quot;imageSize&quot;:&quot;normal&quot;,&quot;height&quot;:209,&quot;width&quot;:500,&quot;resizeWidth&quot;:500,&quot;bytes&quot;:154296,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/gif&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!5LUx!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e70dfff-6858-469a-b747-d38b86f85434_500x209.gif 424w, https://substackcdn.com/image/fetch/$s_!5LUx!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e70dfff-6858-469a-b747-d38b86f85434_500x209.gif 848w, https://substackcdn.com/image/fetch/$s_!5LUx!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e70dfff-6858-469a-b747-d38b86f85434_500x209.gif 1272w, https://substackcdn.com/image/fetch/$s_!5LUx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e70dfff-6858-469a-b747-d38b86f85434_500x209.gif 1456w" sizes="100vw" fetchpriority="high"></picture><div></div></div></a></figure></div><p>Cu acest articol, deschid o serie pe tema securit&#259;&#539;ii. Le voi posta preponderent &#238;n ultima lun&#259; din an. Pentru c&#259; securitatea este foarte important&#259;, iar &#238;n decembrie &#537;tiu c&#259; lumea - inclusiv eu - face planuri pentru la anul. </p><p><strong>Supply chain attacks </strong>cum sunt denumite, sunt o serie de atacuri cibernetice care, spre deosebire de alte tipuri de atacuri - viru&#537;i, malware, ROP - nu au ca &#539;int&#259; direct&#259; software-ul. &#538;inta este dezvoltatorul &#537;i ecosistemul utilizat pentru dezvoltarea programelor.</p><h3>Pachete &#537;i libr&#259;rii third-party</h3><p>Aproape 99.99% dintre toate programele utilizate azi folosesc libr&#259;rii third-party, adic&#259; cod scris sau compilat de c&#259;tre alte persoane &#537;i organiza&#539;ii care nu sunt implicate direct &#238;n dezvoltarea respectivului program. De exemplu dac&#259; eu dezvolt o aplica&#539;ie pentru comer&#539; pe internet, voi instala o libr&#259;rie care s&#259; m&#259; ajute s&#259; criptez datele pe care le trimit c&#259;tre procesatorul de pl&#259;&#539;i, deoarece ar fi un efort prea mare s&#259; scriu acea libr&#259;rie de la zero. &#536;i desigur, de aceea foarte multe limbaje de programare ofer&#259; unelte ca managere de pachete - care te ajut&#259; s&#259; cau&#539;i, instalezi &#537;i &#238;n unele cazuri s&#259; &#537;i auditezi o libr&#259;rie extern&#259;. </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!JAtG!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F878fd18c-4cc5-4761-b47f-f57073b50b89_360x640.webp" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!JAtG!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F878fd18c-4cc5-4761-b47f-f57073b50b89_360x640.webp 424w, https://substackcdn.com/image/fetch/$s_!JAtG!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F878fd18c-4cc5-4761-b47f-f57073b50b89_360x640.webp 848w, https://substackcdn.com/image/fetch/$s_!JAtG!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F878fd18c-4cc5-4761-b47f-f57073b50b89_360x640.webp 1272w, https://substackcdn.com/image/fetch/$s_!JAtG!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F878fd18c-4cc5-4761-b47f-f57073b50b89_360x640.webp 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!JAtG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F878fd18c-4cc5-4761-b47f-f57073b50b89_360x640.webp" width="262" height="465.77777777777777" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/878fd18c-4cc5-4761-b47f-f57073b50b89_360x640.webp&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:640,&quot;width&quot;:360,&quot;resizeWidth&quot;:262,&quot;bytes&quot;:56244,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/webp&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!JAtG!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F878fd18c-4cc5-4761-b47f-f57073b50b89_360x640.webp 424w, https://substackcdn.com/image/fetch/$s_!JAtG!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F878fd18c-4cc5-4761-b47f-f57073b50b89_360x640.webp 848w, https://substackcdn.com/image/fetch/$s_!JAtG!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F878fd18c-4cc5-4761-b47f-f57073b50b89_360x640.webp 1272w, https://substackcdn.com/image/fetch/$s_!JAtG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F878fd18c-4cc5-4761-b47f-f57073b50b89_360x640.webp 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Libr&#259;rii externe folosite de aplica&#539;ia android Twitter</figcaption></figure></div><p>C&#226;nd folose&#537;ti o libr&#259;rie extern&#259;, toate datele pe care le proceseaz&#259; acea libr&#259;rie pot fi subiectul unui atac, de aceea &#238;n func&#539;ie de importan&#539;a &#537;i impactul proiectului pe care lucrezi, reputa&#539;ia &#537;i m&#259;surile de securitate pe care la adopt&#259; dezvoltatorii &#537;i organiza&#539;iile care dezvolt&#259; libr&#259;rii externe pot fi foarte importante. </p><h3>Scenarii de atac</h3><p>Cum am men&#539;ionat mai sus adoptarea unor m&#259;suri de securitate &#537;i analiz&#259; a codului sunt necesare, mai ales pentru libr&#259;riile care sunt folosite &#238;n sisteme de operare sau programe care fac tranzac&#539;ii monetare. Scenariile de atac se &#238;nscriu de obicei &#238;n patru categorii:</p><h4><em>Lipsa unei evalu&#259;ri de securitate de rutin&#259;</em></h4><p>O libr&#259;rie extern&#259; care are o vulnerabilitate. Dezvoltatorul fixeaz&#259; aceast&#259; vulnerabilitate &#537;i anun&#539;&#259; public, &#238;ns&#259; organiza&#539;ii care dezvolt&#259; software care include aceast&#259; libr&#259;rie am&#226;n&#259; actualizarea. Pe aceast&#259; am&#226;nare s-au bazat atacatorii care au ex-filtrat datele clien&#539;ilor companiei Equifax &#238;n 2017<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-1" href="#footnote-1" target="_self">1</a> .</p><h4><em>Publicarea unei libr&#259;rii cu nume similar</em></h4><p>De&#537;i cu impact mai mic, profit&#226;nd de bun&#259;-voin&#539;a &#537;i politica permisiv&#259; a hub-urilor de pachete cu surs&#259; deschis&#259;, atacatorii &#238;ncarc&#259; copii ale unor pachete extrem de populare, la care adaug&#259; cod mali&#539;ios - dar cu o liter&#259; schimbat&#259; - de exemplu &#238;n loc de jQuery, jQwery. Mul&#539;i dezvoltatori, mai ales juniori, vor trece cu vederea diferen&#539;a de liter&#259;, sau de multe ori acestea se prezint&#259; ca av&#226;nd func&#539;ionalit&#259;&#539;i extra fa&#539;&#259; de original. </p><p>Acest tip de atac se nume&#537;te typosquatting &#537;i cel mai relevant exemplu este cel al pachetului <code>crossenv</code><a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-2" href="#footnote-2" target="_self">2</a>, care a ajuns s&#259; fie desc&#259;rcat de aproape 1000 de ori, &#238;n detrimentul pachetului original <code>cross-env</code>.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://stack.moustacios.dev/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption"><em>Pentru update-uri de securitate, d&#259; un subscribe:</em></p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><h4><em>Compromiterea contului dezvoltatorului libr&#259;riei</em></h4><p>De multe ori, unele libr&#259;rii populare sunt dezvoltate de oameni foarte pasiona&#539;i, dar &#238;n acela&#537;i timp fac asta ca un hobby. De&#537;i &#238;n majoritatea cazurilor &#238;&#537;i iau m&#259;suri de securitate, se poate &#238;nt&#226;mpla ca, contul lor s&#259; fie compromis. Acest tip de atac este mai dificil de executat, deoarece persoana compromis&#259; va anun&#539;a imediat pe alte canale c&#259; este o problem&#259;. A&#537;adar atacatorii sunt nevoi&#539;i s&#259; evite acest lucru &#537;i mai apoi s&#259; publice o versiune nou&#259; a libr&#259;riei cu codul mali&#539;ios - pe care dac&#259; al&#539;i membrii &#238;l auditeaz&#259; are &#537;anse foarte mici s&#259; ajung&#259; publicat. </p><p>&#206;n acest caz libr&#259;riile dezvoltate de o singur&#259; persoan&#259; sunt mai expuse, deoarece este nevoie de compromiterea unui singur actor. Dar mai ales codul pentru versiuni poate fi publicat f&#259;r&#259; un audit. &#206;ns&#259; &#537;i companiile mari sunt expuse, iar m&#259;surile de securitate luate sau evitate de angaja&#539;i pot avea consecin&#539;e nefaste. Iar un exemplu notoriu este breach-ul suferit de compania SolarWinds prin compromiterea furnizorului FireEye<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-3" href="#footnote-3" target="_self">3</a>.   </p><h4><em>Utilizarea la scar&#259; global&#259; a unei singure libr&#259;rii</em></h4><p>&#536;ti&#539;i cum multe solu&#539;ii software se laud&#259; cu standarde &#238;nalte de securitate pentru c&#259; adopt&#259; solu&#539;ii recunoscute &#537;i aplicate &#537;i &#238;n cadrul altor sisteme. Una dintre punctele slabe provine tocmai din tendin&#539;a dezvoltatorilor de software de a folosi cele mai populare solu&#539;ii. De&#537;i pe de o parte, &#537;ansa ca aceste libr&#259;rii s&#259; fie &#537;i cele mai sigure este mai mare, c&#226;nd 90% din infrastructura de internet folose&#537;te o anumit&#259; libr&#259;rie, se dovede&#537;te c&#259; pariem prea mult pe aceste solu&#539;ii, &#238;n ciuda faptului c&#259; exist&#259; &#537;i alte solu&#539;ii cu acelea&#537;i caracteristici. Un astfel de pariu, l-am pierdut &#238;n 2014, c&#226;nd a fost anun&#539;at&#259; o vulnerabilitate &#238;n OpenSSL<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-4" href="#footnote-4" target="_self">4</a>, o libr&#259;rie care cripteaz&#259; datele a peste 90% din traficul de pe internet. </p><h3>Cum ne protej&#259;m</h3><p>Acest subiect ar merita un articol dedicat, dar ca dezvoltatori putem s&#259; aplic&#259;m un minim de m&#259;suri de securitate pentru proiectele &#537;i infrastructura pe care ruleaz&#259;:</p><ul><li><p>actualiz&#259;ri &#537;i audit-uri periodice de securitate</p></li><li><p>audit pentru codul scris de dezvoltatori - pull requests &#537;i reviews</p></li><li><p>folosirea metodelor de autentificare sigure: ssh keys, 2 factor authentication.</p></li><li><p>servicii care scaneaz&#259; periodic codul &#537;i dependin&#539;ele pentru vulnerabilit&#259;&#539;i </p></li></ul><p>Pentru companii, cele enumerate mai sus desigur, &#238;ns&#259; merit&#259; men&#539;ionate &#537;i folosirea unui VPN &#537;i standarde de autentificare ca Fido &#537;i Passkeys. Alte resurse g&#259;si&#539;i &#238;n lista de mai jos:</p><ul><li><p><a href="https://github.com/readme/guides/dependency-risk">Do your part to secure the open source supply chain</a> </p></li><li><p><a href="https://arxiv.org/pdf/1902.09217.pdf">Small World with High Risks:</a></p><p><a href="https://arxiv.org/pdf/1902.09217.pdf">A Study of Security Threats in the npm Ecosystem</a></p></li><li><p><a href="https://github.com/dependabot">Automated dependency updates built into GitHub - Dependabot</a> </p></li><li><p><a href="https://security.snyk.io/">Snyk Vulnerability Database</a></p></li><li><p><a href="https://www.sonarsource.com/solutions/security/">Sonar Source SAST</a></p></li></ul><p></p><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-1" href="#footnote-anchor-1" class="footnote-number" contenteditable="false" target="_self">1</a><div class="footnote-content"><p><a href="https://www.synopsys.com/blogs/software-security/equifax-apache-struts-vulnerability-cve-2017-5638.html">Equifax, Apache Struts, and CVE-2017-5638 vulnerability</a></p></div></div><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-2" href="#footnote-anchor-2" class="footnote-number" contenteditable="false" target="_self">2</a><div class="footnote-content"><p><a href="https://blog.npmjs.org/post/163723642530/crossenv-malware-on-the-npm-registry">`crossenv` malware on the npm registry</a></p></div></div><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-3" href="#footnote-anchor-3" class="footnote-number" contenteditable="false" target="_self">3</a><div class="footnote-content"><p><a href="https://www.npr.org/2021/04/16/985439655/a-worst-nightmare-cyberattack-the-untold-story-of-the-solarwinds-hack">A 'Worst Nightmare' Cyberattack: The Untold Story Of The SolarWinds Hack</a></p></div></div><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-4" href="#footnote-anchor-4" class="footnote-number" contenteditable="false" target="_self">4</a><div class="footnote-content"><p><a href="https://www.cisa.gov/news-events/alerts/2014/04/08/openssl-heartbleed-vulnerability-cve-2014-0160">OpenSSL 'Heartbleed' vulnerability (CVE-2014-0160)</a></p><p></p></div></div>]]></content:encoded></item><item><title><![CDATA[Sisteme de baze de date - ce este teorema CAP?]]></title><description><![CDATA[Vrei ultima? oricare disponibil&#259;? sau ce-am scris &#238;nainte s&#259; se ia curentul? Alege dou&#259;.]]></description><link>https://stack.moustacios.dev/p/sisteme-de-baze-de-date-teorema-cap</link><guid isPermaLink="false">https://stack.moustacios.dev/p/sisteme-de-baze-de-date-teorema-cap</guid><dc:creator><![CDATA[Teo cel Mustăcios]]></dc:creator><pubDate>Tue, 28 Nov 2023 05:45:22 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!TUaA!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe378fd07-e81a-4fdd-94e7-3955b2a5d595_760x379.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!TUaA!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe378fd07-e81a-4fdd-94e7-3955b2a5d595_760x379.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!TUaA!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe378fd07-e81a-4fdd-94e7-3955b2a5d595_760x379.png 424w, https://substackcdn.com/image/fetch/$s_!TUaA!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe378fd07-e81a-4fdd-94e7-3955b2a5d595_760x379.png 848w, https://substackcdn.com/image/fetch/$s_!TUaA!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe378fd07-e81a-4fdd-94e7-3955b2a5d595_760x379.png 1272w, https://substackcdn.com/image/fetch/$s_!TUaA!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe378fd07-e81a-4fdd-94e7-3955b2a5d595_760x379.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!TUaA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe378fd07-e81a-4fdd-94e7-3955b2a5d595_760x379.png" width="760" height="379" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e378fd07-e81a-4fdd-94e7-3955b2a5d595_760x379.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:379,&quot;width&quot;:760,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:93201,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!TUaA!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe378fd07-e81a-4fdd-94e7-3955b2a5d595_760x379.png 424w, https://substackcdn.com/image/fetch/$s_!TUaA!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe378fd07-e81a-4fdd-94e7-3955b2a5d595_760x379.png 848w, https://substackcdn.com/image/fetch/$s_!TUaA!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe378fd07-e81a-4fdd-94e7-3955b2a5d595_760x379.png 1272w, https://substackcdn.com/image/fetch/$s_!TUaA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe378fd07-e81a-4fdd-94e7-3955b2a5d595_760x379.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Acronimul CAP vine de la Consistency, Availabilty and Partition tolerance, dup&#259; teorema propus&#259; de Eric Brewer<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-1" href="#footnote-1" target="_self">1</a>. Aceasta nu se refer&#259; doar la sistemele de baze de date, ci la sistemele distribuite &#238;n general &#537;i afirm&#259; urm&#259;toarele:</p><blockquote><p><em>Este imposibil ca un sistem distribuit de stocare a datelor, s&#259; furnizeze simultan mai mult de dou&#259; dintre urmatoarele trei garan&#539;ii:</em></p><ul><li><p>Consisten&#539;&#259;: Fiecare citire prime&#537;te cea mai recent&#259; versiune sau o eroare.</p></li><li><p>Disponibilitate: fiecare cerere prime&#537;te un r&#259;spuns care nu este o eroare, f&#259;r&#259; garan&#539;ia c&#259; acesta reprezint&#259; cea mai recent&#259; versiune.</p></li><li><p>Toleran&#539;&#259; la parti&#539;ionare: sistemul continu&#259; s&#259; opereze chiar daca un num&#259;r arbitrar de mesaje sunt pierdute sau &#238;nt&#226;rziate &#238;n re&#539;eaua dintre noduri.</p></li></ul></blockquote><p>Uit&#226;ndu-ne la aceste trei constr&#226;ngeri este u&#537;or de observat, de ce sunt imposibil de implementat. &#206;ns&#259; &#238;n designul sau alegerea unui sistem baze de date se prioritizeaz&#259; de obicei dou&#259; dintre ele:</p><ul><li><p>fie ai consisten&#539;&#259; &#537;i disponibilitate (CA), dar &#238;n cazul unei parti&#539;ii &#238;ntre noduri sistemul va returna erori: MySQL, MariaDb<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-2" href="#footnote-2" target="_self">2</a>, SQL Server.</p></li></ul><ul><li><p>(CP) consisten&#539;&#259; &#537;i toleran&#539;&#259; la parti&#539;ionare, f&#259;r&#259; garan&#539;ia disponibilit&#259;&#539;ii: Hbase, MongoDb<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-3" href="#footnote-3" target="_self">3</a>, Redis, BigTable.</p></li><li><p>(AP) disponibilitate &#537;i toleran&#539;&#259; crescut&#259;, cu renun&#539;area la consisten&#539;&#259;: Cassandra, ScyllaDb<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-4" href="#footnote-4" target="_self">4</a>, Riak, CouchDb.</p></li></ul><p>Legat de baze de date, mai dou&#259; concepte importante de men&#539;ionat: eventual consistency &#537;i ACID. </p><p>Eventual consistency - orice baz&#259; de date devine consistent&#259; &#238;n urma unui eveniment, &#537;i respectiv toate nodurile care comunic&#259; &#238;ntre ele vor avea aceea&#537;i versiune. &#536;i cum men&#539;ionam consisten&#539;a mai sus, care este sacrificat&#259; &#238;n cazul sistemelor AP (availability &amp; partition tolerance), asta nu &#238;nseamn&#259; c&#259; aceste sisteme nu au consisten&#539;&#259;, dar nu sunt proiectate s&#259; garanteze consisten&#539;a datelor - devin consistente eventual. </p><p>De exemplu, &#238;n urma unei erori de re&#539;ea ireconciliabile, &#238;n care nodurile nu pot comunica unul cu cel&#259;lalt - un server din Australia nu mai poate comunica cu cel din Bucure&#537;ti, aceste sisteme vor returna valori diferite pentru clien&#539;ii din Australia dec&#226;t pentru cei din Bucure&#537;ti. Odat&#259; restabilit&#259; conexiunea, cea mai recent&#259; versiunea va fi distribuit&#259; &#238;ntre noduri.</p><p>Simlar cu o pan&#259; de curent la un datacenter, asta poate fi o problem&#259; cu impact minor, pentru o aplica&#539;ie de email. &#206;ns&#259; &#238;n cazul unei aplica&#539;ii pentru tranzac&#539;ii financiare este innacceptabil s&#259; ob&#539;ii valori diferite pentru acelea&#537;i cereri. &#536;i de aceea &#238;n acest caz se va alege un sistem CP (consistency &amp; partition tolerance).</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ewu7!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F890f961c-7735-43b4-98f1-09a2b182efcc_768x294.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ewu7!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F890f961c-7735-43b4-98f1-09a2b182efcc_768x294.png 424w, https://substackcdn.com/image/fetch/$s_!ewu7!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F890f961c-7735-43b4-98f1-09a2b182efcc_768x294.png 848w, https://substackcdn.com/image/fetch/$s_!ewu7!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F890f961c-7735-43b4-98f1-09a2b182efcc_768x294.png 1272w, https://substackcdn.com/image/fetch/$s_!ewu7!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F890f961c-7735-43b4-98f1-09a2b182efcc_768x294.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ewu7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F890f961c-7735-43b4-98f1-09a2b182efcc_768x294.png" width="768" height="294" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/890f961c-7735-43b4-98f1-09a2b182efcc_768x294.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:294,&quot;width&quot;:768,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:109060,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ewu7!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F890f961c-7735-43b4-98f1-09a2b182efcc_768x294.png 424w, https://substackcdn.com/image/fetch/$s_!ewu7!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F890f961c-7735-43b4-98f1-09a2b182efcc_768x294.png 848w, https://substackcdn.com/image/fetch/$s_!ewu7!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F890f961c-7735-43b4-98f1-09a2b182efcc_768x294.png 1272w, https://substackcdn.com/image/fetch/$s_!ewu7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F890f961c-7735-43b4-98f1-09a2b182efcc_768x294.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>De asemenea s&#259; nu confund&#259;m CAP cu ACID. Acesta din urm&#259; specific&#259; un mod de operare al tranzac&#539;iilor, &#537;i este specific RDBMS-urilor<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-5" href="#footnote-5" target="_self">5</a>.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://stack.moustacios.dev/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">&#206;nscrie-te pentru newletterul de programare  </p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><h3>C&#226;nd sunt importante limit&#259;rile CAP?</h3><p>Desigur, aceast&#259; &#8221;clasificare&#8221; este irelavant&#259; dac&#259; aplica&#539;ia &#238;nc&#259; &#238;n stadiul de dezvoltare cu baza de date pe un singur server (nod). Dar &#238;n momentul c&#226;nd va fi  nevoie s&#259; scaleze la mai multe noduri, cu replicare &#537;i sincronizare, sau c&#226;nd volumul de date necesit&#259; adoptarea unei solu&#539;ii alternative pentru baza de date, cunoa&#537;terea acestor limit&#259;ri ne va ajuta s&#259; facem o evaluare solid&#259;.</p><p>De asemenea, &#537;i bazele de date proprietare, pe care le lansezi &#238;n cloud, au aceste limit&#259;ri plus detalii despre laten&#539;&#259; &#537;i consisten&#539;&#259; &#238;ntre datacenters. Pentru unele seturi de date, de exemplu, cazul &#238;n care monitorizezi nivelul apei unui fluviu - mai mult de 1 secund&#259; de laten&#539;&#259; este inacceptabil.  </p><h3>Mai este relevant&#259; CAP &#238;n 2023?</h3><p>O &#238;ntrebare valid&#259;, mai ales c&#259; aceast&#259; teorem&#259; a fost publicat&#259; &#238;n 1998. &#206;ns&#259;&#537;i autorul, Eric Brewer men&#539;ioneaz&#259; c&#259; &#8221;regulile s-au schimbat&#8221; &#238;ntr-un articol din InfoQ publicat &#238;n 2012<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-6" href="#footnote-6" target="_self">6</a>.</p><p>Un alt articol<a class="footnote-anchor" data-component-name="FootnoteAnchorToDOM" id="footnote-anchor-7" href="#footnote-7" target="_self">7</a>, din 2015 argumenteaz&#259; c&#259; ar trebui s&#259; abandon&#259;m aceast&#259; clasificare, deoarece este de cele mai multe ori ambigu&#259; &#537;i &#238;n func&#539;ie de vendor poate fi interpretat&#259;.</p><p>Eu cred c&#259; aceste concepte sunt importante, &#537;i utile de &#537;tiut chiar dac&#259; aplicabilitatea lor este mai pu&#539;in relevant&#259; &#238;n ziua de azi. CAP porne&#537;te cu o serie de &#238;ntreb&#259;ri &#8221;ce se &#238;nt&#226;mpl&#259; dac&#259;&#8230;?&#8221;, &#537;i ne aminte&#537;te despre limit&#259;rile de care le vom &#238;nt&#226;lni c&#226;nd proiecte&#259;m sisteme distribuite.</p><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-1" href="#footnote-anchor-1" class="footnote-number" contenteditable="false" target="_self">1</a><div class="footnote-content"><p><a href="https://en.wikipedia.org/wiki/Eric_Brewer_(scientist)">https://en.wikipedia.org/wiki/Eric_Brewer_(scientist)</a></p></div></div><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-2" href="#footnote-anchor-2" class="footnote-number" contenteditable="false" target="_self">2</a><div class="footnote-content"><p><a href="https://mariadb.com/products/community-server/">https://mariadb.com/products/community-server/</a></p></div></div><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-3" href="#footnote-anchor-3" class="footnote-number" contenteditable="false" target="_self">3</a><div class="footnote-content"><p><a href="https://en.wikipedia.org/wiki/MongoDB">https://en.wikipedia.org/wiki/MongoDB</a></p></div></div><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-4" href="#footnote-anchor-4" class="footnote-number" contenteditable="false" target="_self">4</a><div class="footnote-content"><p><a href="https://en.wikipedia.org/wiki/ScyllaDB">https://en.wikipedia.org/wiki/ScyllaDB</a></p></div></div><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-5" href="#footnote-anchor-5" class="footnote-number" contenteditable="false" target="_self">5</a><div class="footnote-content"><p><a href="https://en.wikipedia.org/wiki/ACID">https://en.wikipedia.org/wiki/ACID</a> </p></div></div><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-6" href="#footnote-anchor-6" class="footnote-number" contenteditable="false" target="_self">6</a><div class="footnote-content"><p><a href="https://www.infoq.com/articles/cap-twelve-years-later-how-the-rules-have-changed/">CAP Twelve Years Later: How the "Rules" Have Changed</a> (Eric Brewer)</p></div></div><div class="footnote" data-component-name="FootnoteToDOM"><a id="footnote-7" href="#footnote-anchor-7" class="footnote-number" contenteditable="false" target="_self">7</a><div class="footnote-content"><p><a href="https://martin.kleppmann.com/2015/05/11/please-stop-calling-databases-cp-or-ap.html">Please stop calling databases CP or AP</a> (Martin Kleppmann)</p><p></p></div></div>]]></content:encoded></item><item><title><![CDATA[Rulează modele de limbaj pe PC, cu Ollama]]></title><description><![CDATA[Containere pentru LLM-uri]]></description><link>https://stack.moustacios.dev/p/ruleaza-modele-de-limbaj-local-cu-ollama</link><guid isPermaLink="false">https://stack.moustacios.dev/p/ruleaza-modele-de-limbaj-local-cu-ollama</guid><dc:creator><![CDATA[Teo cel Mustăcios]]></dc:creator><pubDate>Tue, 21 Nov 2023 05:25:43 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!-M8Z!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff1c125f7-f9e5-4fab-9b41-574f03555290_1200x600.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!-M8Z!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff1c125f7-f9e5-4fab-9b41-574f03555290_1200x600.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!-M8Z!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff1c125f7-f9e5-4fab-9b41-574f03555290_1200x600.png 424w, https://substackcdn.com/image/fetch/$s_!-M8Z!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff1c125f7-f9e5-4fab-9b41-574f03555290_1200x600.png 848w, https://substackcdn.com/image/fetch/$s_!-M8Z!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff1c125f7-f9e5-4fab-9b41-574f03555290_1200x600.png 1272w, https://substackcdn.com/image/fetch/$s_!-M8Z!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff1c125f7-f9e5-4fab-9b41-574f03555290_1200x600.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!-M8Z!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff1c125f7-f9e5-4fab-9b41-574f03555290_1200x600.png" width="1200" height="600" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f1c125f7-f9e5-4fab-9b41-574f03555290_1200x600.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:600,&quot;width&quot;:1200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:199982,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!-M8Z!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff1c125f7-f9e5-4fab-9b41-574f03555290_1200x600.png 424w, https://substackcdn.com/image/fetch/$s_!-M8Z!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff1c125f7-f9e5-4fab-9b41-574f03555290_1200x600.png 848w, https://substackcdn.com/image/fetch/$s_!-M8Z!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff1c125f7-f9e5-4fab-9b41-574f03555290_1200x600.png 1272w, https://substackcdn.com/image/fetch/$s_!-M8Z!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff1c125f7-f9e5-4fab-9b41-574f03555290_1200x600.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Large language models, piatra de hotar a inteligen&#539;ei artificiale pe care o vedem azi integrat&#259; cu tot mai multe aplica&#539;ii, sunt re&#539;ele neuronale &#238;nv&#259;&#539;ate s&#259; recunoasc&#259; dar mai ales s&#259; determine statistic componente care preced sau succed input-ul &#238;n limbaj natural. O s&#259; revin cu un articol mai detaliat pe tema aceasta, dar azi o s&#259; vorbim despre un proiect foarte interesant - Ollama, care &#238;&#539;i ofer&#259; posibilitatea de a rula astfel de modele pe PC-ul personal, sau pe un server din cloud dac&#259; ai la dispozi&#539;ie unul dotat. </p><h4>Docker pentru LLMs   </h4><p>Momentan disponibil pentru Mac, Linux &#537;i Windows/WSL, Ollama este un fel de docker &#238;n care po&#539;i rula modele pre-antrenate cu miliarde de parametri. Desigur vei avea nevoie de resurse, mai ales de RAM - minim 16 GB deoarece modelele vor folosi cel pu&#539;in jum&#259;tate din ei: </p><ul><li><p>8 GB RAM pentru modelele cu 3 miliarde de parametrii</p></li><li><p>16 GB RAM pentru cele cu 7 miliarde </p></li><li><p>32 GB pentru cele cu 13 miliarde</p></li></ul><p>Pe linux &#537;i WSL2 instalarea este foarte simpl&#259;, &#537;i putem rula un model local care lanseaz&#259; un prompt &#238;n trei pa&#537;i:</p><pre><code><code># Instalare
curl https://ollama.ai/install.sh | sh

# Ruleaz&#259;, modelul llama2
ollama run llama2

# Prompt
&gt;&gt;&gt;</code></code></pre><p>Alte modele disponibile sunt mistral, codellama, vicuna, starcoder, orca-mini, xvinlm. </p><h4>Http API /generate</h4><p>Ollama expune &#537;i un API pe protocolul http, prin care poate fi integrat cu alte servicii sau aplica&#539;ii care deja suport&#259; integr&#259;ri cu modele AI (de exemplu Obsidian), pentru generare de text:</p><pre><code><code>curl -X POST http://localhost:11434/api/generate -d '{
  "model"  : "llama2",
  "prompt" : "Why is the sky blue?"
}'</code></code></pre><p>Ofer&#259; &#537;i un API pentru a genera embeddings:</p><pre><code>curl -X POST http://localhost:11434/api/embeddings -d '{
  "model"  : "llama2:7b",
  "prompt" : "Here is an article about llamas..."
}'</code></pre><p>&#536;i unul pentru a crea modele pornind de la un model de baz&#259;:</p><pre><code>curl -X POST http://localhost:11434/api/create -d '{
  "name": "mario",
  "path": "~/Modelfile"
}'</code></pre><h4>Modelfile</h4><p>Simlar cu conceptul de Dockerfile, cu ajutorul unui Modelfile po&#539;i tuna comportamentul &#537;i al&#539;i parametrii specifici unui model:</p><pre><code><code>FROM llama2
# Configureaz&#259; parametrul 
# Valoare mai mare - creativ, valoare mic&#259; - coerent
PARAMETER temperature 1

# Configureaz&#259; dimensiunea ferestrei de context 4096, 
# C&#226;te token-uri va folosi modelul pentru context, la generarea 
# token-ului urm&#259;tor
PARAMETER num_ctx 4096

# Porne&#537;te cu un prompt specific, 
# Pentru a ghida r&#259;spunsurile oferite de asistent
SYSTEM You are Mario from super mario bros, acting as an assistant.</code></code></pre><p>Cu acest fi&#537;ier, cre&#259;m &#537;i rul&#259;m un model configurat:</p><pre><code>ollama create mariobros2 -f ./Modelfile
ollama run mariobros2</code></pre><p>Promptul se va lansa cu un chatbot, care va r&#259;spunde ca &#537;i c&#226;nd ar fi personajul Mario.</p><p>Un alt&#259; aplica&#539;ie interesant&#259; este cea a unui ChatGPT local, sau PrivateGPT:</p><div class="native-video-embed" data-component-name="VideoPlaceholder" data-attrs="{&quot;mediaUploadId&quot;:&quot;6eab8111-8c1e-432a-abaa-d9f8a3b35cef&quot;,&quot;duration&quot;:null}"></div><p>Surse:</p><ul><li><p><a href="https://www.youtube.com/watch?v=jib1wjgIaa4">Code to the Moon (Video)</a></p></li><li><p><a href="https://ollama.ai/">www.ollama.ai</a></p></li><li><p><a href="https://github.com/jmorganca/ollama">github.com/jmorganca/ollama</a></p></li><li><p><a href="https://github.com/kevinhermawan/Ollamac">github.com/kevinhermawan/Ollamac</a></p></li><li><p><a href="https://github.com/jmorganca/ollama/blob/main/docs/modelfile.md">github.com/jmorganca/ollama/blob/main/docs/modelfile.md</a></p></li></ul>]]></content:encoded></item></channel></rss>