author avatar

iffyuva

Mon Oct 23 2023

One liner for adding a delay in Typescript: await new Promise((r) => setTimeout(r, 2000));

author avatar

sujay

Sat Oct 21 2023

Difference between const and final in Dart • Even though both const and final cannot be reassigned, there is a subtle difference between them. • const variables are used for compile-time constants whereas final variables are used for run-time constants.

const current_time = new DateTime.now() // DON'T do it as the value is computed at run time
const name = 'Rahul' // DO it as the value is known at compile time

• When reading from database or reading from a file, the values won't be known at compile time. Use final in such cases

author avatar

soniya.rayabagi

Fri Oct 20 2023

figured out how we can use gitignore to add the .DS_STORE files into it by deleting the ds.store file first , and then using echo ".DS_Store" >> .gitignore to add the .ds_store file.

author avatar

soniya.rayabagi

Fri Oct 20 2023

Using git url to clone repo instead of https will not ask password on every git push/pull

author avatar

soniya.rayabagi

Fri Oct 20 2023

figured out how we can use gitignore to add the DS.STORE files into it by deleting the ds.store file first and using echo ".DS_Store" >> .gitignore to add the file.

author avatar

soniya.rayabagi

Thu Oct 12 2023

Using git url to clone repo instead of https will not ask password on every git push/pull

author avatar

rishav.raj

Thu Oct 05 2023

I've have a radio input in a React Hook form and attempted to pass a boolean value, however when i submit the form, i receive the typeof value as a string. Knowing that RHF has valueAsNumber to convert it as number. I thought that setValueAs was a generic way to allow any conversion but I can't make it work.

I learn how to extract a boolean value from a RHF radio input.

The setValueAs approach, which I have previously tried, only functions with text input (such as type="text" or type="number"). Even if the value for a radio button is a string, it doesn't function.

In order to fix it, a Controller component can be used.

Solution:-

      <Controller
            defaultValue={false}
            control={control}
            name="booking_for_someone"
            render={({ field: { onChange, onBlur, value, ref } }) => (
              <label className="booking-for-someone">
                <span className="f-semibold">{t("I'm Booking For")}</span>
                <div>
                  <input
                    type="radio"
                    onBlur={onBlur}
                    onChange={() => onChange(false)}
                    checked={value === false}
                    inputRef={ref}
                    id="myself"
                  />
                  <label
                    htmlFor="myself"
                   >
                    {t("Myself")}
                  </label>
                </div>
                <div >
                  <input
                    type="radio"
                    className="w-16 h-16 rounded-full accent-blue"
                    onBlur={onBlur}
                    onChange={() => onChange(true)}
                    checked={value === true}
                    inputRef={ref}
                    id="someone-else"
                  />
                  <label
                    htmlFor="someone-else"
                   >
                    {t("Someone Else")}
                  </label>
                </div>
              </label>
            )}
          />

Thanks :slightly_smiling_face:

author avatar

ashwanikumarjha

Thu Oct 05 2023

Unsubscribe Feature when Email Service Provider is AWS SES

AWS SES List Management

• AWS SES provides built-in feature for managing email subscribers and their subscription preferences. This includes creating contact lists and topics, and enabling unsubscribe functionality directly in our emails. • We need to create separate topics for different types of emails: To handle different types of emails like verification links, subscription updates, marketing etc. we can create separate topics for each type of email. This allows us to manage the subscription preferences for each type of email separately. • We need to Include the {{amazonSESUnsubscribeUrl}} placeholder in our emails: AWS SES will automatically replace the {{amazonSESUnsubscribeUrl}} placeholder in the email with the actual unsubscribe URL. • When a user clicks on this link, they will be taken to an unsubscribe landing page hosted by AWS, where they can choose to opt-out of receiving emails for a specific topic or all topics. • AWS SES will handle the process of updating the user's subscription status when they opt-out of a topic. The next time when our system tries to send an email to that user for the opted-out topic, AWS SES will not allow the email to be sent. • Ensure important emails are not affected: To ensure that users can still receive important emails like OTP verification and password reset emails, even after they opt-out of other emails, we can use separate contact lists and topics for these types of emails or we should not pass ListManagementOptions in these emails.

{
  "Destination": {
    "ToAddresses": ["user@example.com"]
  },
  "Message": {
    "Body": {
      "Html": {
        "Charset": "UTF-8",
        "Data": "<body> // Email content... <p>If you no longer wish to receive our emails, please <a href=" {{amazonSESUnsubscribeUrl}}">unsubscribe</a></p></body>"
      }
    },
    "Subject": {
      "Charset": "UTF-8",
      "Data": "Email subject"
    }
  },
  "Source": "sender@example.com",
  "ListManagementOptions": {
    "ContactListName": "contact_list_name",
    "TopicName": "Marketing"
  }
}
author avatar

ayushsrivastava

Wed Oct 04 2023

in ruby if we have a variable called a = “HELLO” and then we assign it to a new variable b = a it does not create a deep copy of the string "Hello" stored in a. Instead, it creates a new variable b that references the same string object in memory as a. Both a and b will point to the same memory location, which means they will hold the same value and any changes made through one variable will be reflected in the other.

so if we do

b.upcase!

it will return

puts a  # Output: "HELLO"
puts b  # Output: "HELLO"

If we want to create a separate copy of the string, we can use the dup method or string manipulation methods to create a new string object with the same content.

author avatar

satya

Tue Oct 03 2023

copying mysql dump file to local database. Note: please create your db first if you don't have one

mysql> use your_local_db;
mysql> source your_db_backup_dump.sql;

Showing 25 to 27 of 66 results