Best time of the year to watch birds in my back yard
Best time of the year to watch birds in my back yard
New MacBook Pro - Not iconic anymore
After a long thought I convinced myself to upgrade my laptop to a new MacBook pro. While I did consider switching to Windows due to many bad reviews about the new Pro, I couldn’t digest the thought of going back to windows world. There are many reviews about the new touch bar and various aspects of the new Pro, so I wanted to highlight some of the minor things that I miss which i believe made the old MacBook Pro an iconic product to own. Wonder why Apple choose to leave them out.
- Charge indicator
I really liked having a physical button and an indicator to show the battery charge status without having to open the laptop and check the status in the menu. This was very useful when putting the laptop for charging on the go and you are in the rush to remove it from the charge and leave. Now I have to take a guess which has been mostly right so far, but as time goes and the battery will start to degrade it would be hard to guess how long it will take to charge.
- Magsafe connector for charging
Lots of people talk about the reversibility aspect of USB-C in the context of charging cable, but magsafe connector was reversible too additionally it also had magnets, so it was real easy to plug it in. This is most envied feature of non-mac owners
- Apple logo that lights up
Although a minor one, yet those are the little things that differentiated an iconic product from rest of the pack.
- New USB-C charger
The new USB-C charger do not have the notch to wrap the cable around. This was way more useful to keep the cable neat and tidy
- Physical esc key
I had to say “Physical” esc key because there is a virtual esc key available in the touch bar. I am a heavy user of vim and some times I keep one finger on top of the physical esc key until there is a need to click it. I also rest my left hand fingers on first line of the keyboard when using the trackpad (for ex while browsing or reading a big document). Now I had to adjust my hand position and orientation to rest the fingers in the number keys instead of the function keys row - I dont like to keep the fingers hanging at the top, it needs to be rested.
- HDMI connector
I use external monitor a lot as a second screen, can’t say enough on how much productive having a second screen is. I am starting to think of attaching an apple tv at home and office so I can extend to the screen wirelessly over airplay instead of carrying another dongle around.
As an Apple fan boy I do love the new MacBook Pro and would never go back to the windows world. Yet I believe that it is a natural human tendency to expect an iconic experience when owning a premium product that stands out of the normal pack. This version of the MacBook Pro do not have any such iconic standouts (touch bar cannot be considered iconic, not yet). Apple also decided to remove some of those iconic features that used to exist before. This is what makes the existing pro and air owners compare the new Pro with other laptops like sub standard laptops like Dell XPS 13 and such. If Apple do not restore some of the premium options that makes its product iconic, they will not stand out and lose against the normal competitors.
Funny quotes from Snap Inc’s S1 Document
Snap IPO is the most anticipated IPO for this year. After reading about the hype in many news sites I decided to read the S1 document myself to understand the proposed business model a bit better. While there are many interesting facts about how they are different in creating targeted and context aware advertising I found some of the quotes really funny, here are a few for you to enjoy.
Meaning of Kind
Our team is kind, smart, and creative. When we say “kind,” we mean the type of kindness that compels you to let someone know that they have something stuck in their teeth even though it’s a little awkward.
Funny, yet not funny category
We have incurred operating losses in the past, expect to incur operating losses in the future, and may never achieve or maintain profitability.
About Smartphones
we eat, sleep, and poop with our smartphones every day. They can also understand the world around them, such as where they are and how fast they are moving.
Go here if you are inclined to read the full 200+ page document.
Resolution to Write
This year I have taken a resolution to write more. Its been 10 days since the new year and finally I have taken the time to get into the habit of writing. I hope I continue to write more this year and for the years to come.
Here are three reasons on why I want to write
Expand the knowledge
Having easy access to information either through google search or using voice search (think Alexa, Hey Siri or OK Google) does not mean we expand our knowledge. Reading books, blogs and other information sources helps but I realized that writing helps even more to expand the knowledge.
Make more friends
Make friends, not just with like minded people but also with those who has opposing view point for a healthy debate and help in my first point of expanding my knowledge. If you are reading this, I would love to hear from you, just leave a comment saying hello.
Live Life Twice
One of the best quote I read about writing is
“We write to taste life twice, in the moment and in retrospect.” - Anaïs Nin
Yes, I would like to live life twice.
With that let me start the journey to write and live life again.
Visualization
“visual representations of abstract data to amplify cognition”
Incoming SMS to Email
One of the common problems developers face when integrating with a Messaging API like nexmo is to make an end point available to receive the incoming messages. Since they are in the middle of development they wont have an application ready to host in an internet facing domain for accepting new messages.
In order to address this problem I created a simple app called nexin that would email the incoming messages to the registered users email. This app will create a new endpoint as soon as the user registers an incoming number. This callback url can be added to the incoming callback url in the nexmo dashboard.
Checkout the app and let me know if you have any suggestions.
If there is enough interest I am planning to add an event notification feature to publish the incoming message as an event to AWS SNS topic or to a Rabbit MQ endpoint instead of sending it by email. This would allow the consumption of message programatically.
Send SMS from MYSQL Triggers
There were situations where you have to send SMS from a trigger in mysql. I can hear you screaming why would I do that. When it comes to architecture its all about options. Although this may not look like a ideal place to send a message from, it might come in handy in some rare occasions.
In the following example I assume that you have a usertable that contains the number column. The requirement is to send a SMS when the number is changed in the table.
First install a mysql-udf-http package from https://code.google.com/p/mysql-udf-http/
create a mysql trigger on the table where the phone number is stored.
Use nexmo SMS API to send sms using REST API.
CREATE TRIGGER `restful_trigger` BEFORE INSERT ON `user` FOR EACH ROW
BEGINDECLARE phone_number varchar(20) default “;
SET @phone_number = NEW.PHONE; SET
@message = ‘Phone number is updated from’;
CASE
WHEN NEW.PHONE != OLD.PHONE THEN SET xxx = ‘yyy’;
SELECT http_get(CONCAT ('https://rest.nexmo.com/sms/json?api_key={api_key}&api_secret={api_secret}&from=yourcompany&to=’,@phone_number,’&text=’,@message))INTO @rtn_value;
SET NEW.STATUS = ‘Message sent with status ’,@rtn_value
END;
Thats a quick way to get SMS hooked up with mysql.
Send SMS using Nexmo and AWS Lambda
I used Nexmo’s SMS API to send SMS application alerts to users. I have also used Nexmo’s Verify API to enable two factor authentication (2FA) to allow my client’s customers to view their order status without having to log in to an eCommerce platform.
There are two key aspects to Nexmo’s Verification API:
Generation of random number is handled by the API which relieves the app developer from generating and storing the number for verification later.
Nexmo makes a voice call as a fallback if the number used for verification is either not a text enabled number or if the code is not entered by the customer within a few seconds.
Amazon recently launched AWS Lambda, which is an event-driven computation service that abstracts the infrastructure required to run an application behind a code. What this means is that as a developer, it’s sufficient to write a piece of code that takes action on an event without the need to setup an infrastructure to run the code. A typical example is an image resizing service that can take an image and resize on request. Some of the unique benefits include metered billing in increments of 100 milliseconds and scaled infrastructure to process the event automatically based on the throughput of input events.
In this blog, I will demonstrate how to send SMS using Nexmo API from an AWS Lambda function when an event is published to a SNS topic.
Overview :
Publish a message to the SNS Topic and process it through a lambda function which sends a SMS message using the Nexmo API.
The process involves 5 steps.
- Setup Nexmo Account
- Setup IAM Role
- Create a Lambda Deployment Package
- Configure Lamda function
- Configure SNS and Connect to Lambda
Setup Nexmo Account :
If you don’t have a nexmo account already setup a nexmo account from here
Buy a number to be used as a from number for sending SMS message.
Setup IAM Role :
Create a new user or get the arn of an existing user who should be able to subscribe and publish to the SNS queue.
Create a Deployment Package :
Create a nodejs project with package.json and index.js file. A sample project can be downloaded from this github project.
The function signature that will be invoked by Lambda is
function(event, context)
The structure and content of event param depends on the service that invoked the lambda function. In this case the invocation is from SNS the event object structure.
{
"Records": [
{
"EventSource": “aws:sns”,
"EventVersion": “1.0”,
"EventSubscriptionArn": “arn:aws:sns:EXAMPLE”,
"Sns": {
"Type": “Notification”,
"MessageId": “95df01b4-ee98-5cb9-9903-4c221d41eb5e”,
"TopicArn": “arn:aws:sns:EXAMPLE”,
"Subject": “TestInvoke”,
"Message": “Hello from SNS!”,
"Timestamp": “1970-01-01T00:00:00.000Z”,
"SignatureVersion": “1”,
"Signature": “EXAMPLE”,
"SigningCertUrl": “EXAMPLE”,
"UnsubscribeUrl": “EXAMPLE”,
"MessageAttributes": {
"Test": {
"Type": “String”,
"Value": “TestString”
},
"TestBinary": {
"Type": “Binary”,
"Value": “TestBinary”
}
}
}
}
]
}
The message sent to SNS can be retrieved using this access key.
event.Records[0].Sns.Message
Create a function to parse the incoming message and call nexmo API using the easynexmo nodejs library as below.
nexmo.sendMessage(smsMessage,function(err,messageResponse) {
//add custom logic to handle success or failed message delivery
consolelog(err,messageResponse);
next(err);
});
Once the functions are created and tested zip the files up from within the folder. Its important that the zip archive is from within the folder that contains the package.json, index.js and node_modules files. This archived file is the deployment package of the lambda function.
Configure Lamda Function :
Now that the lambda package is created use the AWS console to create a new lambda function and upload the package. Below is the screenshot showing the values on how to configure the handle and file names.
Configure SNS and Connect to Lambda :
The last step is to create the SNS topic to publish the message and add a lambda subscriber to process the message sent to SNS topic.
Either use AWS CLI or AWS console to create a new SNS Topic. Then Add a new subscriber and make sure to choose the protocol as AWS Lambda.
The Endpoint dropdown will contain the new created lambda function from the previous step.
Testing :
There are 2 ways to test this setup.
AWS console provides a useful debugging function that can send a test message to the lambda function. Use the event JSON from above to test from the console.
Create a new publisher to send message to the SNS queue. For simplicity I added a test function in the index.js file that can publish a message to the SNS topic. Here is the sample code to accomplish this.
function testSNSDelivery() {
var message = { from:NEXMO_FROM_NUMBER,
to:TO_NUMBER,
text:‘testing from local to sns to lambda to nexmo’
};
var params = {
TargetArn:SNS_TOPIC_ARN,
Message:JSON.stringify(message),
Subject: 'TestSNSNexmo’
};
if (err) {
console.log('Error sending a message’, err);
} else {
console.log('Sent message:’, data.MessageId);
}
});
}
sns.publish(params, function(err,data){
The logs generated by lambda function can be viewed from cloud watch log viewer.
If you have read through so far, you may ask why I used a lambda function to send SMS. As an alternative, I can use the built-in SMS function of SNS to send SMS messages. However, SNS doesn’t support sending SMS worldwide. Nexmo has a wide variety of communications API that can be used to do Two Factor Authentication, Number Verification, Number Insights, Make a Phone Call, Text To Speech and SIP endpoints. Above all, Nexmo supports sending SMS worldwide.
Example Use Cases:
Send notification when:
- A file is uploaded to S3 bucket
- A job is completed in Hadoop cluster
- An iot sensor detects a change like a light is turned on, a door is opened etc.
- A new customer downloaded the app from appstore
Summary:
Nexmo provides a cost-effective way to sending SMS worldwide. AWS Lamda provides a cost effective way to process events without managing an infrastructure. By using Nexmo and AWS Lamda you can create an asynchronous notification microservice component for your backend infrastructure without having to maintain an infrastructure.
Use Nexmo with AWS Lambda
I have been using nexmo as the communication API provider for my applications. Its been working great especially for sending SMS messages worldwide.
Amazon has added many new features to the AWS Lambda service today. This got me excited and gave an idea to implement SMS notification through Nexmo API from a Lambda function using the nexmo nodejs sdk.
Stay tuned for a detailed blog post on how to do this tomorrow.
Just another beautiful icy morning - a great way to start the day.
Page 1 of 3