Basic Chest Workout of the Day!

Today’s Chest Workout! Time to get shredded!

This workout is very straight forward. Just do these in order and take a rest between each set for about 1 minutes – 2 minutes. Don’t get too comfy, your heart rate should still be decently active before you start your next set.

Overall Workout Structure

1) (Warmup) – 8 minute jog,  2 minute powerwalk, 1 minute stretch

2) Flat Bench Press

3) Incline Bench Press

4) Dumbbell Pull Overs

5) Decline Chest Flies (video)

6) Dips (video)

Set Structure

Increase the weights to your discretion

1) 20 reps at 20 % of your full strength for a warmup

2) 10 reps with increased weights

3)  10 reps with increased weights

4) 8 reps with increased weights

5) 8 reps with same weight

6) 1 rep with increased weight

JavaScript Interview Question: Value Types and Reference Type

This interview question is designed to test candidates that they know how JavaScript types are handled.

Question: What will the console print out?

Answer:

The first loop should print: “Adam”, “Bob”, “Cathy”

The second loop should print = “Adam, “Bob”, “Catherine”

Why?

JavaScript passes primitives (integers, floats and strings) by value.

JavaScript passes objects and functions by reference.

 

Organizing Modules in AngularJS

While this isn’t probably new, it’s still a worthy mention to a popular method of organizing your AngularJS applications into submodules. For those coming from a Java , C++, or C# background, this will help you get a “namespace” feel to things.

In an N-Tier Framework, you might have “modules” like “services”, “presentation code”, “configuration managers”, “data access”, and “domain objects”. You can bring this type of organization into your AngularJS application! In addition, with AngularJS we can can include dependencies of other modules as well!

To define a module.  We call the module function.

  •  The first parameter is the name of the module
  • The second parameter is an array of strings of the other module names

In most cases we store this module into a JavaScript variable like so:

This enables us to use it later in our application whenever we want to add or reference our module.  Okay so a lot of people might not able to see the use of modules. Let’s get straight into a very practical and common pattern for you N-Tier people

Typically our AngularJS applications will have a series of different components.

  • Services
  • Controllers
  • Filters
  • Directives
  • Constants

If we put these ideas together, we have a fully functional AngularJS Application.

We can start off by creating an empty object to hold our application module:

And then we can bootstrap the application to our DOM in the HTML. The ng-app=”myApplication” tells AngularJS the location of our main application module

Now we can extend the myApplication object with sub-property objects that reference our sub-modules

Now we actually need to tell AngularJS that the application is an AngularJS module and will depend on its sub components.

So if we wanted to create a controller for our application we can now do the following:

Happy Coding!

Quick Extension Methods

Say you have the following DateTime object:

This a normal store someones birthday of June 5th, 1990. With birthdays being stored, wouldn’t it be great to just calculate the current age from the System.DateTime type? Unfortunately, DateTime isn’t our code to edit. We are stuck with writing a static utility method to operate on it. But, wouldn’t it be great if you could just do this?

Instead of having some static utilities method do this for you

Well with extension methods you can!

How do I write an extension method?
  1. Create a public static class (yes it has to be static). My recommendation is to include the word “Extensions” in the class name to help other developers out. I would place it within a folder called “Extensions”
  2. Create a public static method with the class
  3. Include the type that you’d like to extend as a parameter in the method with the word “this” before it like this. (You can include other parameters after it)
  4. Whenever you want to use the extension method, just include the namespaces and references to where you put the code.

So with the birthday and age example stated above, you’ll get the following extension method.

So what do extension methods address?

Extension methods allow you to add methods to an existing uneditable type (class or interface). This is especially convenient when you need to extend classes or interfaces that you’ve reference from a .dll file (external libraries and .NET framework types). Thus, the DateTime type that comes boxed with .NET is a great example of this.

Here’s the big take away: Extension Methods looks like they’re part of that specific type but they’re just a static method added

So what can’t extension methods do?

  • Extension methods cannot modify or read private variables in the type they are extending. So when writing extension methods, don’t be fooled into thinking that you have access to the private members within that class.
  • Extension methods cannot override already existing methods. That’s right, you can’t override methods with extension. Extension Methods take a lower priority over the native methods that are already defined.

Quick and Dirty CORS support for ASP.NET Web API

Cross-Origin stuff is a pain in the butt to configure in any framework or language, especially when it’s in your way from doing any JavaScript AJAX calls.

This little tid bit will help you out if your AJAX applications are coming from a different domain than your Web API.

For example:

Also subdomains are different domains as well, so this will also pertain to you!

 

Need to play around with JavaScript AJAX calls and your ASP.NET Web API right away? Do this. You might have to come back and implement a more robust solution, but let’s be honest: you’re not at that stage yet if you can’t get a damn XMLHttpRequest in because it’s throwing you 405 errors. You want to test your single page application right?

Note: Make sure you have WebDAV uninstalled completely under the “Turn Windows Features on and off”.

This will also get rid of the pesky 405 Method Not Allowed for the “OPTIONS” method that a lot of JavaScript AJAX calls will send before actually doing what you want it to, if you’re interested it’s called pre-flight request.

In the system.webServers section add this:

 

 

You will most likely have to change the values around but make sure you contain “Content-Type” in the “Access-Control-Allow-Headers” and the “GET, POST, PUT, DELETE, OPTIONS” in the “Access-Control-Allow-Methods”

codecamper

Thoughts on John Papa’s Single Page Apps with HTML5, Web API, Knockout, and jQuery PluralSight Training Series

John Papa released one of the most badass modern day JavaScript application video tutorials ever known to man on PluralSight. The finished product is an application call CodeCamper (live demo here), a fake app where you can sign up to see a tech-talk session.

The Good

  • A great coverage of many different technologies
  • A full walkthrough from the domain driven design server application pattern, repository/unit of work pattern, and exposing data via JSON, to construction a full-fledged Single Application with dependency injection
  • Excellent explanations of certain architecture choices
  • Author provides a very nice looking application available with a live demo.

The Bad

  • No mention of authentication, authorization or any type of security
  • The final JavaScript client application is stich of many different frameworks
  • Author sometimes goes a little too fast

Okay so let me begin by saying that the tutorial isn’t free but it’s almost worth a PluralSight subscription. John Papa can go very fast in some sections and does not always show all the code involved in creating the finished product. You will definitely miss some lines, so I wouldn’t stress out by continually pausing to copy content down. Due to the quick pace, you will definitely want the “Monthly Plus” subscription plan that allows you to download the source code. This is an excellent tutorial as it not only creates a full n-tier application using Entity Framework 5, ASP.NET Web API, and numerous JavaScript libraries such as

  • RequireJS for modularizing code and creating a service locator pattern
  • KnockoutJS for model binding
  • SammyJS for routing patterns
  • AmplifyJS for AJAX requests
  • jQuery for DOM manipulation
  • QUnit for testing
  • Creating Data Context for caching data on the client
  • Patterns for filtering and sorting data

Even if you don’t know or don’t care about the ASP.NET portion of the tutorial, you should sit in to the JavaScript portion of the series. At the end of the day, you’re going to be communicating in JSON, so it really doesn’t matter what server technology you end up using.

If you are a developer that has used primarily jQuery and a plethora of plugins to accomplish dynamic behavior with your browser experience, you may have been in situations where your code becomes an absolute tangled mess. In general, there hasn’t been much guidance (or maybe widespread knowledge or care) on the web on how to organize and modularize JavaScript code until the last few years. Papa’s source code has a great logical pattern in which he modularizes code and prevents the use of global variables. In addition to modularization, he does a great job of creating a JavaScript data access tier to create a succinct and organized way to fetch, delete, add, and update data.

The JavaScript sections feature HTML5 Routing, View Models/Form Validations, and how to commit JSON back to the Web API.  My favorite section was the DataContext & DataService portions. It’s very well thought out and really does a great job in creating another tier in your JavaScript application. One of my favorite aspects of this tutorial series is that Papa shows how to use mock data and integrates his workflow with test driven development. Fortunately, he doesn’t go overboard with the testing and focuses primarily on the patterns that his applications need.

As with any application, a major portion of development and testing often goes to authentication, authorization, and other types of security features. Unfortunately, this application does not cover anything of the sort. Even worse, there aren’t a lot of samples or tutorials online that help developers implement security with JavaScript applications and JSON APIs. Having said that I can’t blame Papa because this type of security is such a “use what works for you” area.

Overall, John Papa definitely did everyone a favor of walking through the construction of an application from database to client app.

However, I would never use his JavaScript approach for my own projects. No matter how much pretty CSS you put on this site, it truly is a sexy but Frankenstein-ish app. It’s kind of like Nicki Minaj. Just take a look at the list of technologies that he uses to get this thing going. There were probably 10 completely different libraries, plugins, and frameworks included. There’s nothing wrong with this, I don’t know about you but I can’t imagine hunting down answers through 10 different documentations and having to maintain them all as my project evolved.

My Recommendation: I recommend using AngularJS. If you’re programming a web application these days, I’m going to bet that you’re using some sort of MVC pattern (Rails, ASP.NET MVC, Spring MVC, CodeIgniter etc…). Assuming one is familiar with those patterns, why reinvent a framework to act MVC-ish when there’s one that has almost all the tools you need out of the box?

Final Words: If you’re into creating single page applications using JavaScript and some sort of JSON rest service, definitely take a look at this course. However, I would advise against using this tutorial’s approach and go with something a bit more complete that has built in routing, dependency injection, and model binding.

1152_google-chrome-os

Chromium OS’ Zero Sum Game

I recently had the pleasure of installing and playing with the Chrome/Chromium Operating System on my Mac. I have a really good friend that highly recommended me to give it an honest go and give him some feedback from a developers perspective. While there is a lot of rave about cloud-computing, I’ve found a few interesting points that the Google OS is attempting to achieve.

Chromium OS, is Google’s operating system answer to the cloud revolution. The Chrome OS’s goal seems pretty straightforward. Instead of traditional operating systems like Windows, Mac OSX, or Linux for personal computing, allow a super lightweight Chromium OS to take advantage of web applications that run through a browser and get rid of everything else.  So what is an operating system? For those who don’t know or really just think it’s the stylish or sexiness of your computer or notebook, here’s a pretty direct but important explanation.

Operating System 101: Not just sexy UI

An operating system is not just an cute graphical fan boy user interface. It is a piece of software that runs on a computer that helps manage its resources. If you take a computer apart, there are a lot of interconnected hardware and components (the resources) like RAM, Hard drive, USB Input, display for the monitor, the CPU, the keyboard, or even something as abstract as security.  When you open up a program on your computer, like an internet browser, a video game or Microsoft Word, that program is going to ask to use some of your resources. It’s going to ask for RAM, some organized way to look for files, maybe full screen capabilities and much much more. These programs never really have direct access to use or manipulate these resources (nor should they ever need to!), they always go through a mediator (the Operating System) to get its job done.

The trend from Desktop to the Cloud

Remember those days of shrink-wrap software where you actually had to go to Circuit City and buy a box that had a CD in them? Then you had to wait for a very long time to install the piece of software and then you could run it? These applications are typically referred to as “desktop applications”, they live on your computer and take up space on your computer’s hard drive.

People are still stingy about WiFi

South Korea is the most digitally connected country in the world. I’ve been there, it’s fantastic! However, in Silicon Valley, I was able to lose signal inside of a mall. Countries like South Korea and Japan have incredible connectivity rates for widespread public use, while I can only login to Panera’s slow WiFi for 30 minutes at a time. The staggering disparity and quality of wireless connections from square foot to square foot on this planet pose a pretty interesting geographical limitation that traditional devices are immune to. Yes, I understand that people today use their computer primarily for internet browsing. However, a Chrome book with no WiFi is virtually crippled compared to a MacBook in the same situation.

Chromium can only thrive under a difficult combination (HTML5 + JavaScript)

There are some absolutely amazing HTML5 and JavaScript web applications out there. They all have one thing in common:

They use AJAX to make their web application behave like a desktop application

The world wide web today has a defacto standard for sending information back and forth: Hyper Text Transfer Protocol (HTTP).  This protocol is stateless. The stateless nature of the web can be demonstrated by going to many website registration pages, filling it out, and going to a different page and instead of pressing submit, then returning to the registration page. Voila, all your emails and phone numbers and all the data has been completely erased. Stateless means that the web application has no way of knowing what happened from page to page. (Just go on Youtube, watch a videeo half way and press refresh, the application will not know where you last stopped!) Thus, in a lot of situations a simple refresh button or closing the browser can lead to a lot of lost data. This is a frustrating part of using and creating fluid web experiences. On the other hand, desktop applications don’t have this issue thus they are stateFULL. Being statefull has not only a really beneficial user experience but also a much more pleasant development experience.

This is not say all is lost because everything being transported via HTTP! Developers and frameworks have created many workarounds to simulate a stateful web. The overwhelming solution is to employ HTML5′s new features with JavaScript in a technique called AJAX(Asynchronous JavaScript and XML). AJAX is not a programming language, it's just a way of using JavaScript to manipulate and retrieve data from a server without reloading the page.. However, perfecting such a simulation using AJAX is very difficult. The more complex the application, the development difficulty significantly rises.  Even the best solutions to allow web applications to act like a stateful desktop application like Google Docs, Google Maps, Compilr, Microsoft Office Live, Presi, etc…  still have many flaws. At the end of the day, using AJAX to create and simulate the responsiveness of desktop applications on the web will (at the current writing of this) continue to be only a simulation of statefulness.

Facing the facts: Even today, it’s still not easy to create software

For those who aren’t really technical, this might be news to you. Regardless of today’s hype around tech companies and startups selling for billions in less than 2 years, it hasn’t gotten any easier to develop software. There are some major hurdles that really have no solution and have just become part of the process:

  1. Today’s developers must learn many programming languages
  2. The demand for mobile puts much more work on the developer
  3. There is a staggeringly low supply of software engineers out there today

Today’s developers must learn many programming languages

Back maybe a few years ago when cloud computing wasn’t as prominent as it is today, a developer could really just program in straight C++ or C to crank out an impressive desktop application. Today, with the majority of the developer positions aimed at web specific solutions, software teams are required to learn many programming languages and technologies. While the common frameworks and solutions are pretty much similar across the board, the differences create overhead to getting a good product rolled out.

Let’s take a famous example: Facebook. It’s really just one application: you can go online and add profiles and photos and statuses. This alone (as far as I know) has quite a few technologies involved:

  1. C++ (Server Side Language)
  2. C (Server Side Language)
  3. PHP (Server Side Language)
  4. SQL (Server Side Language)
  5. JavaScript (Client Side Language)
  6. ActionScript (Client Side Language for all the Flash Stuff)

In an example as simple as Facebook, there are at least 5 programming languages used! Let alone, there probably many technologies and design implementations that the development team have to master in order to roll out a straight forward application.

The demand for mobile puts much more work on the developer

Now comes the demand for mobile applications. Facebook now has to support adding more languages to their current stack

  1. iPhones -> Objective-C
  2. Android -> Java
  3. Windows Phone -> C#
  4. Mobile Site Version-> Reinventing/Modifying the JavaScript, CSS, HTML, and images of the original site.

This list is a probably a serious cursory to the additional technologies, and architecture, and plugins and in house code that needs to be written to make an application available across multiple mediums. With the advent of mobile devices, applications are now required to be mobile friendly. Some may not know but mobile websites and applications have far less resources available than a desktop browser. This forces developers to optimize everything so that applications don’t crash and still remain somewhat responsive for a good user experience. Optimizing code is often thought of a good thing, but sometimes extreme optimization of code can tear down readability, a fundamental importance in software engineering, and push back deployment time, a fundamental importance in business development! In addition, memory management When software uses resources, they typically use memory or RAM. Many modern languages have a feature called Garbage collection that allows programmers to focus more on code rather than tedious tracking the memory that their code might be using. Garbage Collection is nonexistent when developing for the iPhone or iPad! is nonexistent for iPad and iPhone development.

There is a staggeringly low supply of software engineers out there today

Today, there aren’t a lot of software engineers. The demand for technology has significantly increased but the rate at which people take up a profession as software engineers or graduate with a computer science degree is simply not able to keep up with the demand. The average starting salary for junior developers is scary high these days: with a majority of them approaching $100,000. Software engineering can really handle a specific type of organizational and logic thinking. It’s not necessarily mathematics driven but logically driven. Many students today struggle with computer science courses and cannot make the mental leap to dive into creating software as a business. Thus, from the handful of developers out there, only a handful of them will probably make good software!

 

 

 

fuji_mountain_japan_1920x1080

Book Recommendation: Essential Japanese Grammar

The Japanese language is extremely flexible. Flexible in the sense that besides having the verb at the end of the sentence or phrase, everything else is very pliable. Learners of the European language base come from a much more rigid grammatical flow and at times may encounter some uneasiness when they discover that different people and slightly different situations call for different patterns of grammar. In addition, Japanese grammar and syntax has a surprising amount of emotion and social status attached to different usage types. This can be very intimidating for intermediate learners who are eager to express complicated sentences while being unsure of the correct grammar and conjugation to get the job done. Well fear no more. Essential Japanese Grammar by Masahiro Tanimori and Eriko Sato is one excellent book to move from intermediate to semi advanced useful grammar in the Japanese language. While the book does an excellent job of doing its title justice as Essential Japanese Grammar, it is lacking in the Keigo Keigo is the respectful subset of the Japanese language. It is used pervasively in the business setting as well as any other formal situation or occasion. Keigo employs many intricate vocabulary as well as grammatical differences between it and colloquial Japanese. section of the book. While Keigo is very much a part of work life in Japan, I still think would have been a good addition to add a few more chapters on the matter and the techniques. As for the typography and visual presentation the book is extremely elegant. The font size is a comfortable 12 or 13 times new roman and the kana looks slightly bigger to prevent the kanji from looking too squished on the page.

Overall Review: 4/5

Good things about the book

Bad things about the book

  • This book has romajiRomaji is the use of the western alphabet to phonetically write out the Japanese Language. . Romaji is cute and fine for casual travelers to Japan and some casual learning. However, I believe its extremely detrimental past that point. I don’t know why a grammar book that goes into such depth would include it everywhere. My eyes constantly betray my morals and tries to trick me into reading the romaji. If I had to review a book that is at this intermediate level of Japanese grammar, I would have included full usage of Kanji (which it already has) along side kana and the English translation. In turn this helps the readers learn kanji and jukugo at the same time.
salthash

User Domain Entity with Salted and Hashed Passwords

One of the hottest areas in the .NET arena today is Entity Framework Code First. Entity Framework Code First is so exciting and sexy that many of us cram our Entity models with tons and tons of fields without realizing some easy security pitfalls. The most popular security pitfall revolves around mapping your applications users login information (username/email and password information) blatantly within the database. Thus if your domain entity looks like this, you’re probably messing upAllowing malicious people to steal your users passwords is not only a legal risk but it also hurts the web application community since a massive majority of people use the same login credentials and email credentials from site to site! 

If you map the User class above to your database context, you can run

and get:

UserId Username Email Password
52 gWashington233 delawarepirate@gmail.com itWasntThatCold
53 Sheraton.hall Sheraton.hall@yahoo.com niceTryIhaveSymbols!^
54 Onetimesally69 neverSafeEnough@hotmail.com lolIHasnumbers2333

This is wrong wrong wrong. I’m not going to talk to you like I’m a security guru, but you don’t want anyone even developers or database to see your users passwords as plain texts. While Entity Framework in many cases prevents a lot of SQL Injection types of attacks it opens you up to a Rainbow Table attack which are a lot more common than one thinks. There are a ton of different attacks out there to steal, change, or corrupt your data. But salting and hashing is a very good step in the right direction again the Rainbow Table Attack pattern.

Create a SaltedHash Security Utility Class

This salted hash utility class will be a static class with 3 static methods.

The thought process:

  1. The Password in plain text: this is a plaintext string that the user enters during registration, login, or changing passwords
  2. The Salt: Generate a byte[] based off a random integer between a minimum size and a maximum size using System.Random.
  3. The Hashed Password: Generate another byte[] based off the generated the salt ( byte[] ) and the plain text password (string)
  4. Store the Salt and the Hashed Password in the Domain Entity/Database Table but NOT Password
Required Namespaces:
  • System
  • System.Text
  • System.Security.Cryptography

 The new and improved User Domain Entity

Notice that the the Salt and Hash are both private sets and that there is a [NotMapped] attribute over the Password string property. You can see that this User entity will allow the application to set the password but will never allow the software to display the actual password in plain text. There is obviously many areas for improvement depending on the use case. Some developers may not feel comfortable to let a User object set a new password so easily.

 

email

Sending Emails from C# .NET v4 (Gmail)

In this quick little tutorial. I’ll show you how you can use .NET and C# to send emails using Gmail. This also is very easily modifiable to use other SMTP Mail Services as well. All you need are 2 Namespaces, a few strings, ints, and a bool to make it all work. All primitive value  types! Hurrah!

Note: Please don’t use System.Web.Mail and stick to this tutorial use of System.Net.Mail. This example uses System.Net.Mail to fully handle SMTP. In previous versions of .NET, it was popular to use System.Web.Mail which used a lot of the COM functions to handle SMTP, which apparently is heavily frowned upon by .NET 3.5.

Required Namespaces:

  • System.Net
  • System.Net.Mail

Required Parameters

  • string fromEmailAddress (example: “youremail@gmail.com”, this matters because it’s also the username used for authentication)
  • string fromName (example: “Max Alexander”, this is just a friendly name )
  • string fromPassword(example: “yourGmailPassword”)
  • string host (example: “smtp.gmail.com”)
  • int portNumber (in the case of gmail it’s default is 587)
  • string toEmailAddress (example “yourfriendsemail@gmail.com”, this doesn’t have to be gmail)
  • string toName (example: “Stephanie Sprayregen”, this doesn’t really matter, it could be empty)
  • string subject (example :”Hey can’t wait to hang out this weekend! Let’s grab drinks!”)
  • string body (the message body! if isHtmlEmail is true, this string can hold htmltags, if it’s false, it’ll be rendered as plain text)
  • bool isHtmlEmail (very self explanatory, I recommend this to be set to true)

The code

Note Regarding SSL: You can probably see that I highlighted SSL to true by default. I don’t think I’ve encountered one email service that didn’t have SSL. A lot of services don’t give you the ability to switch it off, and if they do, the service, like Gmail will give you ample warning that it’s not a recommended option.