<?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:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Anthony on Medium]]></title>
        <description><![CDATA[Stories by Anthony on Medium]]></description>
        <link>https://medium.com/@anthony.cherbuin?source=rss-2ab40f7ae0e1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*a9STVanRGIDXilFfK3p6hQ.jpeg</url>
            <title>Stories by Anthony on Medium</title>
            <link>https://medium.com/@anthony.cherbuin?source=rss-2ab40f7ae0e1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 10:16:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@anthony.cherbuin/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[I built my family their own Spotify-style app in 5 days with Claude.]]></title>
            <link>https://medium.com/@anthony.cherbuin/i-built-my-family-their-own-spotify-style-app-in-5-days-with-claude-9faa280c2624?source=rss-2ab40f7ae0e1------2</link>
            <guid isPermaLink="false">https://medium.com/p/9faa280c2624</guid>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[claude]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Anthony]]></dc:creator>
            <pubDate>Fri, 27 Nov 2026 09:42:40 GMT</pubDate>
            <atom:updated>2026-11-27T09:42:40.409Z</atom:updated>
            <content:encoded><![CDATA[<h4>iPhone, Android, Windows and Mac from one codebase, 9 releases shipped to the family phones.</h4><p><em>Not affiliated with Spotify. Not for sale. Not on any app store. Just a family app that looks and feels like the one we all know.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*MjHIlxUrxZoY2ERMs8xVhg.gif" /></figure><p><strong>Five days after I opened a terminal, my whole family had moved to a music app I built.</strong> Here is what I did, and what Claude did.</p><p>It is 2026. An AI writing an app is not news anymore: Claude Code writes most of the code in my day job too. What is interesting is everything around the code. What you ask for, how you check it, and how you ship it to people who don’t care at all how it was built.</p><p>So here is a small real project, told from that angle.</p><h3>The brief</h3><p>At home we have iPhones, Androids, Windows PCs and Macbooks. I wanted one music app for the whole family: everyone with their own account, synced playlists on every device, the living room speakers one tap away.</p><p>And one hard rule: <strong>if you have used Spotify, you already know how to use it.</strong> Same home page with your mixes, same player, same “Connect” sheet for the speakers, same gestures.</p><p>On 24 October I opened a terminal and gave Claude Code that brief. 5 days later the app was on every phone of the family.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*5vmxuJ9zElcT7tMSn-JC7w.gif" /><figcaption>The real thing, on my iPhone: launch, home, a radio, the player and the lyrics.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LEipGXneJrkiNMazedWM6w.png" /><figcaption>If you know Spotify, you know this screen. That was the whole point.</figcaption></figure><p>One app on iPhone, Android, Windows and Mac. One account. Speakers, AirPlay and Bluetooth in the same sheet. Podcasts in the same app. And updates that land on every phone without me touching anything.</p><h3>What it does</h3><p>I did not start from an empty folder. The base is <strong>Spotube</strong>, an open-source music player built with Flutter (huge thanks to its team). Flutter gives one codebase for every device, which is the right trade-off for a team of one human and one agent. On top of it I built:</p><ul><li><strong>A Spotify-style redesign</strong>: home page with Daily Mixes and radios that rotate, liked songs, playlists, a full-screen player with lyrics.</li><li><strong>Spotify links just work</strong>: someone sends you a Spotify link, it opens in the family app.</li><li><strong>Your Spotify past comes with you</strong>: playlists and the full listening history from the data export Spotify gives you on request. For me: <strong>169,337 plays and 47,981 different tracks</strong>. Yes, I listen to too much music.</li><li><strong>The family listens</strong>: a shelf on the home page with one card per family member, showing the song they played the most this week. Tap a card to see their full top 5 of the last 7 days. It refreshes every Monday, so it turned into a small weekly ritual at home. My favourite feature, by far.</li><li><strong>New music videos</strong>: a custom shelf with the latest official music video of the artists you like. It checks each artist’s own channel first, so you get the real clip, not a fan upload.</li><li><strong>Speakers</strong>: the app finds the Sonos speakers on the home wifi by itself. AirPlay and Bluetooth sit in the same sheet.</li><li><strong>Podcasts, downloads and an offline mode</strong>, for the train and the mountains.</li><li><strong>Artist pages with an “About” section</strong>, built from Wikidata and Wikipedia.</li><li><strong>A Mac app</strong>, with all your devices visible in your account and live sync.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sr9kAls0oftfhRff5a6gRQ.png" /><figcaption>Now I know who plays the same song 40 times a week. (Names and faces blurred.)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZY2ECtd4mUJ14yUf6Tb02g.png" /><figcaption>Artist pages with an “About” section, built from Wikidata and Wikipedia.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J4uiRLdYDqryWjpEWK4jlA.png" /><figcaption>Podcasts live in the same app. No extra app on the phone.</figcaption></figure><p><strong>How the Mac knows what the phone plays.</strong> Every app signed in to an account joins a private real-time channel on Supabase, one channel per account. Each device announces there what it plays: the song, play or pause, and the position with the time it was taken, so the other devices compute where the song is on their own instead of receiving a constant flow of updates. Commands like play, pause, skip or “move the music to the Mac” travel on the same channel as small events. A database rule makes sure only the account owner can read or write on that channel, so family members never see or control each other’s devices. No server of my own, no polling.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-45g-kRH__bS22s1sqeOfg.png" /><figcaption>The Mac app, same account: the music plays on my iPhone, and the Mac shows it and controls it live.</figcaption></figure><h3>How the work was split</h3><p>Claude wrote almost all the code: Dart for the app, a bit of Swift and Kotlin for the native parts, SQL for the database, shell for the release pipeline. I wrote a few lines. My time went into five things.</p><p><strong>1. Architecture calls.</strong> Fork a solid open-source base instead of starting from scratch. One Flutter codebase for four platforms. Supabase (hosted Postgres with sign-in and real-time built in) for accounts, sync and the family features. Ad-hoc builds for the family phones instead of the app stores. Those choices shaped everything, and an agent will not make them for you.</p><p><strong>2. A closed feedback loop.</strong> Claude does not just write code and hope. It builds the app, installs it on an iPhone simulator, taps through the screens by itself, takes screenshots, compares them with my Figma designs using MCP connection and fixes what looks wrong. When a bug only shows up on a real phone, it pulls the logs and the database straight from the device. The faster the loop, the fewer things I have to look at.</p><p><strong>3. Context as infrastructure.</strong> The repo has a rules file the agent reads at every start (how to build, how to ship, what never to do) and a handoff file it keeps up to date itself. When it hit its usage limit in the middle of a big change, the next run picked up the work from those notes. Treat that file like code.</p><p><strong>4. Shipping.</strong> One command builds the iPhone, Android, Windows and Mac versions, publishes them, and every phone of the family shows an “update available” banner. Nine releases in the first ten days, zero app store reviews.</p><p><strong>5. Tools and references, not just prompts.</strong> For the backend, I connected Claude to Supabase through its MCP server. It designed the tables, the security rules and the SQL function behind “The family listens”, applied the migrations itself and checked the result in the database. I only reviewed the schema. For the speakers, I gave it an open-source Sonos repo to read as a reference. It studied how the speakers are found on the network and how they are driven, then wrote its own version for the app. An agent with good references writes far better code than an agent with a long prompt.</p><h3>Limitations</h3><ul><li><strong>Sound quality, but only on Sonos.</strong> On the phone, in the car, with AirPlay or Bluetooth, the sound is great, even at 128 kbps AAC. On the Sonos speakers, the same songs sound flatter than in the big streaming apps. That is the one gap I still hear. The next idea: a small server of its own that streams FLAC quality to the speakers.</li></ul><p><strong>Everything else?</strong> After one month of daily use by the whole family, it feels exactly like Spotify. Same habits, same speed, same comfort.</p><h3>Questions people ask first</h3><p><strong>Can I download it ?</strong><br>No. It is built for my family only, and it will stay that way. Releasing it publicly would bring trouble I don’t want. I wrote this article to show what is now doable, not to ship another app. It stays with me and my close family.</p><p><strong>So it is a Spotify clone ?</strong><br>It is a Spotify-style app: same habits, same layout, zero learning curve. But it is not Spotify, it has 0 link with Spotify, and it uses no Spotify code, api or logo.</p><p><strong>Did you write any code ?</strong><br>A few lines. Mostly I wrote briefs, made the architecture calls, read diffs and tested on real phones.</p><p><strong>How long did it take, really ?</strong><br>Five days, from the first prompt on 24 October to the app on every phone of the family. Then five more days of polish from real use: the car, the speakers and the family’s feedback. Mostly evenings.</p><h3>Your turn</h3><p>If you are an engineer, the hard part is not the code anymore. Pick a good open-source base, write a sharp brief, build the feedback loop, and spend your own time on the decisions.</p><p><em>Spotify is a trademark of Spotify AB. This project is a private family app with no link to Spotify.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9faa280c2624" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Vercel’s Flat Rate CDN Is a One-Way Ratchet, and You’re Already Strapped In]]></title>
            <link>https://medium.com/@anthony.cherbuin/vercels-flat-rate-cdn-is-a-one-way-ratchet-and-you-re-already-strapped-in-879447447e9a?source=rss-2ab40f7ae0e1------2</link>
            <guid isPermaLink="false">https://medium.com/p/879447447e9a</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[indiehackers]]></category>
            <category><![CDATA[vercel]]></category>
            <category><![CDATA[dark-patterns]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <dc:creator><![CDATA[Anthony]]></dc:creator>
            <pubDate>Wed, 25 Nov 2026 13:02:45 GMT</pubDate>
            <atom:updated>2026-11-25T13:02:45.513Z</atom:updated>
            <content:encoded><![CDATA[<h3>It upgrades itself without asking. It never downgrades on its own. I call that a dark pattern, and here’s how to get out.</h3><p>I found it scrolling an invoice from Vercel last week. Between the usual Pro charges sat a line I had never seen until now: <strong>Flat Rate CDN 10M, $20/month.</strong> I never picked a tier. I never clicked “upgrade.” I didn’t even know I was enrolled in anything.</p><h3>Step one: enroll everyone by default</h3><p>Flat Rate CDN is now <strong>on by default for new Vercel Pro teams.</strong> It isn’t opt-in. It’s just on. Pro includes the lowest tier for free: <strong>1M CDN requests and 1 TB of data transfer per month.</strong> The paid tiers are $20/month (10M requests, 50 TB), $100 (50M) and $300 (150M).</p><p>The quota sounds generous until you see how it’s counted: per <em>team</em>, not per project. Every project you own drains the same 1M bucket. Every HTML page, JS chunk, favicon, API call and preview fetch counts. So does every bot...</p><h3>Step two: upgrade them automatically</h3><p>My team ran at about 750k requests a month for Months. Then I deployed one Payload CMS app. Between the admin panel, the API routes and the previews, team-wide requests jumped to <strong>1.7M–2.45M a month.</strong></p><p>Bandwidth? <strong>22–29 GB a month.</strong> That’s less than 3% of the free 1 TB.</p><p>Didn’t matter. Per Vercel’s own docs, if your usage for a billing cycle exceeds your tier, you get moved up a tier at the start of the next cycle. Yes, the terms promise at least seven days’ notice. It’s the kind that lands next to “Your weekly usage summary” and dies there. <strong>Sorry, but notice is not consent.</strong></p><h3>Step three: never move them back down</h3><p>Here’s the part that turns a pricing model into a trap. Vercel’s terms say it plainly: <strong>tiers do not downgrade automatically.</strong></p><p>So to be clear... When usage goes <em>up</em>, Vercel acts for you by the next billing cycle. When it goes <em>down</em>, whether back under 1M or all the way to zero because you deleted the project, Vercel does nothing. You keep paying $20 every month until you notice and fix it yourself.</p><p>Automatic in the direction that earns them money, manual in the direction that saves you money. If that isn’t a dark pattern, I don’t know what the term is for.</p><p>And there’s a sneakier layer. Say you do notice and drop back to the free 1M tier. Congratulations, you’re still enrolled. The next time you cross 1M, the ratchet clicks again and you’re back at $20. Downgrading isn’t an exit. <strong>Only switching Flat Rate CDN completely Off is.</strong></p><h3>The real slap in the face: $20 extra for traffic that should have cost me $0 extra</h3><p>At around 2M requests, I was using about a fifth of the 10M tier’s request capacity and under 0.1% of its 50 TB. Vercel is charging me warehouse rent to store a shoebox.</p><p>With Flat Rate CDN off, you’re back on plain on-demand pricing. Rates depend on where your traffic comes from. They range from <strong>$2.00 to $3.20 per 1M CDN requests</strong> and from <strong>$0.15 to $0.35 per GB</strong> of Fast Data Transfer. My traffic is mostly European, and in Frankfurt the rates are $2.60 per 1M requests and $0.15 per GB.</p><p>Now take a pessimistic case and bill every request and byte from zero. My worst month (2.45M requests, 29 GB) comes to about $6.37 for requests plus $4.35 for transfer: <strong>roughly $11.</strong> Even if every single request came from Vercel’s most expensive region, it would be about $18. That’s still less than the tier.</p><p>Now the punchline. <strong>Every Pro plan already includes $20 of monthly usage credit</strong> that you can spend across infrastructure resources. Those few CDN dollars come out of credit you’re already paying for with the platform fee. The Flat Rate tier showed up on my invoice as its own $20 line, stacked on top.</p><p>So it’s <strong>$20 a month versus $0 extra</strong>, as long as your functions and other usage leave room in the credit.</p><p>And when does the $20 tier actually start paying off? Count requests only. At Frankfurt’s $2.60 per million, pay-per-use only costs more than $20 above <strong>roughly 7.7M requests a month</strong>. Depending on region, that’s between about 6.3M and 10M. That’s before the credit even comes into play.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q-QNVXu9UY3dpNe5X5zwvQ.png" /><figcaption><em>Requests only. Data transfer (GB) is billed on top when Flat Rate CDN is off, at $0.15 to $0.35 per GB depending on region. Image-heavy or download-heavy sites should add it before deciding, because it lowers the break-even.</em></figcaption></figure><p>Sure, Flat Rate CDN makes sense if you push serious bandwidth or go viral every other week. Vercel’s launch post brags about a team it saved tens of thousands of dollars. Good for them. But defaulting every small team into an auto-escalating subscription that never escalates back down isn’t “spike protection.” It’s revenue protection.</p><h3>Get out in five minutes</h3><ol><li><strong>Check your invoice right now</strong> for a “Flat Rate CDN” line.</li><li><strong>Find the noisy project.</strong> Go to <em>Usage → CDN Requests</em> and filter by project, or run vercel billing usage for a day-by-day view. The usual suspects are CMS admin panels that poll, clients that refetch on window focus, and bots.</li><li><strong>Turn it OFF. Don’t downgrade.</strong> Go to <em>Billing → Flat Rate CDN</em>, switch off the toggle and confirm. Your current tier runs until the end of the cycle, then you’re on on-demand pricing and out of the ratchet.</li><li><strong>Set a spend alert</strong> in Spend Management, so the next surprise comes from you and not from them.</li></ol><h3>Defaults are decisions</h3><p>Someone at Vercel chose this default. They chose for upgrades to be automatic. They chose for downgrades not to be. Those aren’t accidents of UX. They’re product decisions, and every one of them points the same way.</p><p>$20 a month won’t sink anyone. But it’s $240 a year for capacity I wasn’t using, on a feature I never chose. Multiply that by every small Pro team that hasn’t looked yet.</p><p>Go check your invoice. Then flip the switch.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=879447447e9a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Can you totally remove content filling in your Agency web dev process in 2026?]]></title>
            <link>https://medium.com/@anthony.cherbuin/can-you-totally-remove-content-filling-in-your-web-dev-process-in-2026-9fa4307807a4?source=rss-2ab40f7ae0e1------2</link>
            <guid isPermaLink="false">https://medium.com/p/9fa4307807a4</guid>
            <category><![CDATA[agency]]></category>
            <category><![CDATA[cms]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Anthony]]></dc:creator>
            <pubDate>Thu, 23 Apr 2026 10:02:06 GMT</pubDate>
            <atom:updated>2026-04-23T10:02:44.956Z</atom:updated>
            <content:encoded><![CDATA[<p>If you’re part of a web team and have ever tackled a content-heavy project, there’s a good chance the phrase “content filling” makes you want to walk out of the meeting. In fact, it’s likely that no one on your team wants to take 100% responsibility for it.</p><p>Perhaps I am wrong, and your agency does offer content population as a service. But that comes with a price tag, adding content to a CMS is time-consuming, and it significantly increases the project estimate. Because of this, the common industry approach is to shift the responsibility to the client.</p><p>The assumption is that once the CMS is delivered, the client can simply migrate their data from source files. However, the reality is nuanced. The success of this hand-off depends entirely on the client’s resources and the intuitive design of the CMS you have built. Sometimes it works smoothly, sometimes it adds support hours you had not planned. But why is this task so universally avoided?</p><p>At a time where AI is more and more powerful, we have to remain competitive as an agency. Let’s be fair, in 2026 with the power of AI a single freelancer can easily compete with what an agency was doing back years ago. Yes, we still are 100% sure we provide a better value with our CMS solution, client understanding, design, solution provided and knowledge overall. But it’s also a time where it’s our job to be able to provide better value to our potential clients wherever we can in order to be a step ahead. In this case, content filling can be improved on our side and help us improve our client experiences.</p><h3>The issue</h3><p>In a way it’s understandable. If you’re not part of a very big web team, the roles usually revolve around these people:</p><ul><li><strong>PMs:</strong> Manage the project</li><li><strong>Developers:</strong> Develop</li><li><strong>UX/UI team:</strong> Design</li><li><strong>Content writers:</strong> Write the content</li></ul><p>Such a team works, and it’s enough to create a really good website. However if you try to draw the line to who’s responsible for the content filling in the CMS of the new website, you’ll be faced with some questions at one point.</p><p>Asking the UX/UI team to be responsible for filling the content is not a good option in our case. Our main process looks a bit like this in the main lines:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k8REZ1ZkH8owI6iFJWGbJA.png" /><figcaption><em>How our web projects are managed</em></figcaption></figure><p>This means our UX/UI team is always a step forward in every project (in theory) so that the machine can keep going and the dev team always has something ready to start developing. Sure, this is not always perfect and in practice tandem work is daily business. However if we want to try to keep the team rolling, it’s not the best solution to slow down the designers when they definitely have other projects and workshops to think about.</p><p><strong>The obvious solution… at first:</strong> One might think it’s the work of the content writer. Well, they write the content already, so the content needs to be part of their job, no? However our content writers work with their own tools and process which allow them to quickly iterate and update their content based on client feedback. Asking them to fill out the content is basically adding a new work to their pipeline, not impossible, but they then also need to take part in some CMS training in order to be efficient. This means more time for training on every project and more work too. Integrating the content directly in the CMS is also, even with the best CMS you might have, way more time-consuming than simply writing in a Word file, so this is not an option.</p><p>To remove this issue, at one point we decided that it was better and more time-efficient for our PM to integrate the content in the CMS. When you think about it, the PM already has a really good overview of the project and knows the status of the CMS and client feedback more than everyone else in the team, so they’ll be efficient. It’s true! And this also allowed us to gain some time on the CMS training. However in a digital agency like ours, our PMs are one of the most solicited people daily, between calls, tickets, team management, adding them this workload might work in some cycles with fewer projects, but it very quickly became a big bottleneck during middle to high loaded cycles.</p><p>This leads us to the 3rd idea: why not ask the developers to integrate the content? Let’s take the final content created by the content writer and integrate it step by step in the CMS they know by heart and developed during weeks, what can go wrong? You’re right, nothing can go wrong… if you’re not taking time and price optimization into account, and your developers’ sanity also…</p><p>Is it really optimal for our company to charge engineering/PM hours to the client for content filling? If you build small websites and this accounts for 1–2H, why not. But quoting 2–7 days of content filling at engineering rate really calls for some optimization thinking, that’s something worth revisiting.</p><p>Soooooo what are we doing? Give all the job to the young trainee that came to learn design in the company for a few months? Let’s be fair, this came to our mind at one point, as a joke, but we’re not monsters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*olg0tgqnYSHm6pqt.gif" /><figcaption><em>Team meeting to decide that the intern is responsible to fill out a 146-page CMS from Word files</em></figcaption></figure><p>So we land back on the default: let the client fill it out with pre-made pages, CMS training, and support along the way. It works. But two things keep bothering us about it:</p><ul><li>If given a white card with a pre-made design, there is a 100% chance the client will use components in a way that was not thought of by the UX/UI team. Know the sentence “if something can go wrong it’ll go wrong”? I am speaking about this here. Using this way of doing will give you a good time of refactoring the content of your client if you want your final product to look and feel as your team designed it.</li><li>We take care of our clients and want them to have a good experience from the onboarding process to the content filling. Giving them some links and tutorials and telling them “now go” always feels a bit like dropping your kid in the forest with a torch and some snacks while hoping they’ll make it back home fit and safe.</li></ul><h3>Stop the thinking, let’s take action</h3><p>Now that the thinking is finished and we drank a few coffees (btw nothing related, but did you know you can use dandelion roots and roast them to get a bitter coffee alternative? I might write about this one day…).</p><p>Stop with the surface reasoning and let’s get to business. What can our dev team do to fix this situation? We like to take the problem as a solution first and cut the road to it by steps. What would the best solution be then, in a single sentence?</p><blockquote><em>We should be able to provide a fully filled website to the client for the least amount of cost as possible.</em></blockquote><p>It might not be possible to automate this easily in a single shot, but we decided to do a quick MVP first to target the issues and improvement points as early as possible. Here’s a basic overview of our technical idea on how to implement such a solution:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UbF8rOxxbY7BfW86bJzDDA.png" /></figure><p>While 99.9% of CMS content eventually becomes public, it’s the 0.1% that shouldn’t, the forgotten internal memo in a PDF, the unreleased financial drafts, or Figma links to unshipped designs that dictates our architecture.</p><p>That’s why we decided to build on Infomaniak hosted LLMs. By using a Switzerland-based provider, we ensure data stays on-shore, remains private, and is never used to train foreign models.</p><p>But, as of the date I am writing this, Infomaniak’s API doesn’t natively support web browsing or file search yet. To give our users an OpenAI-like experience without compromising our privacy standards, we engineered three server-side workarounds:</p><ul><li><strong>Qwen3’s massive context:</strong> We feed full document content directly to the model, bypassing the need for a custom vector-based search setup and infrastructure (downside: limited in size, but works well with small to medium size documents).</li><li><strong>Smalot PdfParser:</strong> PDFs are parsed on our servers, only the raw text reaches the LLM.</li><li><strong>Jina Reader:</strong> URLs are quickly converted into clean Markdown before processing, creating a web access capability that we also input in the context.</li></ul><p>We spent the first few weeks perfecting a CLI-first approach to ensure technical stability before wrapping it in a UI addon. The result is a tool that handles the “scaffolding” of a site in minutes, entirely under our control.</p><p>Here’s a quick first look at our tool in action for the creation of a single page:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rcRmoEwu6S2e5jLIyzJ5hg.gif" /><figcaption><em>We allow PDF/TXT files upload to provide content to the LLM</em></figcaption></figure><p>This worked better than we expected. We were afraid the LLM wouldn’t use the correct sections, but with an improved description of what every section does in the original context, it targeted very precisely the usage to the new sections.</p><p>We still ran into small issues:</p><ul><li><strong>What about page translations?</strong> A lot of old websites are not using correct hreflang and alternate references. This makes the linking of the languages difficult. We decided to fix this by first checking those elements; if not available we check the navigation URLs; if not available we then use the website sitemap and our LLM to find related pages. If this still doesn’t work, we also created a bulk translation tool directly in our CMS with the DeepL API in the backend.</li><li><strong>What about other requests the user might have?</strong> Like updating a page, deleting this, etc…? Well, those are agentic behaviors that need some safeguards. We decided to integrate it later and we allowed our tool write access for the creation of new pages only.</li></ul><p>Once this logic was developed we ran a few tests. Cost of the operation to create a scaffold of a 20-page website, you ask? 15 minutes and 0.18 CHF of API costs, plus one hour of testing and updating minor content being placed at the wrong place.</p><p>It’s definitely not perfect, but what would have taken 8 hours before takes us now 1 hour. It’s a promising first step.</p><p>This is now a tool we’ve now freshly integrated into our dev process, and it drastically reduced content filling time and costs. We’re already thinking about the next steps: improving the UI and adding functionality so everyone involved in the project can push bulk content during the filling phase.</p><p>Our clients will now receive not just a website, but a website with content already filled in their CMS, and soon, a tool they can use to create their own pages faster. All for a fraction of the previous time and effort.</p><p>So, can you totally remove content filling in your web dev process in 2026?</p><p>No. But you can make it way more enjoyable and fast with a good stack and today’s LLMs.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9fa4307807a4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Google MyMaps was ugly — So I built  a SaaS alternative]]></title>
            <link>https://medium.com/@anthony.cherbuin/google-mymaps-was-ugly-so-i-built-a-saas-alternative-20ca324fef0d?source=rss-2ab40f7ae0e1------2</link>
            <guid isPermaLink="false">https://medium.com/p/20ca324fef0d</guid>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[google-my-maps]]></category>
            <category><![CDATA[custom-map]]></category>
            <category><![CDATA[saas]]></category>
            <category><![CDATA[maps]]></category>
            <dc:creator><![CDATA[Anthony]]></dc:creator>
            <pubDate>Sun, 26 Jan 2025 03:53:03 GMT</pubDate>
            <atom:updated>2026-02-12T17:00:07.082Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Google MyMaps was ugly — So I built a SaaS alternative</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JfPMQNot-FrS4IjRss54Ew.png" /><figcaption>It already looks better no ?</figcaption></figure><p><strong>My first Problem: Why I Hated Google MyMaps</strong><br>As a developer and occasional event organizer, I relied on Google MyMaps for years, because it’s useful. But let’s be honest: it’s clunky, visually outdated, and rigid. Customizing the map felt like solving a puzzle, embedding maps as iframes broke my website’s design flow and worst of all? It looked <em>unforgivably outdated </em>— like a relic from the early 2000s. I needed a tool that was <strong>simple</strong>, <strong>aesthetic</strong>, cheap and <strong>developer-friendly</strong>. When I couldn’t find one, I built <a href="https://mamap.io/">mamap.io</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mginxvb7nD3nco6ycwE66Q.png" /><figcaption>Holy Moly…is this what I really want on my beautiful Nuxt3 Frontend ?</figcaption></figure><p><strong>The 2nd Problem: Why I Hated developing maps</strong></p><p>If designing maps with Google MyMaps felt like wrestling a bear, <em>developing</em> them was like trying to teach that bear ballet. The real nightmare began when integrating maps into client projects. Want to link markers to a CMS like Sanity or Wordpress ? Prepare for some hours of API code. Managing images and popup content ? — a soul-crushing loop of copy-paste code from c̶h̶a̶t̶G̶p̶t̶ the package documentation.</p><p>And the search bar? The real headache wasn’t just styling it — it was reinventing the wheel every time I started a new project. Manage the zoom, update a location, refresh the map, open the popup… Ha, and popups? Also that you need to style it.</p><p>I craved a tool where the search bar intuitively worked out of the box, where popups would display my image nicely, and where CMS integration would just be a far away bad dream while I drink my nice morning espresso.</p><h3>The Vision: A basic beginning</h3><p>I am simple dev, so I envisioned a mapping tool that prioritized three main things in the first time:</p><ol><li><strong>No Iframes</strong>: No more ugly Iframes. Users should be able to tweak all the css to match their brand.</li><li><strong>Ease of use and no backend management</strong>: Drag-and-drop simplicity for non-developers, handling of images, pop-up, searchbar and markers editing outside of my project.</li><li><strong>Avoiding Google maps pricing</strong>: No hidden fees. A stable solution for everyone based on Open-Source solution.</li></ol><p>This led to <a href="https://mamap.io/">mamap.io</a> — a platform combining Leaflet’s open-source flexibility with SaaS-grade polish.</p><h3>How mamap.io Solves the Google MyMaps Problem</h3><p>Let’s break down why this tool exists:</p><h4>1. Beauty Meets Functionality</h4><p>Google MyMaps’ UI felt like a spreadsheet. Mamap.io’s maps are built for <strong>visual integrations</strong>. Custom CSS lets you style every element — search bars, popups, markers — to align with your website’s design. Want rounded corners? Shadow effects? A dark theme? Done. No Iframes, no constraints.</p><h4>2. Developer-Friendly Integration</h4><p>Forget wrestling with Google’s APIs. Mamap.io uses a lightweight script tag, letting you embed maps directly into your site. Need advanced tweaks? The CSS classes are fully exposed, so you can override styles for rapid customizations.</p><h4>3. Privacy-First and Google away</h4><p>Solutions based on google’s pricing tiers gave me nightmares. Mamap.io uses Leaflet in the background, slashing costs without sacrificing quality. Plus, your data stays yours — no ads, no tracking, no selling to third parties.</p><h3>The Technical Nitty-Gritty</h3><p>Building mamap.io meant solving real-world frustrations:</p><ul><li><strong>Customization</strong>: Users demanded control. We enabled CSS overrides for everything, from popup backgrounds to search bar.</li><li><strong>Scalability</strong>: A centralized dashboard lets businesses manage multiple maps — stores, events, service areas — without coding.</li></ul><h3>Who can use It? (Spoiler: Everyone I think…)</h3><ul><li><strong>Businesses</strong>: Showcase store locations in a clean, interactive format.</li><li><strong>Developers</strong>: Embed maps into client sites without rebuilding functionality from scratch.</li></ul><p>Obviously I made a tutorial to show the current state: <a href="https://www.youtube.com/watch?v=JG5nI9oOKiQ&amp;t=1s">https://www.youtube.com/watch?v=JG5nI9oOKiQ</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aeIpgVjKZd9UKufErweVUg.png" /><figcaption>The same map, one time with Google my maps and one time using mamap.io</figcaption></figure><h3>The Road Ahead</h3><p>Mamap.io is just starting. Future plans I have include:</p><ul><li>Advanced map customization</li><li>Filters creation for searchbar</li><li>Better management of markers customization</li><li>Improved UI for the map editing</li><li>Improved loading time of the script</li></ul><p>But the core promise should remains: <strong>maps should be beautiful, simple, and accessible to all</strong>.</p><p><strong>Try It Yourself</strong><br>If you’re tired of ugly, inflexible maps, or tired of integrating the same map solution in your CMS for the 10th time this year, give <a href="https://mamap.io/">mamap.io</a> a spin. <strong>I write this article because I am looking for 5 people motivated to test it for free this year against feedbacks</strong>.</p><p>If you’re interested, just ping me and let’s make mapping fun again :)</p><p><em>— A developer who just wanted pretty maps</em></p><p>Want to hire me ? Contact me at <a href="https://www.esaho.ch/">https://www.esaho.ch</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=20ca324fef0d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Learning ML basics and using it to become rich in 2024 by predicting Swiss Ice Hockey results]]></title>
            <link>https://medium.com/@anthony.cherbuin/learning-ml-basics-and-using-it-to-become-rich-in-2024-by-predicting-swiss-ice-hockey-results-99aa8e093933?source=rss-2ab40f7ae0e1------2</link>
            <guid isPermaLink="false">https://medium.com/p/99aa8e093933</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[switzerland]]></category>
            <category><![CDATA[hockey]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Anthony]]></dc:creator>
            <pubDate>Sat, 20 Jul 2024 03:26:36 GMT</pubDate>
            <atom:updated>2024-07-20T03:26:36.700Z</atom:updated>
            <content:encoded><![CDATA[<p><em>This title might be a small clickbait…but if you’re here, why not read the article anyway </em>🤷 <em>?</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6sOWjMevIH_WI7Eu0O-XMw.jpeg" /></figure><p>If you directly want to test the final product: <a href="https://t.me/LNA_prediction_bot">https://t.me/LNA_prediction_bot</a> <em>(I use some free hosting and free APIs, it can take up to </em><strong><em>5min</em></strong><em> to wake up the bot when using it and it can also reach the limit of 500 API request/day)</em></p><h3>Introduction</h3><p>AI, ML, LLM have been in the mouth of every developer and digital enthusiast those last years. It’s surely a crazy time to live in and the idea of being able to breakthrough a lot of unsolved historical problems using those technologies is surely motivating. I always have a lot of interest for new technological stuff (it does certainly comes from my geeky side).</p><p>However, I also know by experience that a lot of those early interest that start as small side hobbies can quickly drop me in the dark side of the Mordor once I’ve scratched the surface and try to understand more about the subject (like FPV drones, IOT or 3d printing…where debugging take more time and nights than the hobby itself… Knows who knows).</p><p>This is why I want to say this now before you read more of this text: <strong>this article is by no mean a tutorial or a source of truth</strong>, it’s more an explanation of my curiosity journey toward the learning and development of my first ML project on the web as a Frontend and Creative engineer.</p><p>Feel free to enjoy the idea and development of the project by reading it while drinking a coffee. If you feel like you’re more in the mood of learning the technical side of this subject properly by someone who is more experienced, I invite you to read this article <a href="https://python.plainenglish.io/creating-machine-learning-models-to-predict-football-game-outcomes-70b6bf02885c">https://python.plainenglish.io/creating-machine-learning-models-to-predict-football-game-outcomes-70b6bf02885c</a> or <a href="https://www.kdnuggets.com/2023/01/python-machine-learning-predict-football-match-winners.html">this one</a>. Those are really good posts with detailed explanations.</p><h3>What do we build ?</h3><p>The idea is not new, a lot of peoples did it already: <strong>Predicting sports Match Winners With Machine Learning.</strong></p><p>Btw, here is a video that made me think “ok let’s learn to build this bruh”:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F0irmDBWLrco%3Fstart%3D1308%26feature%3Doembed%26start%3D1308&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D0irmDBWLrco&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F0irmDBWLrco%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/86e0a37daa7607c22cc34705a6454465/href">https://medium.com/media/86e0a37daa7607c22cc34705a6454465/href</a></iframe><h3>The beginning</h3><p>I have not a precise idea at where to start at this point. But one think I am pretty sure of, is that I’ll need a basic dataset to start my project. For football (soccer) you’ll find tones of nice dataset on <a href="https://www.kaggle.com/">Kaggle</a>, but none for the Swiss hockey league. So let’s get to work and create or own starting dataset. This is something we can do by scrapping datas online using Selenium, puppeteer or some chrome extension for the more basic stuff like teams, location, dates or results. (We can go wayyyyy more complex here with the parameters, but let’s go slowly and scrap what we can easily, like: match date, scores, home and away team, …).</p><p>✨<em>Magic happen</em>✨</p><blockquote>Wooo, after this step we have all the match from 1856BC to 2024. Now what else ?</blockquote><p>Using just the basic informations of the match would not bring a lot and also I don’t think that results from to far in the past would give us any useful datas for our predictions. So let’s firstly remove all match that happened before 2008.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7682-OVKz_f1X37O5J7OWQ.png" /><figcaption>Sample of data fetched for the match</figcaption></figure><blockquote><strong>What other data could be useful ?</strong></blockquote><p>After reading some articles online I quickly understood the complexity of building a good and accurate dataset (creating a good one will take weeks/months and a lot of testing…), as said, I am by no mean experienced in ML and don’t want to spend 1 year on the dataset only…, so as first project I wanted to keep my focus on an easy solution to learn the basics, but I still wanted a solution that could lead me to get some nice results.</p><p>This is when I fumbled on this really good video from <a href="https://www.youtube.com/@CryptoWizards">Crypto Wizards</a> :</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F00YPWyB5aR4%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D00YPWyB5aR4&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F00YPWyB5aR4%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/acf55781e9cd0f3498cba855cce5062c/href">https://medium.com/media/acf55781e9cd0f3498cba855cce5062c/href</a></iframe><p>The idea is to use the historical datas from bookies and the real match results as a key value points for predictions and try to beat the brookies on the bet. This idea looked pretty interesting for me as I can find those data online and I don’t need to start listing and cross merging complex data in my dataset (team players, referee, …). So let’s get those datas and add them in our dataset. Here some parts of the python code used during the process:</p><pre># Load the datas from our 2csv for merging<br>df1 = pd.read_csv(&#39;saison_2008_2020.csv&#39;, delimiter=&#39;;&#39;)<br>df2 = pd.read_csv(&#39;Odds_2008_2020.csv&#39;)<br><br># Define the mapping function to standardize team names as it comes from different sources<br>def standardize_team_names(team_name):<br>    mapping = {<br>        &#39;HC Ambri-Piotta&#39;: &#39;Ambri-Piotta&#39;,<br>        &#39;EV Zug&#39;: &#39;Zug&#39;,<br>        &#39;Fribourg-Gottéron&#39;: &#39;Fribourg&#39;,<br>        &#39;SCL Tigers&#39;: &#39;Langnau Tigers&#39;,<br>        &#39;SC Bern&#39;: &#39;Bern&#39;,<br>        &#39;Lausanne HC&#39;: &#39;Lausanne&#39;,<br>        &#39;EHC Biel-Bienne&#39;: &#39;Biel&#39;,<br>        &#39;ZSC Lions&#39;: &#39;Zurich&#39;,<br>        &#39;HC Lugano&#39;: &#39;Lugano&#39;,<br>        &#39;Genève-Servette HC&#39;: &#39;Servette&#39;,<br>        &#39;SC Rapperswil-Jona Lakers&#39;: &#39;Rapperswil&#39;,<br>        &#39;HC Davos&#39;: &#39;Davos&#39;,<br>        &#39;HC Ajoie&#39;: &#39;Ajoie&#39;,<br>        &#39;HC La Chaux-de-Fonds&#39;:&#39;La Chaux-de-Fonds&#39;<br>    }<br>    return mapping.get(team_name, team_name)  # Return original if not in mapping</pre><pre># Since File 1 might not be in datetime format, we adjust this line to ensure it is<br>df1[&#39;Datum&#39;] = pd.to_datetime(df1[&#39;Datum&#39;], format=&#39;%d.%m.%y&#39;)<br><br># Merge the datasets on &#39;Datum&#39;, &#39;Home&#39; (&#39;TeamA&#39; in File 2), and &#39;Away&#39; (&#39;TeamB&#39; in File 2)<br>merged_data = pd.merge(df1, df2, left_on=[&#39;Datum&#39;, &#39;Home&#39;, &#39;Away&#39;], right_on=[&#39;Datum&#39;, &#39;TeamA&#39;, &#39;TeamB&#39;], how=&#39;left&#39;)<br><br># Remove rows with missing data in any of the odds columns<br>original_count = len(df)<br>df.dropna(subset=cont_vars, inplace=True)<br>removed_count = original_count - len(df)<br><br>print(f&quot;\nRemoved {removed_count} rows with missing odds data.&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NB66-ePHmxFE7-qrqAWTNg.png" /><figcaption>Odds merged in the dataset and winner defined</figcaption></figure><p>I will use this basic dataset for this project, as said we could go way more complex if we wanted to improve our precision. But as learned from an episode in <a href="https://course.fast.ai/Lessons/lesson1.html">this lesson</a> it’s always good to create a first model as soon as possible before to spend to much time on the improvement of the dataset :)</p><p>Let’s start with the training.</p><blockquote>BTW, I made this dataset open source<strong> </strong><a href="https://www.kaggle.com/datasets/anthonytoto/national-league-ice-hockey-switzerland-2008-23/settings"><strong>on Kaggle here</strong></a><strong> </strong>if some of my fellow Swiss coders or hockey fans want to use it or improve it.</blockquote><h3>Training our model with fastai</h3><p>In this section, we’ll dive into the process of training our machine learning model using Fastai, a popular deep learning library built on top of PyTorch. Fastai provides a high-level API that simplifies the process of training neural networks, which is what we need right now :)</p><p>We do have our data ready, so let’s train a model:</p><pre># Define preprocessing steps<br>procs = [Categorify, FillMissing, Normalize]<br><br># Define categorical and continuous columns again if needed<br>cat_vars = [&#39;Home&#39;, &#39;Away&#39;]<br>cont_vars = [&#39;OddsTeamA&#39;, &#39;OddsTeamB&#39;, &#39;OddsX&#39;]<br><br># Define splits for training and validation<br>splits = RandomSplitter(valid_pct=0.2)(df)<br><br><br># Prepare your TabularPandas object, ensuring all arguments are correctly utilized<br>to = TabularPandas(df, procs=procs, cat_names=cat_vars, cont_names=cont_vars,<br>                   y_names=&#39;Winner&#39;, splits=splits)<br><br># Print the first few rows of the processed training set to inspect<br>print(&quot;Processed training set preview:&quot;)<br>print(to.train.xs.head())<br><br># Create DataLoaders<br>dls = to.dataloaders(bs=64)<br>learn = tabular_learner(dls, layers=[200, 100], metrics=[accuracy, Precision()])<br><br># Find the optimal learning rate<br>learn.lr_find()<br># Train the model using the fit_one_cycle method<br>learn.fit_one_cycle(5, 1e-2)<br><br># Show results to evaluate the model<br>learn.show_results()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YzR59a-MBiErbib-DXux4w.png" /><figcaption>Precision on validation dataset: 0.6184834123222749</figcaption></figure><p>It’s a pretty basic model yes, but as a first I am happy with that for now.</p><h3>Using psychology and UX/UI to create an addictive gambling app…</h3><p>Kidding, I will create a Telegram bot… because it’s easier and less time consuming for a side project. Here is a basic idea of the project structure:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nR02-2QBn5p4W1YdY8ZqTw.jpeg" /><figcaption>My wonderful schema done in-between two coffee</figcaption></figure><p>We can split this futur project like that: Our client (Telegram app), our telegram Python bot script, external API that return the futur matchs/odds and our ML Python endpoint that return the estimation of the result.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*onBJt1weL010thF3kPoptA.gif" /><figcaption>Time to set up the APIs</figcaption></figure><h3>Preparing our Python APIs using Flask</h3><p>Having a working project locally is always nice. But my goal is to be able to integrate my ML as an API. This way I’ll be able to use it everywhere in the future and I’ll be able to call it from my Telegram bot script 🤖</p><p>Let’s create that. I wanted to keep all my work on Python and avoid any unnecessary code migration. This is why I decided to use Flask for Python in order to create my API endpoint.</p><h4>Using our fastai model anywhere</h4><p>We trained our fastai model and we want to be able to use it in our API. In order to do that we can serialize it using the command:</p><pre>learn.export(&#39;model_v1.pkl&#39;)</pre><p>This will create a pickle file (.PKL) that we can later load in our code in order to use the trained model.</p><pre>#Loading and using the exported model<br>learn = load_learner(&#39;model_v1.pkl&#39;)<br>#...<br># Convert the incoming data to a DataFrame<br>    new_data = pd.DataFrame({<br>        &#39;Home&#39;: [Home],  <br>        &#39;Away&#39;: [Away],  <br>        &#39;OddsTeamA&#39;: [OddsTeamA],<br>        &#39;OddsTeamB&#39;: [OddsTeamB],<br>        &#39;OddsX&#39;: [OddsX]<br>    })<br><br>    dl = learn.dls.test_dl(new_data)<br><br>    #Here we get the predictions<br>    preds, _ = learn.get_preds(dl=dl)<br>    prediction = preds[0].tolist()</pre><p>Now, if we integrate this in our /predict route created with Flask<br><em>@app.route(‘/predict’, methods=[‘POST’])</em> we get an endpoint that we can call from anywhere by passing to it the parameters we defined:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CYlKD0QrbCz-bqhdBwdFmA.png" /><figcaption>We can verify that our enpoint is working locally using postman already, whoooouou!</figcaption></figure><h4>Hosting</h4><p>As a big user of Vercel for all my Frontend deployment I wanted to see if I was able to use it to host my Python API. The answer is “yes you can…but it’s not the easiest way right now in my opinion”. I was able to make it work but faced some weird issues when using Vercel cli locally to run their Python runtime (still Beta as I write this article so let’s wait for the future).</p><p>In the end I decided to use <a href="https://gunicorn.org/">gunicorn</a> with Flask. I hosted my ML api code on <a href="https://render.com/">render.com</a> and I hosted the telegram bot on a Jetlastic instance (hosted by Infomaniak).</p><p>I found it way easier and less restrictive in my workflow, the prices of the services are also ok in my opinion if we need an upgrade in the future.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MP1m0rVAL7ZTiVgbB-nGjw.png" /><figcaption>don’t forget to define and install your dependencies on render.com</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0ec3JH0hnNsKLlES1Z4m2w.png" /><figcaption>and run your production app using gunicorn</figcaption></figure><h3>A bit of betting logic for our Bot</h3><p>Giving back the probability of win to the end user is cool. But when it comes to betting, simply knowing the probability of a win isn’t enough to make an good decision. While having an accurate win probability is crucial, it’s not the only factor one should consider before placing a bet.</p><p>Equally important are the odds offered by bookmakers. If these odds are less favorable than the implied probability of the win then we can say that the bet might not be worth the risk.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/1*xT4dBlIW0vk4YKexCNVfRg.gif" /><figcaption>Time to bring back those probability lessons memories from engineering school</figcaption></figure><h4>Example</h4><p><strong>Win Probability</strong>: This is the chance that a particular outcome will occur given our ML API response. For instance, if a team has a 70% chance of winning a game, the win probability returned is 0.7</p><p><strong>Odds</strong>: These are the bookmakers’ way of expressing the likelihood of an outcome and determining payouts. For example, odds of 1.2 mean that for every 1$ you bet, you would win 1.20$ if the bet is successful.</p><p><strong>To decide whether a bet is worth placing, you need to compare the implied probability derived from the odds with your own estimated win probability. </strong>So<strong> </strong>we can say that:</p><blockquote>OddsWorthBettingFrom=1/Probability</blockquote><p>For example if the win probability given by our ML is 62% we can say that a bet is worth placing if the odds given by the brooker are higher than <strong>1/0.62=1.61</strong></p><p>Now that we understand this, we can use our code to determine if a bet is worth the risk, we can provide a useful information to the end user, telling him which odds are worth betting on or not, instead of just sending back a win probability.</p><pre>    #we calculate the implied probability <br>    oddsOkFrom = round(1 / ml_probability, 2)<br>                <br>    #We return a better response<br>    response = (<br>       f&quot;🏆 {winning_team} have {ml_probability * 100:.1f}% chance to win this game.\n&quot;<br>       f&quot;✅ It&#39;s worth betting on {winning_team} if odds of the booker are higher than {oddsOkFrom}\n&quot;<br>    )</pre><p>With this done, we now will receive all the informations for the next match.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*YNa9JmQJUiruMSEJ1IlcGw.gif" /><figcaption>Let’s to put some money in this bad boi !</figcaption></figure><h3>Our Telegram Bot</h3><p>The telegram bot commands are straight forward in this V1 with just one command that we define:</p><p><em>/next_match → </em>will provide the next match or a list of the next matchs happening at the same time and the expected outcome for each match.</p><p>Main part of the bot code is this function that will call the different API and manage the matchs return:</p><pre># Async function to handle the &#39;next_match&#39; command<br>async def next_match(update: Update, context: ContextTypes.DEFAULT_TYPE):</pre><pre>#...<br>    # Make the request to the API<br>    response = requests.get(url, headers=headers, params=payload)<br>    matches = response.json()<br>    ns_matches = [match for match in matches[&#39;response&#39;] if match[&#39;status&#39;][&#39;short&#39;] == &#39;NS&#39;]<br>    <br>    if ns_matches:<br>        # Get the earliest match time<br>        earliest_match_time = min(ns_matches, key=lambda x: x[&#39;timestamp&#39;])[&#39;timestamp&#39;]<br>        # Get all matches that happen at the earliest match time<br>        earliest_matches = [match for match in ns_matches if match[&#39;timestamp&#39;] == earliest_match_time]<br>        for match in earliest_matches:<br>            # Extract relevant match information<br>            home_team = match[&#39;teams&#39;][&#39;home&#39;][&#39;name&#39;]<br>            away_team = match[&#39;teams&#39;][&#39;away&#39;][&#39;name&#39;]<br>            match_date = match[&#39;date&#39;]<br>            # Convert the match date to a readable format<br>            date_object = datetime.fromisoformat(match_date)<br>            formatted_date = date_object.strftime(&quot;%d %B %Y at %H:%M&quot;)<br>            #....</pre><p>We can now interact with our bot at anytime:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/1*vR5azfZlc8xa7uPWD1WGGA.jpeg" /><figcaption>We catch the case when the odds are not ready (available only 1–7 days prior a match)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4DBo2IJsY7dx4MikbrSlOw.jpeg" /><figcaption>When odds are available we then get the advice from the bot for the match.</figcaption></figure><h3>Conclusion</h3><p>This project is by no means a final product that one could rely on. In fact, I am pretty sure you will achieve better results by trusting your instincts rather than depending on my model, it also tends to always make an away team favorite for now…</p><p>The good news is that with the current structure of the code, I can from now on easily focus 100% on training a model to enhance accuracy without modifying a single line of the project’s core code.</p><p>It was a fun and educational experiment that allowed me to explore new possibilities, learn the very basics of machine learning, and gain insights into the current capabilities of web-based ML APIs. Additionally, it was my first experience integrating a Telegram bot into such a project. I believe this approach could be useful for specific use cases in the future, offering a fast and convenient way to fetch basic data without the need to develop a frontend.</p><p>…now I just need to wait the beginning of the 2024–2025 Hockey season and update the model to someV̶2̶ V43 in order to get some descent estimations 😄</p><p>Feel free to give me some advices, ideas.I would love to have your opinion on the subject ! ❤</p><p><em>… and hopp Gotteron </em>🐉</p><ul><li><strong>Telegram bot available here</strong>: <a href="https://t.me/LNA_prediction_bot">https://t.me/LNA_prediction_bot</a> (as I use a free hosting it can take up to 5min to wake up and give you an answer)</li><li><strong>Kaggle dataset of Swiss Hockey Nation League available here: </strong><a href="https://www.kaggle.com/datasets/anthonytoto/national-league-ice-hockey-switzerland-2008-23">https://www.kaggle.com/datasets/anthonytoto/national-league-ice-hockey-switzerland-2008-23</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=99aa8e093933" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Interact with 3D model on the web using your webcam — Vuejs]]></title>
            <link>https://medium.com/@anthony.cherbuin/interact-with-3d-model-on-the-web-using-your-webcam-vuejs-9ee281b214d5?source=rss-2ab40f7ae0e1------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ee281b214d5</guid>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[3d]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[ux]]></category>
            <category><![CDATA[a-frame]]></category>
            <dc:creator><![CDATA[Anthony]]></dc:creator>
            <pubDate>Thu, 27 Jul 2023 09:42:41 GMT</pubDate>
            <atom:updated>2023-07-27T09:45:53.198Z</atom:updated>
            <content:encoded><![CDATA[<h3>Interact with 3D model on the web using your webcam — Vuejs</h3><p>The internet is a space filled with endless possibilities. As developers, we have an exciting opportunity to redefine user interaction within this digital landscape. An idea came to my mind, what if I could transform a typical browsing experience with a mouse into something more immersive and dynamic, like interacting with 3D objects using my webcam?</p><p><strong>Final result as a video:</strong> <a href="https://dms.licdn.com/playlist/vid/C4D05AQHpDQZchyDrIA/mp4-720p-30fp-crf28/0/1640880215964?e=1691053200&amp;v=beta&amp;t=PKXiIJBekOuGNwXz1eq-D0ZMzz-Vh9VBw2Yh2j58KwQ">https://dms.licdn.com/playlist/vid/C4D05AQHpDQZchyDrIA/mp4-720p-30fp-crf28/0/1640880215964?e=1691053200&amp;v=beta&amp;t=PKXiIJBekOuGNwXz1eq-D0ZMzz-Vh9VBw2Yh2j58KwQ</a></p><p>Comeback on this small project made in 2022 using Vuejs 2.</p><figure><img alt="3d interaction on the web with vuejs" src="https://cdn-images-1.medium.com/max/1024/1*292H4zMbuV5RBnI4q6IU0Q.png" /></figure><p>This blog post will walk you through some of the main process of building this project using the A-Frame and handsfree.js libraries. I will cover the major steps and considerations, provide code examples, and discuss the user experience challenges for the future of this idea.</p><h3>Let’s Dive In: Starting A-Frame</h3><p>Before we start, let’s get familiar with A-Frame. A-Frame is a web framework for building virtual reality (VR) experiences, which we can use to create 3D environment pretty easily. Feel free to check the documentation and play with the example they provide: <a href="https://aframe.io/">https://aframe.io/</a></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%2528171%252C%2B184%252C%2B195%252C%2B1%2529%26t%3Dmonokai%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%25253Ca-scene%252520fog%25253D%252522type%25253A%252520exponential%25253B%252520color%25253A%252520%252523fff%25253B%252520far%25253A%25252010%25253B%252520density%25253A%2525200.075%252522%25253E%25250A%252520%252520%25253Ca-entity%252520id%25253D%252522rig%252522%252520position%25253D%2525220%2525201%252520-5%252522%25253E%25250A%252520%252520%252520%252520%25253Ca-camera%25253E%25253C%25252Fa-camera%25253E%25250A%252520%252520%25253C%25252Fa-entity%25253E%25250A%252520%252520%25253Ca-entity%252520position%25253D%2525220%2525200%2525200%252522%252520id%25253D%252522rightHand%252522%252520hand-controls%25253D%252522hand%25253A%252520right%25253B%252520handModelStyle%25253A%252520lowPoly%25253B%252520color%25253A%252520%252523ffcccc%252522%25253E%25253C%25252Fa-entity%25253E%25250A%25253C%25252Fa-scene%25253E%25250A&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%252528171%25252C%2B184%25252C%2B195%25252C%2B1%252529%26t%3Dmonokai%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%2525253Ca-scene%25252520fog%2525253D%25252522type%2525253A%25252520exponential%2525253B%25252520color%2525253A%25252520%25252523fff%2525253B%25252520far%2525253A%2525252010%2525253B%25252520density%2525253A%252525200.075%25252522%2525253E%2525250A%25252520%25252520%2525253Ca-entity%25252520id%2525253D%25252522rig%25252522%25252520position%2525253D%252525220%252525201%25252520-5%25252522%2525253E%2525250A%25252520%25252520%25252520%25252520%2525253Ca-camera%2525253E%2525253C%2525252Fa-camera%2525253E%2525250A%25252520%25252520%2525253C%2525252Fa-entity%2525253E%2525250A%25252520%25252520%2525253Ca-entity%25252520position%2525253D%252525220%252525200%252525200%25252522%25252520id%2525253D%25252522rightHand%25252522%25252520hand-controls%2525253D%25252522hand%2525253A%25252520right%2525253B%25252520handModelStyle%2525253A%25252520lowPoly%2525253B%25252520color%2525253A%25252520%25252523ffcccc%25252522%2525253E%2525253C%2525252Fa-entity%2525253E%2525250A%2525253C%2525252Fa-scene%2525253E%2525250A&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/d3111d3ea9841424e73c7d69e5bc7178/href">https://medium.com/media/d3111d3ea9841424e73c7d69e5bc7178/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%2528171%252C%2B184%252C%2B195%252C%2B1%2529%26t%3Dmaterial%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%252520%252520%252520%252520%252520%252520%25253C%2521--%252520Some%252520lights%252520--%25253E%25250A%252520%252520%252520%252520%252520%252520%25253Ca-entity%252520light%25253D%252522type%25253A%252520ambient%25253B%252520color%25253A%252520%252523fff%252522%25253E%25253C%25252Fa-entity%25253E%25250A%252520%252520%252520%252520%252520%252520%25253Ca-entity%252520light%25253D%252522type%25253A%252520directional%25253B%252520color%25253A%252520%252523FFF%25253B%252520intensity%25253A%2525200.6%252522%252520position%25253D%252522-0.5%2525201%2525201%252522%25253E%25253C%25252Fa-entity%25253E%25250A%252520%252520%252520%252520%252520%252520%25253Ca-entity%252520light%25253D%252522color%25253A%252520%252523000%25253B%252520intensity%25253A%2525201%25253B%252522%252520visible%25253D%252522%252522%25253E%25253C%25252Fa-entity%25253E%25250A%252520%252520%252520%252520%252520%252520%25253Ca-entity%252520light%25253D%252522color%25253A%252520%252523000%25253B%252520intensity%25253A%2525201.5%252522%252520position%25253D%2525225%2525205%2525205%252522%25253E%25253C%25252Fa-entity%25253E%25250A%252520%252520%252520%252520%252520%252520%25253Ca-entity%252520light%25253D%252522color%25253A%252520%252523000%25253B%252520intensity%25253A%2525200.5%252522%252520position%25253D%252522-5%2525205%25252015%252522%25253E%25253C%25252Fa-entity%25253E%25250A&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%252528171%25252C%2B184%25252C%2B195%25252C%2B1%252529%26t%3Dmaterial%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%25252520%25252520%25252520%25252520%25252520%25252520%2525253C%252521--%25252520Some%25252520lights%25252520--%2525253E%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%2525253Ca-entity%25252520light%2525253D%25252522type%2525253A%25252520ambient%2525253B%25252520color%2525253A%25252520%25252523fff%25252522%2525253E%2525253C%2525252Fa-entity%2525253E%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%2525253Ca-entity%25252520light%2525253D%25252522type%2525253A%25252520directional%2525253B%25252520color%2525253A%25252520%25252523FFF%2525253B%25252520intensity%2525253A%252525200.6%25252522%25252520position%2525253D%25252522-0.5%252525201%252525201%25252522%2525253E%2525253C%2525252Fa-entity%2525253E%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%2525253Ca-entity%25252520light%2525253D%25252522color%2525253A%25252520%25252523000%2525253B%25252520intensity%2525253A%252525201%2525253B%25252522%25252520visible%2525253D%25252522%25252522%2525253E%2525253C%2525252Fa-entity%2525253E%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%2525253Ca-entity%25252520light%2525253D%25252522color%2525253A%25252520%25252523000%2525253B%25252520intensity%2525253A%252525201.5%25252522%25252520position%2525253D%252525225%252525205%252525205%25252522%2525253E%2525253C%2525252Fa-entity%2525253E%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%2525253Ca-entity%25252520light%2525253D%25252522color%2525253A%25252520%25252523000%2525253B%25252520intensity%2525253A%252525200.5%25252522%25252520position%2525253D%25252522-5%252525205%2525252015%25252522%2525253E%2525253C%2525252Fa-entity%2525253E%2525250A&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/9a12f9d3bc153b84cde6efc2186ee607/href">https://medium.com/media/9a12f9d3bc153b84cde6efc2186ee607/href</a></iframe><h3>Adding Webcam Interaction with handsfree.js</h3><p>Handsfree.js is a library that helps us convert facial and hand gestures into data we can use. The crazy good part of this library is that it comes pretty powerful out of the box and you can also train your own model if you want. We start by initiating handsfree.js in our Vue component.</p><p>doc:<a href="https://handsfreejs.netlify.app/">https://handsfreejs.netlify.app/</a></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%2528171%252C%2B184%252C%2B195%252C%2B1%2529%26t%3Dmonokai%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Dthis.handsfree%252520%25253D%252520new%252520Handsfree%2528%25257B%25250A%252520%252520showDebug%25253A%252520true%25252C%25250A%252520%252520weboji%25253A%252520true%25252C%25250A%252520%252520hands%25253A%252520%25257B%25250A%252520%252520%252520%252520enabled%25253A%252520true%25252C%25250A%252520%252520%252520%252520maxNumHands%25253A%2525202%25252C%25250A%252520%252520%252520%252520minDetectionConfidence%25253A%2525200.7%25252C%25250A%252520%252520%252520%252520minTrackingConfidence%25253A%2525200.7%25250A%252520%252520%25257D%25250A%25257D%2529&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%252528171%25252C%2B184%25252C%2B195%25252C%2B1%252529%26t%3Dmonokai%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Dthis.handsfree%25252520%2525253D%25252520new%25252520Handsfree%252528%2525257B%2525250A%25252520%25252520showDebug%2525253A%25252520true%2525252C%2525250A%25252520%25252520weboji%2525253A%25252520true%2525252C%2525250A%25252520%25252520hands%2525253A%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520enabled%2525253A%25252520true%2525252C%2525250A%25252520%25252520%25252520%25252520maxNumHands%2525253A%252525202%2525252C%2525250A%25252520%25252520%25252520%25252520minDetectionConfidence%2525253A%252525200.7%2525252C%2525250A%25252520%25252520%25252520%25252520minTrackingConfidence%2525253A%252525200.7%2525250A%25252520%25252520%2525257D%2525250A%2525257D%252529&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/f9d94377694b70d34b7622d0af67dc94/href">https://medium.com/media/f9d94377694b70d34b7622d0af67dc94/href</a></iframe><h3>Adding Movement and Control to Our 3D Hand Model</h3><p>Once we have established a 3D scene and initiated handsfree.js, we might want for example to connect the virtual hand model we added to our template before with real hand movements. We use the main loop of handsfree.js to capture real-time webcam data and translate it to the virtual 3D hand model.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%2528171%252C%2B184%252C%2B195%252C%2B1%2529%26t%3Dmonokai%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Dthis.handsfree.use%2528%2527lookHandsfree%2527%25252C%252520%2528%25257B%252520weboji%252520%25257D%2529%252520%25253D%25253E%252520%25257B%25250A%252520%252520...%25250A%252520%252520this.rig.setAttribute%2528%2527rotation%2527%25252C%252520%252560%252524%25257Btween.yaw%25257D%252520%252524%25257Btween.pitch%25257D%252520%252524%25257Btween.roll%25257D%252560%2529%25250A%252520%252520this.rig.setAttribute%2528%2527position%2527%25252C%252520%252560%252524%25257Btween.x%25257D%252520%252524%25257Btween.y%25257D%252520%252524%25257Btween.z%25257D%252560%2529%25250A%25257D%2529%25250A&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%252528171%25252C%2B184%25252C%2B195%25252C%2B1%252529%26t%3Dmonokai%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Dthis.handsfree.use%252528%252527lookHandsfree%252527%2525252C%25252520%252528%2525257B%25252520weboji%25252520%2525257D%252529%25252520%2525253D%2525253E%25252520%2525257B%2525250A%25252520%25252520...%2525250A%25252520%25252520this.rig.setAttribute%252528%252527rotation%252527%2525252C%25252520%25252560%25252524%2525257Btween.yaw%2525257D%25252520%25252524%2525257Btween.pitch%2525257D%25252520%25252524%2525257Btween.roll%2525257D%25252560%252529%2525250A%25252520%25252520this.rig.setAttribute%252528%252527position%252527%2525252C%25252520%25252560%25252524%2525257Btween.x%2525257D%25252520%25252524%2525257Btween.y%2525257D%25252520%25252524%2525257Btween.z%2525257D%25252560%252529%2525250A%2525257D%252529%2525250A&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/d5d617105922a403137d9876c33f6945/href">https://medium.com/media/d5d617105922a403137d9876c33f6945/href</a></iframe><p>When tracking the movements of a user’s head, our webcam provides us with raw data that might be a bit too abrupt for real-time application. It can lead to jittery camera movement if applied directly. To counter this, we use the TweenMax library and play a bit with the number to get the speed we feel confortable with.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%2528171%252C%2B184%252C%2B195%252C%2B1%2529%26t%3Dmaterial%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%252520%252520%252520%252520%252520%252520TweenMax.to%2528tween%25252C%2525201%25252C%252520%25257B%25250A%252520%252520%252520%252520%252520%252520%252520%252520yaw%25253A%252520-rot%25255B0%25255D%252520%252A%2525200.1%25252C%25250A%252520%252520%252520%252520%252520%252520%252520%252520pitch%25253A%252520-rot%25255B1%25255D%252520%252A%2525201%25252C%25250A%252520%252520%252520%252520%252520%252520%252520%252520roll%25253A%252520rot%25255B2%25255D%252520%252A%2525200.4%25252C%25250A%252520%252520%252520%252520%252520%252520%252520%252520x%25253A%252520pos.x%25252C%25250A%252520%252520%252520%252520%252520%252520%252520%252520y%25253A%252520pos.y%25252C%25250A%252520%252520%252520%252520%252520%252520%252520%252520z%25253A%252520pos.z%25250A%252520%252520%252520%252520%252520%252520%25257D%2529&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%252528171%25252C%2B184%25252C%2B195%25252C%2B1%252529%26t%3Dmaterial%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%25252520%25252520%25252520%25252520%25252520%25252520TweenMax.to%252528tween%2525252C%252525201%2525252C%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520yaw%2525253A%25252520-rot%2525255B0%2525255D%25252520%25252A%252525200.1%2525252C%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520pitch%2525253A%25252520-rot%2525255B1%2525255D%25252520%25252A%252525201%2525252C%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520roll%2525253A%25252520rot%2525255B2%2525255D%25252520%25252A%252525200.4%2525252C%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520x%2525253A%25252520pos.x%2525252C%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520y%2525253A%25252520pos.y%2525252C%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520z%2525253A%25252520pos.z%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%2525257D%252529&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/252895e4ce8014df655dad7814ef1998/href">https://medium.com/media/252895e4ce8014df655dad7814ef1998/href</a></iframe><p>You understand it, now we can use the same logic to apply different event to our 3D world using our webcam and the datas we get from handsfree.js</p><h3>Rotating a 3D Model</h3><p>In our Vue.js template, we define a 3D model with its rotation linked to a data. This data will be updated by the handsfree.js library based on the user’s hand movements. This allows the user to interact with the 3D model by moving their hand in front of the webcam (Here we link the rotation of the model to the “finger8X data).</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%2528171%252C%2B184%252C%2B195%252C%2B1%2529%26t%3Dmonokai%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%25253Ca-entity%252520class%25253D%252522clickable%252522%252520%25253Arotation%25253D%252522%2525600%252520%252524%25257Bthis.finger8X%25257D%252560%252522%252520scale%25253D%2525220.05%2525200.05%2525200.05%252522%252520%25253Aposition%25253D%252522%2525600%2525201%252520-7%252560%252522%252520gltf-model%25253D%252522%25252Fstatic%25252Ftotoro.glb%252522%25253E%25253C%25252Fa-entity%25253E%25250A&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%252528171%25252C%2B184%25252C%2B195%25252C%2B1%252529%26t%3Dmonokai%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%2525253Ca-entity%25252520class%2525253D%25252522clickable%25252522%25252520%2525253Arotation%2525253D%25252522%252525600%25252520%25252524%2525257Bthis.finger8X%2525257D%25252560%25252522%25252520scale%2525253D%252525220.05%252525200.05%252525200.05%25252522%25252520%2525253Aposition%2525253D%25252522%252525600%252525201%25252520-7%25252560%25252522%25252520gltf-model%2525253D%25252522%2525252Fstatic%2525252Ftotoro.glb%25252522%2525253E%2525253C%2525252Fa-entity%2525253E%2525250A&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/f862f51baa1ed7a1bac5214d88fd5699/href">https://medium.com/media/f862f51baa1ed7a1bac5214d88fd5699/href</a></iframe><p><strong>Test the project (</strong>⚠️ 2023: Might not work anymore or <strong>Might need 1min to start once you click on start the webcam):</strong></p><p><a href="https://enhanced-web.vercel.app/">https://enhanced-web.vercel.app/</a></p><h3>Conclusion and UX challenges we can already see</h3><p>I made this project purely for fun, and while this approach adds a layer of immersion to the web experience, it’s nice to consider the user experience challenges and what would be needed to be able to really use such a solution online.</p><p>Challenges:</p><ol><li>Unfamiliar Interaction: Users need some time to adapt to this new form of interaction. Clear instructions or an intuitive onboarding process can mitigate this challenge.</li><li>Accessibility: Not all users have a webcam or are able to use hand gestures. We should ensure that the application offers alternative interaction methods.</li><li>Performance: Processing webcam data and rendering 3D models in real-time is resource-intensive. Optimizations and performance considerations are crucial.</li><li>Not everyone is comfortable with the idea of their webcam being accessed by a web application. They might have concerns about their privacy, including worries about being recorded, watched, or monitored without their consent.</li></ol><p>In the end, while creating interactive 3D experiences on the web using a webcam is an exciting frontier, it’s also a project where a lot of improvements needs to be done in order to truly be able to use it in production. I however might keep this idea for specific projects in the future.</p><p>I hope you enjoyed reading this blog post. Let me now your ideas, suggestions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ee281b214d5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using the Intersection Observer API with NUXT to trigger cool CSS animations.]]></title>
            <link>https://medium.com/@anthony.cherbuin/using-the-intersection-observer-api-with-nuxt-to-trigger-cool-ccs-animations-ca7baab709e9?source=rss-2ab40f7ae0e1------2</link>
            <guid isPermaLink="false">https://medium.com/p/ca7baab709e9</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[animation]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[nuxtjs]]></category>
            <category><![CDATA[frontend]]></category>
            <dc:creator><![CDATA[Anthony]]></dc:creator>
            <pubDate>Thu, 28 Jul 2022 12:50:20 GMT</pubDate>
            <atom:updated>2022-08-11T08:40:22.257Z</atom:updated>
            <content:encoded><![CDATA[<h4>Let’s trigger custom CSS transitions when your element is in the viewport</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1kSyGT2IUEOtxFtB" /><figcaption>Photo by <a href="https://unsplash.com/@cgower?utm_source=medium&amp;utm_medium=referral">Christopher Gower</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>The web is already filled with Packages and Libraries to help us, front-end developers, to trigger cool animations when our elements are visible on the viewport. I think about cool small libraries like the “AOS — Animate On Scroll Library” or about more complex one like GSAP and the ScrollTrigger plugin.</p><p>All these are great tools, however theses solutions tends sometimes to be tricky to use with framework like NUXT once you start having Server-side rendering, Caching and Magic happening under the hoods. It can easily make your code a states and nextTick() land mine in order to help you find that single small CSS line in the component that was rendering 5ms too late and was sliding your whole ScrollTrigger starting point 50px to the top.</p><p>That is the kind of think that make you want to quit the office at 2PM to t̶h̶i̶n̶k̶ ̶a̶b̶o̶u̶t̶ ̶y̶o̶u̶r̶ ̶w̶h̶o̶l̶e̶ ̶l̶i̶f̶e̶ ̶a̶n̶d̶ ̶e̶n̶d̶ ̶y̶o̶u̶r̶ ̶d̶e̶v̶e̶l̶o̶p̶e̶r̶ ̶c̶a̶r̶e̶e̶r̶ drink beers. I am not the only one, am I ?</p><p>Well I say it, these animation Libraries are great, but these kind of small problems where not what I wanted to deal with for a dynamic animation Library that I would be re-using through my different projects in the future. It’s when I started looking at a pure JS solution -&gt; The Intersection Observer API.</p><h3>Code</h3><p>So, let’s get started with a new component: The template is basic as it will just possess an attribute and a &lt;slot/&gt; to allow us to use our component with multiple contents.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%2528171%252C%2B184%252C%2B195%252C%2B1%2529%26t%3Dmaterial%26wt%3Dnone%26l%3Dvue%26width%3D680%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%25253Ctemplate%25253E%25250A%252520%252520%25253Cdiv%25250A%252520%252520%252520%252520ref%25253D%252522fadein%252522%25250A%252520%252520%252520%252520class%25253D%252522animate%252522%25250A%252520%252520%25253E%25250A%252520%252520%252520%252520%25253Cslot%252520%25252F%25253E%25250A%252520%252520%25253C%25252Fdiv%25253E%25250A%25253C%25252Ftemplate%25253E&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%252528171%25252C%2B184%25252C%2B195%25252C%2B1%252529%26t%3Dmaterial%26wt%3Dnone%26l%3Dvue%26width%3D680%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%2525253Ctemplate%2525253E%2525250A%25252520%25252520%2525253Cdiv%2525250A%25252520%25252520%25252520%25252520ref%2525253D%25252522fadein%25252522%2525250A%25252520%25252520%25252520%25252520class%2525253D%25252522animate%25252522%2525250A%25252520%25252520%2525253E%2525250A%25252520%25252520%25252520%25252520%2525253Cslot%25252520%2525252F%2525253E%2525250A%25252520%25252520%2525253C%2525252Fdiv%2525253E%2525250A%2525253C%2525252Ftemplate%2525253E&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/1ccff32f03348363045748bdc79b48c2/href">https://medium.com/media/1ccff32f03348363045748bdc79b48c2/href</a></iframe><p>Here is the mounted hook and don’t forget to add the observer state in the data:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%2528171%252C%2B184%252C%2B195%252C%2B1%2529%26t%3Dmaterial%26wt%3Dnone%26l%3Djavascript%26width%3D680%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%252520%252520data%2528%2529%252520%25257B%25250A%252520%252520%252520%252520return%252520%25257B%25250A%252520%252520%252520%252520%252520%252520observer%25253A%252520null%25250A%252520%252520%252520%252520%25257D%25253B%25250A%252520%252520%25257D%25252C%25250A%252520%252520mounted%2528%2529%252520%25257B%25250A%252520%252520%252520%252520const%252520obsOptions%252520%25253D%252520%25257B%25257D%25253B%25250A%252520%252520%252520%252520this.observer%252520%25253D%252520new%252520IntersectionObserver%2528this.inViewport%25252C%252520obsOptions%2529%25253B%25250A%25250A%252520%252520%252520%252520const%252520ELs_inViewport%252520%25253D%252520this.%252524refs.fadein%25253B%25250A%25250A%252520%252520%252520%252520this.observer.observe%2528ELs_inViewport%2529%25253B%25250A%252520%252520%25257D&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%252528171%25252C%2B184%25252C%2B195%25252C%2B1%252529%26t%3Dmaterial%26wt%3Dnone%26l%3Djavascript%26width%3D680%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%25252520%25252520data%252528%252529%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520return%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520observer%2525253A%25252520null%2525250A%25252520%25252520%25252520%25252520%2525257D%2525253B%2525250A%25252520%25252520%2525257D%2525252C%2525250A%25252520%25252520mounted%252528%252529%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520const%25252520obsOptions%25252520%2525253D%25252520%2525257B%2525257D%2525253B%2525250A%25252520%25252520%25252520%25252520this.observer%25252520%2525253D%25252520new%25252520IntersectionObserver%252528this.inViewport%2525252C%25252520obsOptions%252529%2525253B%2525250A%2525250A%25252520%25252520%25252520%25252520const%25252520ELs_inViewport%25252520%2525253D%25252520this.%25252524refs.fadein%2525253B%2525250A%2525250A%25252520%25252520%25252520%25252520this.observer.observe%252528ELs_inViewport%252529%2525253B%2525250A%25252520%25252520%2525257D&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/86221980f227f8a57b5328ea38e760c8/href">https://medium.com/media/86221980f227f8a57b5328ea38e760c8/href</a></iframe><p>You can add options to the observer with the obsOptions object. Properties root / rootMargin / threshold can be defined. It help you to choose for example, at which percentage of the visibility of the element you want to trigger the observer. You’ll find clear and detailed explanations about these in the official documentation: <a href="https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API">https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API</a></p><p>Now, we still need to define the callback for our Observer, we are going to add and remove a class that we’ll be using for the animation :</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%2528171%252C%2B184%252C%2B195%252C%2B1%2529%26t%3Dmaterial%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%252520%252520methods%25253A%252520%25257B%25250A%252520%252520%252520%252520inViewport%2528entries%2529%252520%25257B%25250A%252520%252520%252520%252520%252520%252520entries.forEach%2528%2528entry%2529%252520%25253D%25253E%252520%25257B%25250A%252520%252520%252520%252520%252520%252520%252520%252520entry.target.classList.toggle%2528%2527is-inViewport%2527%25252C%252520entry.isIntersecting%2529%25253B%25250A%252520%252520%252520%252520%252520%252520%25257D%2529%25253B%25250A%252520%252520%252520%252520%25257D%25250A%252520%252520%25257D&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%252528171%25252C%2B184%25252C%2B195%25252C%2B1%252529%26t%3Dmaterial%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%25252520%25252520methods%2525253A%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520inViewport%252528entries%252529%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520entries.forEach%252528%252528entry%252529%25252520%2525253D%2525253E%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520entry.target.classList.toggle%252528%252527is-inViewport%252527%2525252C%25252520entry.isIntersecting%252529%2525253B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%2525257D%252529%2525253B%2525250A%25252520%25252520%25252520%25252520%2525257D%2525250A%25252520%25252520%2525257D&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/495de5037577b8050fedfe294e73a166/href">https://medium.com/media/495de5037577b8050fedfe294e73a166/href</a></iframe><p>We then want to disconnect the observer in the beforeDestroy Hook:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%2528171%252C%2B184%252C%2B195%252C%2B1%2529%26t%3Dseti%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%252520%252520beforeDestroy%2528%2529%252520%25257B%25250A%252520%252520%252520%252520this.observer.disconnect%2528%2529%25253B%25250A%252520%252520%25257D&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%252528171%25252C%2B184%25252C%2B195%25252C%2B1%252529%26t%3Dseti%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%25252520%25252520beforeDestroy%252528%252529%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520this.observer.disconnect%252528%252529%2525253B%2525250A%25252520%25252520%2525257D&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/ebfa56629f843f11e55d2aa8c2df06bc/href">https://medium.com/media/ebfa56629f843f11e55d2aa8c2df06bc/href</a></iframe><p>We can already test if the code work, use your newly created component in your code and see if the is-inviewport class is added to it when scrolling.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%2528171%252C%2B184%252C%2B195%252C%2B1%2529%26t%3Dmaterial%26wt%3Dnone%26l%3Dvue%26width%3D680%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%25253CCustomFadeIn%25253E%25250A%252520%252520%252520%25253Ch2%25253EThis%252520is%252520my%252520h2%25253C%25252Fh2%25253E%25250A%25253C%25252FCustomFadeIn%25253E&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%252528171%25252C%2B184%25252C%2B195%25252C%2B1%252529%26t%3Dmaterial%26wt%3Dnone%26l%3Dvue%26width%3D680%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%2525253CCustomFadeIn%2525253E%2525250A%25252520%25252520%25252520%2525253Ch2%2525253EThis%25252520is%25252520my%25252520h2%2525253C%2525252Fh2%2525253E%2525250A%2525253C%2525252FCustomFadeIn%2525253E&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/c7f3172c47b7c11a308424166a70cbc2/href">https://medium.com/media/c7f3172c47b7c11a308424166a70cbc2/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y-HpV0hI0FrQcO7Ni5Xp3w.gif" /><figcaption>Here is the result when I am scrolling on and out of my h2. The class is added and removed 🎉</figcaption></figure><p>Bravo. We now have a working Intersection Observer. You can test it, it should work even when navigating through the different pages wit Nuxt router and any delay of rendering shouldn’t be a bother anymore as we don’t do any JS height calculation of DOM elements.</p><p>Ok but we want to make fancy stuff right ? So let’s add a small transition to our class called is-inViewport:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%2528171%252C%2B184%252C%2B195%252C%2B1%2529%26t%3Dmaterial%26wt%3Dnone%26l%3Dcss%26width%3D680%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%25253Cstyle%252520lang%25253D%252522postcss%252522%252520scoped%25253E%25250A%25252F%252A%252520We%252520set%252520the%252520default%252520values%252520%252A%25252F%25250A.animate%252520%25257B%25250A%252520%252520transition%25253A%2525201s%25253B%25250A%252520%252520opacity%25253A%2525200%25253B%25250A%252520%252520transform%25253A%252520translate3d%25280%25252C%25252050px%25252C%2525200%2529%25253B%25250A%25257D%25250A%25250A.animate.is-inViewport%252520%25257B%25250A%252520%252520opacity%25253A%2525201%25253B%25250A%252520%252520transform%25253A%252520translate3d%25280%25252C%2525200%25252C%2525200%2529%25253B%25250A%25257D%25250A%25253C%25252Fstyle%25253E&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%252528171%25252C%2B184%25252C%2B195%25252C%2B1%252529%26t%3Dmaterial%26wt%3Dnone%26l%3Dcss%26width%3D680%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%2525253Cstyle%25252520lang%2525253D%25252522postcss%25252522%25252520scoped%2525253E%2525250A%2525252F%25252A%25252520We%25252520set%25252520the%25252520default%25252520values%25252520%25252A%2525252F%2525250A.animate%25252520%2525257B%2525250A%25252520%25252520transition%2525253A%252525201s%2525253B%2525250A%25252520%25252520opacity%2525253A%252525200%2525253B%2525250A%25252520%25252520transform%2525253A%25252520translate3d%2525280%2525252C%2525252050px%2525252C%252525200%252529%2525253B%2525250A%2525257D%2525250A%2525250A.animate.is-inViewport%25252520%2525257B%2525250A%25252520%25252520opacity%2525253A%252525201%2525253B%2525250A%25252520%25252520transform%2525253A%25252520translate3d%2525280%2525252C%252525200%2525252C%252525200%252529%2525253B%2525250A%2525257D%2525250A%2525253C%2525252Fstyle%2525253E&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/474e94aeda060b14eacd37256d58e8c3/href">https://medium.com/media/474e94aeda060b14eacd37256d58e8c3/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/926/1*PdQYcxXn969Ob9gduBy6ww.gif" /><figcaption>Result</figcaption></figure><p>You now have a working lightweight generic transition you can use on all your components. Isn’t that nice ? You can customize the CSS all you want and be creative with it.</p><h3>Bonus tip</h3><p>It would be great to trigger the animation when scrolling down, but not re-launch it when scrolling up don’t you think ? In order to do that you can update the callback function and calculate the scroll direction with:</p><pre>entry.boundingClientRect.y</pre><p>It’s my first post, if this interest you tell me and I will try to do a post about it.</p><h3>References</h3><p><a href="https://stackoverflow.com/questions/27462306/css3-animate-elements-if-visible-in-viewport-page-scroll/27462500#27462500">CSS3-Animate elements if visible in viewport (Page Scroll)</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ca7baab709e9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>