Ad

Thursday, March 31, 2016

Summary:

Best practices and step-by-step notes from a recent Bloc webinar on how to get started and code HelloWorld app aka skill for Amazon Echo Alexa. This blog post provides step-by-step instruction to create a simple app for area code lookup. It covers the best practice and resource recommendations covered in the presentation.

slides what is Alexa

Presentation slides hello world with Amazon Echo, getting started step by step:

Scroll to the bottom for presentation slides.

Background info:

Users interact with Amazon Echo by saying Alexa, blah blah blah the utterance is the request to be sent to the skill's web server with data and be given a response back. Alexa will voice over the response specified in the <speak></speak>. Alexaalso has online, iOS, Android portals, where users can purchase apps called skills, enable and disable skills, and view info cards.

Mark the Alexa project mentor really thinks Amazon Echo is growing in demand and is experiencing a boom in app creation. The device is growing and gaining in market share. That's where developers will want to be.

Source: Bloc online coding bootcamp webinar on how to develop with Alexa by Henry and Mark

Concept: interacting with the alexa service involves user sending a request and getting a response from Alexa in audio format

Step - App idea generation: come up with an original or semi-original app idea for your Alexa project. Alexa has a relatively small growing app store. It's a good time to get started.

Step - obtaining and cleaning data: need to find either static or dynamic API data for your app. For example, a list of area codes is a static data set, versus the latest news from NYTimes via its news API is a dynamic data set. For first try, Henry recommends finding data with no copyright attached. He used a JSON converter to convert his data to JSON, which works well with AWS Lambda.

Step - Get your app to work locally: use your local dev environment or use jsbin to ensure that your code can grab and process the data correctly. Then upload as a zip file. Your zip code should have a minimum of three files: your app, data file, and an Amazon specific library file. Can use the boiler plate file for now.

Step - Amazon Web Services Lambda: this is a free tier web services that runs on Node.js. It works well with Amazon Echo demo apps, has great out-of-the-box security. Henry recommends this for those familiar with JavaScript.

Step - Build an interaction model: in your Alexa dev portal, access Alexa skill kit for the menu. This is where you can build the interaction model, make configuration changes, test, publish, twig privacy settings.

Concept - testing:

Testing in the Alexa skill kit does not require an Amazon Echo device. You can simulate your app experience by Entering an Utterance which creates an object to be sent to your lambda service for a response. When the response is given, can click the listen button to hear Alexa respond.

Concept - privacy settings: useful for those apps that collect payment information or personal data that is transacted.

Best practice: test a lot, play around a lot to cover all the scenarios of interaction. Get feedback from the Amazon team to be thorough.

Step - Publishing Your Alexa app: Code will be reviewed by the Amazon Alexa team. It's a real world professional code review experience for Bloc students. Once submitted, the app will queue up for a review.

Amazon Echo Alexa interaction model

Best practice:

It's possible to write Amazon Echo apps in any language such as Ruby and Python, but using JavaScript and JSON data formatmakes it easy to plug-n-play with Amazon Lambda Node.js server written in JavaScript.

Amazon reviewing team consisted of professional developers will review each app and either approve or provide feedback for improvement.

Mark: best developers write the least amount of code. Use Amazon Alexa sample apps and sample code when possible. They are vetted.

Resource: Alexa skill sample apps and core concepts page, demo apps

Bloc Online Coding Bootcamp and Mentorship program:

Amazon Echo Alexa programming is not a stand-alone project as of March 2016, but an integrated project block in each of the four famous Bloc tracks including Software Engineering, Full-stack, Rails and Front-end.

Submitting the app through the Bloc program in June, students will receive a free Echo from the Amazon team. This is a seriously awesome partnership between Bloc and Amazon. May be the future of building an app store ecosystem is to partner with coding bootcamps and the fresh blood they attract. It's a smart way to build a pipeline of developers.

Get your own Alexa device for development here - > Amazon Echo by Amazon for $179.99 http://amzn.to/1UG6jr5 via @amazon

Subscribe to Mark's newsletter http://askdevweekly.com/

Further thoughts: use case for complex Alexa skills including in app purchase, role playing games and writing (not realized skills yet).

Further thoughts: experiments have been done on Raspberry Pi which can run Amazon Echo Alexa functionalities. Mark thinks this is proof that Amazon Echo development skills are useful and it is growing in demand. Alexa skills should be able to be applied to run on the internet of things in the future.

Commonly Seen Errors or Caveats:

<say-as interpret-as='digits'>415</say-as> will make Alexa say "four one five" instead of "four hundred fifteen". Useful when decoding area codes and phone numbers.

Background

When I first started writing this blog, I acquired my own name as the domain. Then I kept the blogger subdomain codesum.blogspot.com when I started learning to code and the blog got technical with me. Finally last year, I found the perfect phrase that describes all the topics I want to write about Silicon Valley in its ego and adrenaline filled form: Silicon Vanity. Last year, I did what a Stanford graduate would want to do: I incorporated my startup, founded a Saas company and moved into Westfield lab (the luxurious downtown retail location) BESPOKE, a startup working office. Less than a year later, I found myself already late for my first tax season and a tax bill of $60,000 from Delaware alone. Above is my half hearted deck describing my emotional roller coaster preparing tax forms and lessons learnt today.

Tuesday, March 22, 2016

Shopify Developer Conference: web accessibility talk. Web accessibility is about more than just accommodating a minority group of audience with special web browsing needs! It's about reading in sunlight (needing strong color contrast), night stand reading mode, on-the-go mobile browsing with audio input, desktop audio dictation and much more.

* By Steven bosworth of the themes team
* Shopify image alt texts, fall back texts are important
* Best practice: label all things in theme though tedious
* Each form field should be properly labeled even if hidden
* Form error messages need clear label that traces back to the right field
* form.error is the shopify errors object
* tables : accessibility helpers understands how the td s are tied together. Challenging on mobile - single column display. Shopify handles this for us. (Css work around, hidden span s that announce the correct data, hidden visually but accessibility engine readable
* Best Practice: User testing reveals hidden accessibility problems.
* Caveat: accessibility engines, may not understand relationship between two div s whose visual relation is obvious
* Color contrast and text: studies found white on yellow is not accessible in sunlight reading mode.
* Best practice: test color contrast while designing and developing
* Resource: Twitter #a11y topic on accessibility
* Resource: color blindness testing and simulation tools available on the web.

Concept - can use objects already written by other people, stand on the should of the giants

Concept - two important things to understand about objects: 01 what can an object do? 02 How to make the object do it?

Why is OOP so important?

Industry standard, job requirement to use object oriented programming

Concept - a person is a perfect analogy of an object (computer science): a person has attributes / properties like height weight, and he/she is can do all kinds of things. OOP is intuitive - it is aligned with the way we think

Objects

Analogy - objects are like appliances in a big house. Each appliance such as a heater or the washer has some build-in functionalities

Concept - Object = building block of a program, component with some desired functionality. You can ask objects to do work.

Concept - You don't necessarily know how they do that - how they complete each task.

Analogy - We don't know usually know the granular details how a heater works, as long as it heats water

Concept - it's important to understand WHAT an object can do, NOT necessarily HOW it does that

Lesson Title : Objects demo

Exercise: learn to use an existing project, and start a new instance of an object

Concept: It's important to not get hung up on how an object does its task exactly to the greatest details. The amount of codes in each project can be overwhelming. It's important to follow instruction, and ignore the extra details.

Lesson Title: Lesson 2 - Objects - Classes

Concept: in Java, class = objects with common behaviors. Example the day class, when you want to use objects in this class, look at its documentations. Example: the string class defines the common behavior of the string objects.

Concept: methods = actions that can be done by a class

Comments: this is a really good way to think about objects, for those who are new to OOP

Lesson Title: Lesson 2 - Drawing Pictures

Exercise: playing with interesting codes that can edit and modify pictures

Comment: this is a great exercise, showcasing a real-world application of Java, and how powerful it is for image manipulation

Lesson Title: Lesson 2 - Variable Names

Concept - Use variable to store a value that you need to retrieve later. Every variable has a name. Analogy: parking lot spot, parking structure label

Lesson 2 Objects An Exercise on Variable Names

Identify the variable names in variable declarations

Lesson 2 Objects Variables

Concept Variable Type: in Java writes the type before the variable name. Analogy: parking spot for a bike, versus for motorbikes versus for a car. In Java, we have to specify which type of data the variable holds.

Concept Initial Value : when declaring a new variable, always best practice to specify an initial value.

Concept data type double: a number that can have a decimal point. Ignore the curious name.

Wednesday, March 16, 2016

Udacity gives out free Google I/O 2016 tickets (to Chinese followers and students of their WeChat official channel) and all-expense paid tours of Silicon Valley.

It's not news that Google and Udacity are close. Previously, in 2015 Google I/O, udacity announced its newly minted Udacity Android Nanodegree track promising potential job opportunities of the brightest of graduates with its hiring partners including Google.

And Google not only gave a physical booth and meeting area to Udacity at the event, but also stages for Udacity speakers and the founder - Sebastian. Google even announced the program in the big event's keynote.

Really really wants to work for Google? May be Udacity is the way to go.

Thursday, March 10, 2016

What is a MVP? The key is to follow the "minimum" part almost religiously! You need to do the absolute minimum and test out your product as soon as possible see if it gains traction. The MVP is for getting the innovators the first group of people who would adopt new products. By OneMonth, famous learn-to-code tutorial learning company, a part of the YCombinator (YC) famous Silicon Valley startup accelerator.

See this famous product adoption curve to see how people pick up new products and how products can growth hack.

Wednesday, March 9, 2016

This funny internet parody movie trailer features two old school yet still very prevalent programming languages: Java and .NET (by Microsoft). The movie depicts the coming of age of Java and how it surpassed .NET as the future of technology... once upon a time. It's entertaining.

Sunday, March 6, 2016

This is my notes from the Code School CodeTV lecture for implementing Basecamp Search Feature. I have not covered all the nuances from the lecture. It's a great real-world software engineering series. Each episode is a real scenario crystalized to 20 minutes of discussion, white boarding, sample code and more.

Step: first analyze the search feature and its behavior, then choose what to replicate. Basecamp dashboard search searches through entries, and makes suggestion of matching project messages and users. In case where no EXACT MATCH is found, the website does a FUZZY SEARCH, or a rough match instead.

Step: analyze the data model. Simplified basecamp data model: project is the main object class, there are many projects, each can have many messages, each message has many comments. And there's the User model and user records. User can be associated with one or more projects.

Step: create a search form with the search keyword input field. Method is GET.

Code:

<%= form_tag search_path, method: :get do %>

<%= text_field_tag 'keyword', nil %>

<%= end %>

Step: custom config search route. Not using any resources for this simple functionality.

Code:

get 'search' => 'search#index', as: :search

Step: Search Controller code using parameter input from the search field, first search by keyword in Project, then user and redirect correspondingly. Line 3 get the keyword. Line 5 doing the first exact match - project with the same title using Rails4 .find_by(). Redirect to the specific project with that title. Line 10: custom defined Search class with .for() method. Search is a custom Ruby class not an activerecord class. This is the line for a fuzzy search. Will return an array of concatenated

Code: for Rails database %, the percentage sign, is the string wild card

Sample code for implementing Basecamp search feature search controller
Search projects by title, user by name or else do a fuzzy search

Interview with David Heinemeier Hansson the famous creator of Ruby on Rails

Code School took the basecamp search implementation to show David, creator of Rails at the Chicago Basecamp office.

David explains:

It's indeed okay to only use RESOURCES for CONTROLLER doing more complex task than just a single action.

Resources is a macro script that will create a bunch of utilities for the controller.

Opinion on Exact Match vs Fuzzy Match and how to scope:

Best practice, David will not use local variables when possible. Ask the question What can it offer you? Does it make the code clearer? Change code : keyword = params[:keyword] to into inline local variable instead example

code: if project = Projects.find_by(title: params[:keyword])

It's a stylistic practice. Repeating hashlook up is okay, it's clear that the param is coming from outside world.

Rather than using REDIRECT_TO multiple times create an instance method named with jump.

Fuzzy search : Will have a hard time paginating the result from 3 tables. Cannot use offset properly since SQL offset is based on a single table.

The search class in model has a def self.for(keyword), keyword seems to be internal but actually is from the "outside world" as it is a parameter. Need to be careful of SQL injection and hacking when utilizing user inputs. Because we are using the wild card in an unsanitized input, the hacker can pass in another percentage sign - another wild card sign. And if a friendly user searches for a % percentage sign, he can mess up the query too. Sanitization is needed.

Basecamp uses ElasticSearch to handle its high volume, complex and practically all of its search features.

If number of records is large, also need to manage the number of results. Consider ElasticSearch or an eternal search service. ElasticSearch is made to handle this multi-table query result situation too. It can index a variety of data and return the result for you. That's how basecamp does it. It uses ElasticSearch for almost everything.

There's also a Ruby Gem for ElasticSearch.

David Heinemeier Hansson extracts the .find_by and redirect_to methods on Projects and User into a
jump target instance method.

- The above command effectively RENAME the first file to second file name

- $rm file_name.txt

- Rm remove one or more files

- $echo

- Print something in the terminal

- $echo "starship" > wormhole.txt

- The above command puts "starship" text into a file, effectively create a new file

- $cat file_name.txt

- Cat command prints text in a file

- $ln wormhole.txt gamma.txt

- ln is a link command, cat a linked file will show identical result, however, overriding the original file will also override the linked file. Each file refers to a storage in Unix called inode or index node.

- $ls -i

- will show all the inode number of each file

- Linked file will have the same inode number. It's not the same copy of file, but actually referring to the same content.

- ln -s wormhole.txt gamma.txt

- The symbolic link is a also known as a soft link by passing the -s option to ln. It works a bit differently. Soft linked files have different inode numbers. Symbolic link refers to the file name not the actual content, especially useful for linking across different storage devices such as a USB drive. The inode number has to differ because they are entirely different file systems. Trying to hard link two files across two file systems will result an error but symbolic link will be successful.

- use ls -a to list all directories including hidden directory and the parent directory

- use ls -a -i to list all directories and files in the current directory with their i nodes

- command: cp ../childdir/myfile.txt .

- The above command looks for the parent directory of the current directory, and find a child directory called childdir, find its file called myfile.txt and copy it into the current directory, respresented by a dot. The dot symbol refers to the current directory.

This is my notes and review from the Code School Pluralsights database fundamental series "Database is Your Friend"
Your Database is Your Friend (Code School Pluralsights video)
Rating:
made by pluralsights
Key concepts: database concepts & fundamentals (1. Data Integrity, Concurrency, Reporting), examples in Rails
Time accessed: March 6, 2016 Code School free weekend, covers best practice
Rails is not a prerequisite
Style: pluralsights, not the typical gamified Code School course completed with an opening theme song, challenges,

A lot of a use of rails * migrations * to modify database * state *

Best practice: the presenter prefers to NOT using rolling changes forward or backward in a PRODUCTION ENVIRONMENT. Instead he uses
$bundle exec rake db:drop db:create db:migrate db:seed
to wipe out and recreate the database from scratchw when changes are needed.

- Data Modeling video agenda: 1. Not Null Constraints, 2. Foreign Keys 3. Duplicate Data 4. Polymorphic association alternative 5. Reactive integrity Checks
- Rails error example NoMethodError in Books#show occurred on line <%= @book.blurb.truncate(100) %> tried to call .truncate() on a text but didn't work. A hot fix, a trick is to convert the nil field, which caused the NoMethodError to be a string so use <%= @book.blurb.to_s.truncate(100) %> But it's a temporary hot fix. We are like to encounter unexpected nil again elsewhere or the same mistake in the future, will cause another bandage fix. If we edit a book, entered nothing in the blurb field upon saving the field will no longer be nil but emtpy string. Nil versus Empty String not provided versus provided but empty. It's not exposed in the UI and will cause inconsistent, and does-not-make-sense data called Incoherent Data. We need to figure out where the nil comes from (may be an import script that forgot the blurb field).
- an activerecord validation may help such as validate :blurb, presence: true But this will prevent empty string as well, so we add some additional condition validate :blurb, presence: true, if: ->(record) {record.nil?} But some SQL statements and activerecord methods can bypass validations such as book.save(validate: false)
- The best way is to fix the database scheme and make sure nil is never stored for that data field using rails generate migration add_not_null_to_blurb First we need to update all data to make valid <code> Book.update_all({blurb:''}, {blurb:nil}) </code> replacing all existing nil with empty string. The next step is to change the column to not allowing nil and set a default value <code>change_column :books, :blurb, :text, null: false, default:''</code>

What is scope in Ruby?

This is the note for Code School CodeTV Series - Metaprogramming Scope online learn-to-code tutorial. It's a great, short 5 minute class, which explains computer science fundamental concept - Scope in the context of Ruby programming.