Fueling Curiosity, One Insight at a Time
At Codemancers, we believe every day is an opportunity to grow. This section is where our team shares bite-sized discoveries, technical breakthroughs and fascinating nuggets of wisdom we've stumbled upon in our work.
Oct 5, 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
• We need to Include the
• 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
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": " // Email content... If you no longer wish to receive our emails, please unsubscribe
"
}
},
"Subject": {
"Charset": "UTF-8",
"Data": "Email subject"
}
},
"Source": "sender@example.com",
"ListManagementOptions": {
"ContactListName": "contact_list_name",
"TopicName": "Marketing"
}
}
Ashwani Kumar Jha
Senior System Analyst
Oct 4, 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
so if we do
it will return
If we want to create a separate copy of the string, we can use the
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.Ayush Srivastava
System Analyst
Oct 3, 2023
copying mysql dump file to local database.
Note: please create your db first if you don't have one
Note: please create your db first if you don't have one
mysql> use your_local_db;
mysql> source your_db_backup_dump.sql;
Satya
Sep 29, 2023
When sending an email, a short snippet which is taken from the first few lines of our email content is shown right next to the email subject. This is called the preview text and can be a powerful tool for increasing the open rate.
However, the first few lines of our email might not always provide an accurate summary of what our email is about and this become important when working with HTML email template where first few lines might include elements like image alt text or navigational links.
To solve this problem, MJML have the
However, the first few lines of our email might not always provide an accurate summary of what our email is about and this become important when working with HTML email template where first few lines might include elements like image alt text or navigational links.
To solve this problem, MJML have the
mj-preview
tag. This tag allows us to customize the preview text that appears in the recipient's inbox.
Check out our latest deals!
Ashwani Kumar Jha
Senior System Analyst
Sep 27, 2023
When we create a branch and make numerous commits to it, and later decide to start fresh by removing those previous commits, we can do this by following these steps in the terminal:
1. Delete the branch locally:
2. Recreate the same branch from the ‘main’ branch:
3. Commit and push your changes:
By using the
1. Delete the branch locally:
git branch -D
2. Recreate the same branch from the ‘main’ branch:
git checkout main
git checkout -b
3. Commit and push your changes:
git commit -m "Your commit message"
git push origin -f
By using the
-f
flag in the ‘git push’ command, you force-push the changes to the branch on the remote repository. This erases the previous commits from the branch, giving you a fresh start with your new commit.”Nisanth
Sep 26, 2023
Namecheap allows you to modify DNS record types without deleting exiting records. Example an A record can be changed to CNAME record on the fly without deleting existing A record. This helps in zero downtime deployments.
Ananth
Sep 22, 2023
while connecting rails local server with the client , if you get this error as mentioned below
this means your postgres server is not connected to the host at address
So that file must be present inside your
it will look like this
So from here we need the path that is present after the
Now we can cd into the path. Once we do that we need to do
it will open the file and if you see that there is no host present , we need to write the following lines and press
then start your postgres server for the desired database and you will successfully connect local rails server with your client.
could not connect to server: Operation timed out
Is the server running on host "10.220.0.15" and accepting
TCP/IP connections on port 5432?
this means your postgres server is not connected to the host at address
10.220.0.15
. In order to see if it is connected or not we need to check the pg_hba.conf
file.So that file must be present inside your
postgresql
directory . In order to get the path we can do ps aux | grep postgres
it will look like this
...
user 46455 0.0 0.0 409138608 1248 ?? Ss 13Sep23 0:00.82 postgres: checkpointer
user 46372 0.0 0.0 408998640 2192 ?? S 13Sep23 0:16.79 /opt/homebrew/opt/postgresql@13/bin/postgres -D /opt/homebrew/var/postgresql@13
So from here we need the path that is present after the
-D
flag. So in my case it my path is /opt/homebrew/var/postgresql@13
Now we can cd into the path. Once we do that we need to do
ls
and we can find the file called pg_hba.conf
. Then we need to run nano pg_hba.conf
it will open the file and if you see that there is no host present , we need to write the following lines and press
Ctrl + O
then click Enter
and Ctrl +X
host YOUR_DB_NAME YOUR_USER_NAME 10.220.0.15/32 md5
then start your postgres server for the desired database and you will successfully connect local rails server with your client.
Satya
Sep 22, 2023
HTTP/1 (1996) vs HTTP/2 (2015)
1. HTTP/1 req/res are sent sequentially, one after another. This means that if you have several resources (e.g., photos, stylesheets, scripts) to load for a single web page, each resource requires a separate connection, which can lead to latency and slower page loading times. Where as HTTP/2 introduces request multiplexing, which allows several requests and responses to be delivered and received in simultaneously over a single connection and thus minimising the latency and speeds up the loading of multi-resource web pages.
2. HTTP/1 headers are uncompressed. This can result in significant latency in the form of redundant header data being delivered with each request and response. HTTP/2, on the other hand, employs header compression (HPACK) to minimise the size of headers, hence reducing the amount of data delivered and enhancing efficiency.
3. HTTP/1 does not have built-in capability for prioritising requests. All requests are treated identically, which might lead to poor performance for essential resources. Whereas HTTP/2 supports stream prioritisation. This means that more critical resources can be prioritised, resulting in faster loading and a better user experience.
4. HTTP/1 requires the server to wait until the client requests additional resources before sending them. This can result in inefficiencies because the server may be aware of which resources will be required but must wait for the client to request them. HTTP/2, on the other hand, introduces server push, which allows the server to provide resources to the client that it expects the client will need. This minimises round-trip times and speeds up page loading.
5. I checked couple of websites, some use HTTP/1.1 and most of them use HTTP/2. Also HTTP/3 has been introduced in 2022
1. HTTP/1 req/res are sent sequentially, one after another. This means that if you have several resources (e.g., photos, stylesheets, scripts) to load for a single web page, each resource requires a separate connection, which can lead to latency and slower page loading times. Where as HTTP/2 introduces request multiplexing, which allows several requests and responses to be delivered and received in simultaneously over a single connection and thus minimising the latency and speeds up the loading of multi-resource web pages.
2. HTTP/1 headers are uncompressed. This can result in significant latency in the form of redundant header data being delivered with each request and response. HTTP/2, on the other hand, employs header compression (HPACK) to minimise the size of headers, hence reducing the amount of data delivered and enhancing efficiency.
3. HTTP/1 does not have built-in capability for prioritising requests. All requests are treated identically, which might lead to poor performance for essential resources. Whereas HTTP/2 supports stream prioritisation. This means that more critical resources can be prioritised, resulting in faster loading and a better user experience.
4. HTTP/1 requires the server to wait until the client requests additional resources before sending them. This can result in inefficiencies because the server may be aware of which resources will be required but must wait for the client to request them. HTTP/2, on the other hand, introduces server push, which allows the server to provide resources to the client that it expects the client will need. This minimises round-trip times and speeds up page loading.
5. I checked couple of websites, some use HTTP/1.1 and most of them use HTTP/2. Also HTTP/3 has been introduced in 2022
Syed Sibtain
System Analyst
Sep 20, 2023
When your
Gemfile.lock
says BUNDLED WITH 2.2.4
, but while doing bundle -v
or starting your rails server or rails console you get an error saying"You must use Bundler 2 or greater with this lockfile."
. We can resolve that by running gem update --system
.Satya
Sep 15, 2023
There are a couple of performance metrics used to measure the loading and rendering speed of web pages.
1: First paint: It refers to the point in time when the browser starts rendering first pixels on screen. It does not needs to be recognisable. First Paint can include background colors or simple styling changes and doesn't guarantee that any content or text is visible yet.
2: First Contentful Paint (FCP): First Contentful Paint occurs when the browser renders the first piece of content from the DOM (Document Object Model). It can be text, an image, etc usually referring to something meaningful on the screen.
3. First Meaningful Paint (FMP): It refers to the point where a user can identify and understand the content that is loading. Usually includes layout changes the the font are loaded as well. FMP is depreciated.
4. Largest Contentful Paint (LCP): It measures the time it takes for the largest content element (such as an image, text block, or video) within the viewport to become fully visible and rendered on the user's screen. A webpage should have a LCP of 2.5 seconds or less.
5. Speed Index: It simply refers to how quickly the visible content of a web page is painted or rendered during the loading process. It depends on size of the viewport (mobile/desktop). Lower the score, the better it is.
1: First paint: It refers to the point in time when the browser starts rendering first pixels on screen. It does not needs to be recognisable. First Paint can include background colors or simple styling changes and doesn't guarantee that any content or text is visible yet.
2: First Contentful Paint (FCP): First Contentful Paint occurs when the browser renders the first piece of content from the DOM (Document Object Model). It can be text, an image, etc usually referring to something meaningful on the screen.
3. First Meaningful Paint (FMP): It refers to the point where a user can identify and understand the content that is loading. Usually includes layout changes the the font are loaded as well. FMP is depreciated.
4. Largest Contentful Paint (LCP): It measures the time it takes for the largest content element (such as an image, text block, or video) within the viewport to become fully visible and rendered on the user's screen. A webpage should have a LCP of 2.5 seconds or less.
5. Speed Index: It simply refers to how quickly the visible content of a web page is painted or rendered during the loading process. It depends on size of the viewport (mobile/desktop). Lower the score, the better it is.
Syed Sibtain
System Analyst
Showing 39 to 41 of 80 results
Ready to Build Something Amazing?
Codemancers can bring your vision to life and help you achieve your goals
- Address
2nd Floor, Zee Plaza,
No. 1678, 27th Main Rd,
Sector 2, HSR Layout,
Bengaluru, Karnataka 560102 - Contact
hello@codemancers.com
+91-9731601276