r/webdev - How to create an inline response tool for website

How to create an inline response tool for website : webdev

I am an absolute newbie in website development and was puzzled by how I can add this element to my website.

So, I want to create an element where the visitor can type in an answer, and then the answer gets checked against the correct answer and if the visitor’s answer is wrong then the website displays the correct answer.

I had tried searching for blogposts or articles on google that can help me, but they all state about quiz builders and typeforms; whereas, I simply want to make my website more interactive by having this responsive one-word Q&A element.

I’ve made a simple diagram to help illustrate my query.

r/webdev - How to create an inline response tool for website

Thank you for your time.

Source link

r/webdev - [Showoff Saturday] - I built a chrome extension to offset your Amazon deliveries

[Showoff Saturday] – I built a chrome extension to offset yo…

Hello everyone!

Allow me to introduce you to CarbonCroc

We are a chrome extension that allows you to offset the carbon footprint of your Amazon deliveries. If there is enough interest we will be expanding to other marketplaces in the future.

We are currently at the MVP phase so any and all feedback would be appreciated!

I developed our website using Next JS and the extension itself using a great react boilerplate project you can find here.

If you have any questions about how it works you can visit our FAQ or I’d be happy to answer any questions as well.

Thank you!

r/webdev - [Showoff Saturday] - I built a chrome extension to offset your Amazon deliveries

Source link

Where to download this font for free?

Where to download this font for free?

Where to download this font for free?

I'm looking to get this font or if someone is open for an exchange, I have some free commercial fonts and some FontBundle promos for this specific font.


submitted by /u/Sky_Saga

Source link

r/webdev - Project became too big for me !

Project became too big for me ! : webdev

I asked on another subreddit about what design patterns should I use, and people told me not to focus on that topic and actually start building something, I went for a gym system, where users can sign up online and then there’s a manager that can modify, delete and see these users, I spent a good month on this, setting up a decent design and coding the backend and also done authorization and authentication both on backend and front end, after setting up all these, I thought “yaaay I’m almost done” but when looking at the backend code that I wrote I realized I didn’t implement on the front end the manager interface to edit users, edit/add/delete memberships, update users and I didn’t even complete the Dashboard Interface YET, this is getting really overwhelming and I’m not motivated to go through it anymore, I learnt a lot of things building the smaller portion of this, but it feels like so much effort now. I don’t know what to do now, Should I start a new project that is actually fun (I’ve had a dating app in mind) or should I go through it anyways.

Here are couple screenshots of what I have :

r/webdev - Project became too big for me !

landing page, has a lot of other stuff

r/webdev - Project became too big for me !
r/webdev - Project became too big for me !
r/webdev - Project became too big for me !

this is a template that I’m slowly editing

Source link

Cloudinary Fetch with Eleventy (Respecting Local Development...

Cloudinary Fetch with Eleventy (Respecting Local Development…

This is about a wildly specific combination of technologies — Eleventy, the static site generator, with pages with images on them that you ultimately want hosted by Cloudinary — but I just wanna document it as it sounds like a decent amount of people run into this situation.

The deal:

  • Cloudinary has a fetch URL feature, meaning you don’t actually have to learn anything (nice!) to use their service. You have to have an account, but after that you just prefix your images with a Cloudinary URL and then it is Cloudinary that optimizes, resizes, formats, and CDN serves your image. Sweet. It’s not the only service that does this, but it’s a good one.
  • But… the image needs to be on the live public internet. In development, your image URLs probably are not. They’re likely stored locally. So ideally we could keep using local URLs for images in development, and do the Cloudinary fetching on production.

Multiple people have solved this in different ways. I’m going to document how I did it (because I understand it best), but also link up how several other people have done it (which might be smarter, you be the judge).

The goal:

  • In development, images be like /images/image.png
  • In production, images be like https://res.cloudinary.com/css-tricks/image/fetch/w_1200,q_auto,f_auto/https://production-website.com/images/image.png

So if we were to template that (let’s assume Nunjucks here as it’s a nice templating language that Eleventy supports), we get something like this psuedo-code:

  alt="Don't screw this up, fam."
Development Production
{{CLOUDINARY_PREFIX}} “” “https://res.cloudinary.com/css-tricks/image/fetch/w_1200,q_auto,f_auto/”
{{FULLY_QUALIFIED_PRODUCTION_URL}} “” “https://production-website.com”
{{RELATIVE_IMAGE_URL}} “/images/image.jpg” “/images/image.jpg”

The trick then is getting those… I guess we’ll call them global variables?… set up. It’s probably just those first two. The relative image path you’d likely just write by hand as needed.

Eleventy has some magic available for this. Any *.js file we put in a _data folder will turn into variables we can use in templates. So if we made like /src/_data/sandwiches.js and it was:

module.exports = {
  ham: true

In our template, we could use {{sandwiches.ham}} and that would be defined {{true}}.

Because this is JavaScript (Node), that means we have the ability to do some logic based on other variables. In our case, some other global variables will be useful, particularly the process.env variables that Node makes available. A lot of hosts (Netlify, Vercel, etc.) make “environment variables” a thing you can set up in their system, so that process.env has them available when build processes run on their system. We could do that, but that’s rather specific and tied to those hosts. Another way to set a Node global variable is to literally set it on the command line before you run a command, so if you were to do:

SANDWICH="ham" eleventy

Then process.env.SANDWICH would be ham anywhere in your Node JavaScript. Combining all that… let’s say that our production build process sets a variable indicating production, like:

PROD="true" eleventy

But on local development, we’ll run without that global variable. So let’s make use of that information while setting up some global variables to use to construct our image sources. In /src/_data/images.js (full real-world example) we’ll do:

module.exports = {

    process.env.PROD === 'true' 
      ? 'https://coding-fonts.css-tricks.com' 
      : '',

    process.env.PROD === 'true'
      ? 'https://res.cloudinary.com/css-tricks/image/fetch/w_1600,q_auto,f_auto/'
      : ''


You could also check process.env.CONTEXT === 'deploy-preview' to test for Netlify deploy preview URLs, in case you want to change the logic there one way or the other.

Now in any of our templates, we can use {{images.imageLocation}} and {{images.urlPrefix}} to build out the sources.

  alt="Useful alternative text."

And there we go. That will be a local/relative source on development, and then on production, it becomes this prefixed and full qualified URL from which Cloudinary’s fetch will work.

Now that it’s on Cloudinary, we can take it a step further. The prefix URL can be adjusted to resize images, meaning that even with just one source image, we can pull off a rather appropriate setup for responsive images. Here’s that setup, which makes multiple prefixes available, so they can be used for the full syntax.

The end result means locally relative image in development:

The multiple versions are a lie in development, but oh well, srcset is kind of a production concern.

…and Cloudinary fetch URLs in production:

Other People’s Ideas

Phil was showing off using Netlify redirects to do this the other day:

Then the trick to local development is catching the 404’s and redirecting them locally with more redirects.

If hand-crafting your own responsive images syntax is too big of a pain (it is), I highly recommend abstracting it. In Eleventy-land, Nicolas Hoizey has a project: eleventy-plugin-images-responsiver. Eric Portis has one as well, eleventy-respimg, which specifically uses Cloudinary as I have here.

Proving this stuff has really been on people’s minds, Tim Kadlec just blogged “Proxying Cloudinary Requests with Netlify.” He expands on Phil’s tweet, adding some extra performance context and gotchas.

Source link

publisher subject

Observer Pattern in .NET – DZone Web Dev


I have previously written a few posts about delegates, .NET Events, Events Args to show that similar to real-world events, we can use this concept in our code and how useful they are in certain scenarios. This post will see that those types are a good candidate for implementing the observer pattern without doing anything extra. We will learn some terminologies and see a working example as well.

If you are new to .NET Events, I will suggest reading my previous posts on the topic, and then discussed in this post will be easier to follow. So let’s talk about observer pattern:

The observer pattern is simply a publish/subscribe relationship.

  • The publisher is also referred to as the subject that we want to watch for a state change.
  • Then we have one or more Subscribers, also referred to as Observers. These are the dependent objects that will be notified when the state changes.

Real-World Observer

On Twitter, Follow capability allows up to setup an observer relationship whenever I follow someone on Twitter, whenever that person’s state changes (by adding a tweet), I notified it. Not only me, everyone who is the follower gets notified.

It turns out that if you’ve used an event handler in .NET, you have used an observer pattern.

Consider Observers When?

  • One object is dependent on the changes in another object.
  • Changing in one Object requires changes to many others (other objects are monitoring one object).
  • When changes to an object should allow notification to others without any knowledge of them.

Intent and Structure

publisher subject


  • Creates a separation b/w the subject & observer
  • Allow multiple observers to react to changes to a single object.


  • The subject provides a way to Register, Un-Register, and Notify.
  • Observer provides a way to Update.

Application Code

Before we dive into the observer pattern, let’s see the current code. I created an Account class with two methods Deposit and Withdrew. Account class also has a balance property, which changes when we either deposit or withdraw the amount. Find below the implementation of Account.

public class account

Next, I have the following code in the Main method:
static void

Output when running this code:

account balance

Our application code is doing some basic work, and it is a very typical C# code.

New Requirements

Let’s imagine that we have new requirements as follows:

  • Send Email whenever balance changes.
  • Log balance changes

As you can see that these requirements fit the need for an observer pattern. If we consider our Account class as a subject, we can raise notifications whenever balance changes. On the other end, Logger and Emailer can be considered observers interested in this balance change information for their operations.

The event, EventHandlers, and Custom EventArgs

We can use built-in .NET Types to implement observer pattern easily if you are new to these concepts. You can read about those in my previous posts on the same topic.

To raise notifications from the Account class, I am using built-in EventHandler<T> from .NET. Then I updated the Deposit and Withdrew method to raise the events along with event-data.


I could have put the event raise code in the property-setter of Balance as well (to avoid duplicated code, but for now, it is ok). So our Account class is now a subject or source of the event, or you can call it a publisher.


Here is the custom EventArgs class. This class is used to pass data when an event is raised.

public class


Now, on the receiving end, I added two classes to represent the subject’s observers (or consumers). Here is the code:


Notice that event wiring or registration is being set up in the constructor of these classes. The rest of the code is straightforward and currently writing to console to simulate the operation.

So, now we have our subject, which raises an event (along with event-data) when balance changes, and then two observers are setup to listen for these events. With all this code in place, let’s update the Main method to see all this in action. Here is the updated code for the Main method:

static void

Now, when I run the application. The following output shows that events are fired from the subject, and then observers are notified and processing those events. 

sending email

Now, I will call deposit and withdraw methods multiple times to see the results:

static void

Here is the output:

sending email


In this post, we saw one implementation of the observer pattern, which uses built-in .NET types. We learned a few terminologies, e.g., what is subject, what is observed, and learn that those are sometimes called publishers, subscribers, consumers, etc. If you have some comments or questions, feel free to ask. You can access the code on this URL. Till next time, Happy Coding.

Source link