How to Declare Your Love Like a Programmer ❤️ (2024)

/ #Nodejs
How to Declare Your Love Like a Programmer ❤️ (1)
Florin Pop
How to Declare Your Love Like a Programmer ❤️ (2)

Today is Valentines Day! ?

How nice would it be if you sent a Romantic Message every hour to your loved one? But even better...

How awesome would it be to do it automatically using a Node.js script? We are after all... programmers, right? ?

In this short tutorial I'm going to show you how to do it.

P.S. For the lazy ones out there, here is a Video Tutorial:

Create a CRON job

First, we need to create a CRON job which will run a function every hour.

For that, let's install the node-cron package into our NodeJS app:

npm install node-cron

Next, we're going to schedule a function to run every hour:

const cron = require('node-cron');cron.schedule('0 * * * *', () => {sendMessage();});

Perfect. We don't have the sendMessage() function yet, but we'll create it later.

Also, in case you don't know how the CRON string works, here is an awesome website where you can test it out.

Basically '0 * * * *' means: Run every hour at 0 minutes, so it will run at: 00:00, 01:00, 02:00, etc... You get the point!

Connect to Twilio

We need a Twilio acount, so head over to Twilio.com and create one. You need to verify your email address and also verify the number you want to send the message to. (I had to "steal" my wife's phone in order to verify the number ?)

In there they'll ask you a couple of questions like: "What programming language are you using?" You can pick Node.js and then you'll end up on the /console page.

Here you'll get the ACCOUNT SID and AUTH TOKEN. We need these to call the Twilio API so we are going to store them inside a config.js file.

Warning: Do not share the AUTH TOKEN. This is a secret key so we're going to store them inside this "secret" config.js file.

Great.

The next thing will be to create a Trial Number (you can find the button on the /console page). This number will be used to send the messages FROM.

Now that we have everything in place, let's go back to our code!

We need to install the Twilio package: npm install twilio and we need to use the data we stored inside the ./config.js file.

Along with the ACCOUNT_SID and AUTH_TOKEN we can also store the PHONE_NR of our loved one as we are going to use this to tell Twilio where to send the message TO.

Let's do that and also let's create the sendMessage() function, which will... send a message ?.

const config = require('./config');const accountSid = config.ACCOUNT_SID;const authToken = config.AUTH_TOKEN;const client = require('twilio')(accountSid, authToken);function sendMessage() {client.messages.create({body: 'Your Message here',from: '+19166191713',to: config.PHONE_NR}).then(message => {console.log(message);});}

You can see that the client.messages.create() function required three things:

  1. The body/the message
  2. The FROM number (this is the trial number created above)
  3. The TO number (this is the number we want to send the message to)

Get the messages

We need a list of 24 romantic messages, so for that let's create a messages.js file and put all the messages in there inside an array.

module.exports = [`If I could give you one thing in life, I'd give you the ability to see yourself through my eyes, only then would you realize how special you are to me.`,`If you were a movie, I'd watch you over and over again.`,`In a sea of people, my eyes always search for you.`];

I only added 3 messages above, but you can fill the array up until you get to 24 messages.

Combine everything

Now that we have all the 3 components:

  • the CRON job
  • the Twilio sendMessage() call
  • the messages

We can combine them into the final code:

const cron = require('node-cron');const config = require('./config');const accountSid = config.ACCOUNT_SID;const authToken = config.AUTH_TOKEN;const client = require('twilio')(accountSid, authToken);const messages = require('./messages');const currentMessage = 0;function sendMessage() {client.messages.create({body: messages[currentMessage],from: '+19166191713',to: config.PHONE_NR}).then(message => {currentMessage++;console.log(message);});}cron.schedule('0 * * * *', () => {console.log('Message sent!');sendMessage();});

You can see that I added a currentMessage counter which will be incremented every time we send a message, this way we're going to loop over the entire array of messages.

That's it! ?

Now you can run the script and it'll send a romantic message, every hour, to your loved one!

Happy Valentine's! ?

Originally posted on www.florin-pop.com

ADVERTIsem*nT

ADVERTIsem*nT

ADVERTIsem*nT

How to Declare Your Love Like a Programmer ❤️ (3)
Florin Pop

JavaScript enthusiast, Front-end developer, Blogger & YouTuber

If you read this far, thank the author to show them you care.

Learn to code for free. freeCodeCamp's open source curriculum has helped more than 40,000 people get jobs as developers. Get started

ADVERTIsem*nT

How to Declare Your Love Like a Programmer ❤️ (2024)

FAQs

How do programmers say I love you? ›

In computers, information is stored in binary code, which consists of only two symbols: 0 and 1. To express “I Love You” in binary, we convert the text into its binary representation: I Love You: 01001001 00100000 01001100 01101111 01110110 01100101 00100000 01011001 01101111 01110101.

How do you express love in code? ›

Top 15 Love Code Word
  1. ILYFTBOH. Code Word: ILYFTBOH. Meaning: I Love You From The Bottom Of My Heart. ...
  2. ILYFTBOMS. Code Word: ILYFTBOMS. Meaning: I Love You From The Bottom Of My Soul. ...
  3. ILYMTAWCS. Code Word: ILYMTAWCS. Meaning: I Love You More Than Any Word Can Say. ...
  4. INWY. Code Word: INWY. ...
  5. ILWY. Code Word: ILWY.

What is the code language of I Love You? ›

Well, the number 143 is the code for saying "I love you". The number 14344 is a numeronym representing the number of letters in each word of the phrase "I love you very much." "I love you very much" is also abbreviated as ILYVM. There are several other numbers in cyber terms that are used to express love.

What is a code word for love? ›

143:I love you. 1432: I love you too. 14324*7: I love you 24 hours seven days a week. 143224: I love you, today, tomorrow, and forever. 14344: I love you very much.

What does 14344 mean in love? ›

The number '14344' is a type of code for 'Love'. 14344 means 'I love you very much'. Yes, it basically is the extended version of the famous 143, which means 'I love you'. The numerical representation '14344', of the phrase 'I love you very much', is in actuality an abbreviation.

What does 607 mean in text? ›

607: I Miss You.

What are good secret code words? ›

Although code words used will vary, some common examples are:
  • Charlie, Charlie, Charlie – security threat on the boat.
  • Echo, Echo, Echo – imminent danger ahead e.g. collision with another ship, high winds at port.
  • Red Party – fire onboard.
  • Operation Bright Star – medical emergency, urgent assistance required.
Feb 14, 2023

What does 459 mean? ›

"I Love You (phone keyboard layout for ILY)" is the most common definition for 459 on Snapchat, WhatsApp, Facebook, Twitter, Instagram, and TikTok.

What is 14344? ›

14344 means "I Love You Very Much". Here, we are counting the number of alphabets in each word. I = 1 letter, LOVE = 4 letters, YOU = 3 letters, VERY = 4 letters and MUCH = 4 letters. So, whenever you want to say I Love You Very Much, you can express it as 14344. 2Thank You.

How do you say I love you in 14 languages? ›

How To Say “I Love You” In Different Languages
  1. English: I love you (i love you)
  2. French: Je t'aime (juh tehm)
  3. Dutch: Ik houd van jou (ik howd fan yow)
  4. German: Ich liebe dich (ik leebuh deekh)
  5. Spanish: Te quiero (teh kyero)
  6. Tagalog: Mahal kita (mahal kita)
  7. Russian: Я люблю тебя (ya lyubyu tebya)
Apr 24, 2023

What is the code for I love you in C++? ›

int main() { std::cout << "I love you" << std::endl; return 0; }

What is the most lovely programming language? ›

Rust, Elixir, Clojure, Typescript,and Julia are at the top of the list of Most Loved Programming Languages.

What is the number code for I Love You Infinity? ›

The number "1437" is commonly used as a numeric representation of the phrase "I Love You Forever."

References

Top Articles
Latest Posts
Article information

Author: Trent Wehner

Last Updated:

Views: 6423

Rating: 4.6 / 5 (76 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Trent Wehner

Birthday: 1993-03-14

Address: 872 Kevin Squares, New Codyville, AK 01785-0416

Phone: +18698800304764

Job: Senior Farming Developer

Hobby: Paintball, Calligraphy, Hunting, Flying disc, Lapidary, Rafting, Inline skating

Introduction: My name is Trent Wehner, I am a talented, brainy, zealous, light, funny, gleaming, attractive person who loves writing and wants to share my knowledge and understanding with you.