Friday, September 18, 2015

MongoDB

MongoDB is a NoSQL document-oriented database which stores data as BSON (Binary Script Object Notation) documents.

Salient features of MongoDB are:
  1. Document Oriented - aggregates the data in minimal number of documents.
  2. Ad hoc queries - like regular expression search, by ranges or field is supported.
  3. Indexing - any field in the document can be indexed.
  4. Replication - high availability is supported by maintaining replicas of data in more than one replica set member. The data is eventually consistent between the replica members.
  5. Load Balancing - uses sharding (a shard is a master with one or more slaves) to distribute the data split into ranges (based on shard key) between multiple shards.
  6. File storage - supports storing a file not as a single document but split across multiple shards - GridFS feature of MongoDB comes built in and is used by NGNIX and lighthttpd.
  7. Aggregation - is similar to SQL GROUP BY clause.
  8. Capped collections - can be used to store data in insertion order and once specified size is reached, behaves like a circular queue. Similar to RRD.
  9. Server side Javascript execution - is supported.


MongoDB is one of the top performing NoSQL database. Benchmarks have reported MongoDB performance to be better than some other NoSQL DBs by as much as 25x.
Eventual Consistency - eventually all nodes in the cluster of NoSQL DB will have the same data as data may not be propagated if the network breaks down or the node goes down but eventually when node is up and the network is working then data will be consistent across all shards.
Concepts:
1. Collections - set of documents
2. Document - BSON document with dynamic schema - means that documents in the same collection do not need to have the same set of fields or structure, and common fields in a collection's documents may hold different types of data.
Important mongo shell commands:
use DATABASE_NAME
>show dbs
>show collections
>db.movie.insert({"name":"tutorials point"}) --- will insert a movie document in movie collection.
db.dropDatabase()
>db.createCollection("mycollection")
>db.createCollection("mycol", { capped : true, autoIndexID : true, size : 6142800, max : 10000 } )
>db.COLLECTION_NAME.drop()
>db.COLLECTION_NAME.insert(document)
Query:
>db.COLLECTION_NAME.find()
RDBMS Where Clause Equivalents in MongoDB
To query the document on the basis of some condition, you can use following operations
OperationSyntaxExampleRDBMS Equivalent
Equality{:}db.mycol.find({"by":"tutorials point"}).pretty()where by = 'tutorials point'
Less Than{:{$lt:}}db.mycol.find({"likes":{$lt:50}}).pretty()where likes < 50
Less Than Equals{:{$lte:}}db.mycol.find({"likes":{$lte:50}}).pretty()where likes <= 50
Greater Than{:{$gt:}}db.mycol.find({"likes":{$gt:50}}).pretty()where likes > 50
Greater Than Equals{:{$gte:}}db.mycol.find({"likes":{$gte:50}}).pretty()where likes >= 50
Not Equals{:{$ne:}}db.mycol.find({"likes":{$ne:50}}).pretty()where likes != 50
AND condition:
>db.mycol.find({key1:value1, key2:value2}).pretty()
OR condition:
>db.mycol.find(
   {
      $or: [
      {key1: value1}, {key2:value2}
      ]
   }
).pretty()
Example:
'where likes>10 AND (by = 'tutorials point' OR title = 'MongoDB Overview')'
>db.mycol.find("likes": {$gt:10}, $or: [{"by": "tutorials point"}, {"title": "MongoDB Overview"}] }).pretty()
Update:
>db.COLLECTION_NAME.update(SELECTIOIN_CRITERIA, UPDATED_DATA)
>db.mycol.update({'title':'MongoDB Overview'},{$set:{'title':'New MongoDB Tutorial'}})

Replace old document with new data:
>db.COLLECTION_NAME.save({_id:ObjectId(),NEW_DATA})
>db.mycol.save(
   {
      "_id" : ObjectId(5983548781331adf45ec7), "title":"Tutorials Point New Topic", "by":"Tutorials Point"
   }
)
Delete:
>db.COLLECTION_NAME.remove(DELLETION_CRITTERIA)
>db.mycol.remove({'title':'MongoDB Overview'})
>db.COLLECTION_NAME.remove(DELETION_CRITERIA,1) -- removes the first match
>db.mycol.remove() - remove all documents in the collection.

Projection: selectively display fields and not all fields of a document.
>db.COLLECTION_NAME.find({},{KEY:1})
>db.mycol.find({},{"title":1,_id:0}) -- will display title and not _id (which is always displayed otherwise)
Limit:
>db.COLLECTION_NAME.find().limit(NUMBER)
Sort: 1 is used for ascending order while -1 is used for descending order.
>db.COLLECTION_NAME.find().sort({KEY:1})
Index: Here key is the name of filed on which you want to create index and 1 is for ascending order. To create index in descending order you need to use -1.
>db.COLLECTION_NAME.ensureIndex({KEY:1})
Aggregation:
>db.COLLECTION_NAME.aggregate(AGGREGATE_OPERATION)
> db.mycol.aggregate([{$group : {_id : "$by_user", num_tutorial : {$sum : 1}}}])
select by_user, count(*) from mycol group by by_user -- how many tutorials are written by each user (grouped by a user)

There is a list available aggregation expressions.
ExpressionDescriptionExample
$sumSums up the defined value from all documents in the collection.db.mycol.aggregate([{$group : {_id : "$by_user", num_tutorial : {$sum : "$likes"}}}])
$avgCalculates the average of all given values from all documents in the collection.db.mycol.aggregate([{$group : {_id : "$by_user", num_tutorial : {$avg : "$likes"}}}])
$minGets the minimum of the corresponding values from all documents in the collection.db.mycol.aggregate([{$group : {_id : "$by_user", num_tutorial : {$min : "$likes"}}}])
$maxGets the maximum of the corresponding values from all documents in the collection.db.mycol.aggregate([{$group : {_id : "$by_user", num_tutorial : {$max : "$likes"}}}])
$pushInserts the value to an array in the resulting document.db.mycol.aggregate([{$group : {_id : "$by_user", url : {$push: "$url"}}}])
$addToSetInserts the value to an array in the resulting document but does not create duplicates.db.mycol.aggregate([{$group : {_id : "$by_user", url : {$addToSet : "$url"}}}])
$firstGets the first document from the source documents according to the grouping. Typically this makes only sense together with some previously applied “$sort”-stage.db.mycol.aggregate([{$group : {_id : "$by_user", first_url : {$first : "$url"}}}])
$lastGets the last document from the source documents according to the grouping. Typically this makes only sense together with some previously applied “$sort”-stage.db.mycol.aggregate([{$group : {_id : "$by_user", last_url : {$last : "$url"}}}])
Replication: client application always interact with primary node and primary node then replicate the data to the secondary nodes.
  • All write operations goes to primary
  • Reads can happen from any of primary or secondary nodes.
  • Replication - is keeping multiple copies of the same data for HA and failover. One node is primary and others are secondary. Minimum 3 nodes needed to form a replica set.
  • Writes are always written to primary node in a replica set.
  • Within the replica there will be some delay when the writes to the primary node gets replicated to the secondary. In your application you may want to wait for the writes to be replicated. This is controlled by w flag - or write to replica flag. This is set to w:1 by default in drivers.
  • Mongodb keeps the data in memory and flushes it to disk periodically. If application wants to wait for the data to be written to disk then it can set J:1 (where, j is journal written to disk). W:1, J:1  is default for drivers.
  • Another setting is w:majority, which means write should propagate to majority nodes in the replica set. These w and j settings are called write concerns.
  • An application can set its read preference to read from secondary. Secondary's data may be stale so this is not recommended.

  • Following is how mongodb replica set is created:

    mkdir -p /data/rs1 /data/rs2 /data/rs3
    mongod --replSet m101 --logpath "1.log" --dbpath /data/rs1 --port 27017 --smallfiles --oplogSize 64 --fork

    mongod --replSet m101 --logpath "2.log" --dbpath /data/rs2 --port 27018 --smallfiles --oplogSize 64 --fork
    mongod --replSet m101 --logpath "3.log" --dbpath /data/rs3 --port 27019 --smallfiles --oplogSize 64 --fork
    mongo --port 27017
    Now you will create the replica set. Type the following commands into the mongo shell:
    config = { _id: "m101", members:[
              { _id : 0, host : "localhost:27017"},
              { _id : 1, host : "localhost:27018"},
              { _id : 2, host : "localhost:27019"} ]
    };
    rs.initiate(config);

    rs.status()

    Ps -ef | grep mongod -- will show all the replica sets created on the localhost.
Setting up replica set:
mongod --port "PORT" --dbpath "YOUR_DB_DATA_PATH" --replSet "REPLICA_SET_INSTANCE_NAME"
Backup/Restore MongoDB data: 
>mongodump
>mongorestore

Sharding - is a solution for horizontal scaling of mongodb. More shards (which are in turn made up of replica sets) can be added depending on the load on the system. A shard key needs to be an indexed key in the collection and should be present in all documents. The key need not be unique. It is used to identify the right shard to send the data to for persistence. Within the shard, replica sets will create copies of the data on replica set member nodes. So sharding helps in splitting the data based on a shard key in the document. Its like storing data in a hashmap. The better the key selection, the better the data will be divided among the shards.

Sharding is controlled via mongos router. Application connects to the mongos router which will listen to the 27017 port for example, and will know based on the shard key on which shard to insert the data to. For read/find operation mongos will query the primary node (of the replica set) in each shard and collate the result.

Experiences:
Liked:
  1. Easy to setup and develop against in multiple languages, like Java, python etc. Good to build POC applications.
  2. Stable enough.
  3. Querying is very powerful.
  4. Pretty performant in querying and inserts. If the schema has embedded documents mostly then it is worth using it.
  5. JSON structures can model quite complex objects.
  6. Schema-less DB can be useful (at least it appears to be so in theory) as it can reduce the pain in migration, though you still need to write the migration scripts nevertheless but not have to worry about alter-ing the schema (as there is no DDL or schema definition in MongoDB, all schema gets realized at runtime and documents within the same collection can be quite dissimilar).

Disliked:

  1. By design, no referential integrity is supported:
    1. So no cascade deletion - we need to handle it in application.
  2. Very hard to design with only embedded documents in the schema. Most of the time we end up with having documents with References or links which is akin to relations in the RDBMS. This comes at a price that to build a transaction with rollback is too much work in the application. MongoDB only guarantees atomicity within a document's boundary. So when you have too most documents having references instead of embedded documents in them then consider using RDBMS.
  3. Hard to model many-to-many relations.

Thursday, September 17, 2015

Amazon Web Services

AWS main components:
  1. S3 (Simple storage service)
  2. SQS (Simple Queue Service)
  3. EC2 (Elastic Compute Cloud)
  4. Elastic Beanstalk - PaaS
  5. EBS (Elastic Block Store) - block storage
    1. Instance store-based AMIs - are similar to ephemeral boot drive of openstack.
  6. CloudFormation - orchestration tool (like puppet) from Amazon similar to Heat for OpenStack
  7. CloudFront - CDN feature of Amazon Web services cloud
  8. ELB (Elastic Load Balancer)
  9. Amazon DynamoDB - NoSQL DB from Amazon

S3 - containers (called buckets) - object storage
For eg. Netflix uses S3 to store movies which are then streamed to their customers.



Using AWS CLI: - 

Installing on Mac/Linux is pretty easy if you already have pip installed:
$ pip install awscli

To get started and create an ubuntu instance all using the CLI:

  1. Create a key pair to use for accessing the VM
$ aws ec2 create-key-pair --key-name watshkeydev --query 'KeyMaterial' --output text > watshkeydev.pem
$ chmod 400 watshkeydev.pem

  1. Create security group and create a rule in the group to allow your CIDR subnet address or single IP to access the VM. With 0.0.0.0/0 we allow any host to be able to connect which is fine for test setup as we still require the private key to be able to ssh to VM.
$ aws ec2 create-security-group --group-name devenv-sg --description "security group for development environment in EC2"
$ aws ec2 authorize-security-group-ingress --group-name devenv-sg --protocol tcp --port 22 --cidr 0.0.0.0/0

  1. Launch the VM instance
$ aws ec2 run-instances --image-id ami-29ebb519 --count 1 --instance-type t2.micro --key-name devenv-key --security-groups devenv-sg --query 'Instances[0].InstanceId'
"i-b0b0ac89"

The image id is that of Ubuntu 14.04.1 Trusty release.
This step will take some time so wait and in between if you want yoy can poll for the VM status with the following command:

 $ aws ec2 describe-instances --instance-ids i-b0b0ac89 --query 'Reservations[0].Instances[0].State.Name'
"running"

Once it is running proceed to the next step.

  1. Connect to the VM
$ aws ec2 describe-instances --instance-ids i-b0b0ac89 --query 'Reservations[0].Instances[0].PublicIpAddress'
"x.y.z.k"

$ ssh -i watshkeydev.pem ubuntu@x.y.z.k

  1. Start/stop the instance remotely
$ aws ec2 stop-instances --instance-ids i-b0b0ac89

$ aws ec2 start-instances --instance-ids i-b0b0ac89

Saturday, September 12, 2015

Maven in short

1. Dependency management - can download the transitive dependencies (dependencies of a dependency and this can be infinitely transitive)
2. The main phases in maven lifecycle are:
a. Clean - will clean the target directory
b. Compile
c. Test-compile
d. Test
e. Package 
f. Install
g. Deploy
3. A plugin is bound to a lifecycle phase - for example, compiler plugin is bound to compile phase.
4. We can either execute the mvn <phase-name> or mvn <plugin-name>:<goal-name> for example, mvn compile and mvn compiler:compile do the same thing but when we execute mvn compile any other plugin we have bound to compile phase willl be executed too (together with compiler plugin's compile goal).
5. Maven POM is hierarchical - a project's POM is always inheriting from the base maven's super POM (that comes as part of maven). To see this, execute: mvn help:effective-pom and this will show the plugins that are already part of the super POM we are inheriting from.
6. Within the project too, we can build a hierarchy of POM files. We use the <modules> element to define the sub-modules (which have their own POM files) in the parent module/directory.
In parent pom.xml:
<packaging>pom</packaging>
<modules>
<module>server</module> -- this will build server/pom.xml
<module>client</module>
</modules>
7. All plugins are listed at - http://maven.apache.org/plugins/index.html
8. Maven central repo is - http://search.maven.org/
9. Some important plugins:
a. Clean
b. Jar - mvn package (this is phase and jar plugin in bound to package phase) or run explicitly as mvn jar:jar.
i. -Djava.finalName
ii. -Djar.forceCreation=true - jar created every time.
c. Javadoc 
d. Install - packages and puts the archive in local maven repo so other modules/projects can refer to it.
e. Deploy - deploys to remote maven repo (the remote repo configuration is provided in pom.xml in <distributionManagement> element). This repo could be in cloud (running artifactory server for eg.)
f. Surefire - only one goal (test).
g. War - to package web application 
10. Archetype - to create a project based on an archetype (or template for a project). We can create our own complex setup archetype and make it available as a template for new projects in an organization.
a. Mvn archetype:create-from-project - used to create a new archetype based on existing project. All source files which were there in the original project will be present in the new projects created from that archetype.
b. Mvn archetype:generate - to create a new project 
11. Some commands:
a. mvn archetype:generate  (format is <plugin>:<goal>) - used to generate skeleton for new project.
b. mvn idea:idea or eclipse:eclipse -- to generate project in IDE specific way (run it after archetype:generate)
c. Mvn help:describe -Dcmd=compiler:compile -Ddetail - to see what properties are available for compiler plugin (properties like maven.compiler.verbose)
d. Mvn compiler:compile -Dmaven.compiler.verbose=true -- to debug what is going during compilation
e. Mvn -help
f. Mvn -v
g. Mvn <plugin-name>:help (eg. Mvn compiler:help)
h. Mvn -q compile (quite mode - tidys the o/p)
i. Mvn -X -- gives verbose/debug o/p


Thursday, August 27, 2015

Setting up Ubuntu Linux VM in VirtualBox

1. Download and install Oracle VirtualBox for Windows 10 
https://www.virtualbox.org/download/testcase/VirtualBox-5.0.3-102224-Win.exe
Windows 10 is not officially supported so this test build is available of the most recent stable build of Oracle VirtualBox 5.0.2 with some bug fixes for Windows 10.

2. Download and install Oracle VirtualBox Extension pack 
http://download.virtualbox.org/virtualbox/5.0.2/Oracle_VM_VirtualBox_Extension_Pack-5.0.2-102096.vbox-extpack
Extension pack extends the functionality of VirtualBox  base package (like adding support for USB 2.0, 3.0 devices, RDP, webcam passthrough, PXE boot ROOM support etc).

Note: One can verify that extension pack has installed correctly by checking VirtualBox -> Preferences -> Extensions.

3. Create a new VM in VirtualBox with the following specs:
  • OS – Ubuntu Linux x86-64 (Note: For VirtualBox to show 64 bit OS options you need to ensure that “Virtualization Technology VT-x” option in the system BIOS has been enabled. By default it is disabled and in which case VirtualBox will only show 32 bit OS options for a new VM).
  • CPU – 1
  • Memory – 1024 MB (give more if you want to use the VM for development)
  • Network – Bridge Adapter (instead of NAT so it uses the host OS network interface for internet connection)
  • Virtual HDD – 12 GB (Dynamically allocated – slower but won’t occupy the entire 12 GB from the very beginning and will grow as we install the OS and use the VM). If you want better performance then use Fixed allocation which will take sometime to format and setup).
 4. Download Ubuntu Linux 64 bit Desktop iso image from http://www.ubuntu.com/download/desktop 

5. Associate the iso image as a virtual CD ROM drive to the VM and install OS in the VM. 

When it starts up the resolution of the Ubuntu OS will not be good. To fix that, do the following (excerpted from http://askubuntu.com/questions/451805/screen-resolution-problem-with-ubuntu-14-04-and-virtualbox):
  1. Update Virtualbox to the latest version (currently 4.3.24)
  2. In Terminal in the Guest system type:

    sudo apt-get install dkms
    sudo apt-get install build-essential module-assistant
    sudo m-a prepare
If you have no top menu in the Guest system, it's because you're in scale mode which causes it to be hidden. In that case, press Host + C to toggle scale mode (where Host is Right Control by default)
  1. In the Guest system, go to the top menu, and click Devices->Insert Guest Additions CD Image. This should mount the CD image. Install the guest additions and then a restart the VM. Post the restart the resolution should be 1920x1080 (assuming your monitor supports it). Then you can go full screen mode.

Thursday, July 09, 2015

MSSE-CMC from SJSU

I had long since been an aspirant of MS in Software Engineering(MSSE). Today i was finally accepted as classified graduate (in short was granted admission to the MSSE program) for Fall 2015 of MSSE Special Session - with emphasis in Cloud and Mobile Computing.

I needed to write TOEFL since my BS was from India. The syllabus is very practical and focused on cloud and mobile computing. I am looking forward to having a fun time learning and completing the courses and obtaining the MS degree in Spring 2017.

The MSSE classes will be held in Santa Clara and this will be the 6th batch doing this special session on cloud computing however the first one with both cloud and mobile computing. I am looking forward to learning some mobile application development also while doing my MS :).


Saturday, May 23, 2015

My TOEFL Test experience

Today i took my TOEFL test at a Prometric testing center in San Jose. I arrived at 7am and started writing the exam at 7:35am. I was done with first 2 sections (Reading and Listening) around 9:33am (about 2 hrs) and then resumed at 9:43am or so with the next 2 sections (Speaking and Writing) and was done by 11:10am (1hr 25 mins). So the last 2 sections were quicker for me. I think i had extra questions in Listening (which won't be counted towards my total score).

Now the specifics on each section while i still remember it :):


  1. Reading had 4 passages and around 56 questions in all. Total time was 1hr 20 mins (80 mins) so for each passage i had 20 mins. Passages were from various topics and the ETS TOEFL practice test for Reading (as well as for other sections) were quite like the ones on the exam.
  2. Listening: I don't remember exactly how many audio clips were there in all but the general pattern was you listen to a clip and then answer multiple choice question on them.
  3. Speaking: 6 speaking exercises:
    1. First 2 were about a familiar topic that i got 15secs to prepare for each and 45 secs to speak about.
    2. Next 2 were - read a passage, then listen to an audio clip on it and then speak about the subject matter being discussed in both passage and clip.
  4. Writing: 4 exercises.
    1. 2 were about listening to a clip and reading a passage and then write some answers in your own words.
    2. 2 were given a topic write in your own words about the topic. I was asked about the school days starting early and late which one i preferred and why. Answers needed to be at least 300 words. I wrote close to 380 words.
Got my results on 06/01/2015 (today). I scored 105. Per this discussion on quora it seems it is a decent score to apply. For SJSU the cut-off was 80.

For my preparation, all i did was 1 practice test from TOEFL study guide software. I did intend to study more but could not find the time. However after doing first practice test i was familiar with the sections, the type of questions asked and how to approach them.

TestTest DateReadingListeningSpeakingWritingTotal
TOEFL iBTSat May 23 07:36:01 EDT 201528282821105

Thursday, May 14, 2015

Book Review: Paleo Diet

My notes from the book:

Paleo Diet - What Our Ancestors Didn't Tell Us About The Best Diet In History And How You Can Use It To Lose Weight Quickly And Easily (Paleo Recipes, ... Paleo Solution, Paleo Cookbook, Paleo) (Adams, Ralph)



  1. Health experts have discovered that the culprit behind deadly diseases like cancer and diabetes is in fact the kind of diet people today have.
  2. This means entirely eliminating grains, legumes, dairy products, processed sugars and starches, as well as alcohol from your diet.
  3. The Paleo Diet allows only the consumption of the following food types:   Meat There is some debate and discussion about the kind of meat you should choose for your Paleo Diet. Some advocates insist on eating only lean meat, while others are more adamant about choosing fatty cuts. The original Paleo does not prescribe the kind of meat cuts you should choose. However, Paleo experts dispel the myth about the “unhealthy” saturated fats found in fatty meat cuts. There is no substantial scientific evidence that actually links saturated fats with heart disease, so there’s no need to avoid fats.
  4. meat from grass-fed animals is preferable to meal-fed animals because these are closer in composition to the wild animals hunted by the ancients. If grass-fed is unavailable or too expensive, you should probably choose a leaner cut of the meal-fed.
  5. Fruits are the only natural source for sugars that is allowed in the Paleo diet.
  6. Vegetables Together with fruits, vegetables are a great natural and unprocessed source of necessary nutrients and vitamins.
  7. Whole Nuts and Seeds Nuts and seeds are a great snack for Paleo because they contain healthy fats and essential oils. 
  8. Seafood Ancient hunter-gatherers did not only hunt land animals, they also hunted fish and other sea animals. Seafood is rich in protein, and fish like tuna and salmon are high in the healthy omega3 oil.
  9. Eggs Other diets warn against eating eggs because they are high in cholesterol. But eggs have a lot of good enzymes, being high in protein and vitamins A and B.
  10. Supplements Since grass-fed beef is usually expensive, other Paleo dieters recommend getting the meal-fed ones and supplementing with fish oil capsules to get an added dose of omega3
  11. In moderation, these food and drinks can be consumed:   Coffee Chocolate Tea Rich Sauces dairy products like fermented yogurt, heavy cream, butter, and certain cheeses have little lactose content, so you could include them occasionally in your recipes.   Dried fruits Salt
  12. These foods and substances should be avoided entirely:   Sugars Grains and grain products Legumes Soda Alcohol
  13. Grains are full of gluten and lectin, which can obstruct the natural digestive process. Lectin covers the walls of your stomach and makes food more difficult to digest. Gluten, meanwhile, causes inflammation and can also cause autoimmune diseases, or diseases which cause your immune system to attack itself.
  14. Paleo Benefits Weight loss and maintenance Detoxify your body from substances found in grains and legumes, such as lectin and phytic acids Prevent degenerative diseases like diabetes, cancer, obesity, and heart diseases
  15. You can cut up fruits and vegetables and stock them in your freezer, so you have readily available ingredients for salads and quick snacks.
  16. stock your meat in the freezer and pre-cook enough (without seasoning) for 2 or 3-day meals.
  17. Eat when you are hungry.
  18. Instead of counting the carbs or worrying about the ratio of your veggies and meat portions, let your body guide you and eat a small meal whenever you feel hungry.
  19. Exercise. Paleo works best for people who have relatively active lifestyles. Even just a brief 15 to 30 minute gym or running session can do wonders for weight loss.
  20. Drink water. Never substitute fruit juices for water during Paleo. make sure you get at least 8 glasses of water daily.
  21. Eat more fat. Because you dropped on carbs, you will need more fat to sustain your energy levels throughout the day.

Book Review: Intermittent Fasting

Notes from the book:

Intermittent Fasting: Simple Guide to Weight Loss, Fat Loss, and Improved Health - THE FAT LOSS AND ANTI AGING DIET (Intermittent Fasting for Weight Loss, ... Loss, Weight Loss Diet, Lose Fat Book 1) (Childs, Valerie;Louis, Joy)

  1. The most important thing to understand is this, the number of calories your body burns throughout the day is not dependent on meal frequency.
  2. In weight loss, what matters most is the difference between the number of calories taken in and those used up by the body. Regardless of your meal frequency, you will gain weight if at the end of the day, you eat more calories than you expend.
  3. What matters is not whether you eat breakfast or not but what you eat.
  4. Proteins are the sources of amino acids that keep muscles healthy and growing. Once you eat a meal containing proteins, that is enough to produce amino acids for more than 16 hours.
  5. The book recommends a fasting period of between 12-24 hours.
  6. Studies have shown that even three days of fasting do not affect training performance.
  7. To make your training highly effective however, it is recommended that you take a pre and post workout protein supplement. Some BCAA powder or tablets are the best.
  8. calories in versus calories out is what matters. As long as you are not snacking on unhealthy, high calorie junk food or overeating, you should be okay.
  9. Eating three large meals, instead of six smaller ones, results in much better appetite control.
  10. Whether you fast for 12 hours, 36 hours or three days, your blood sugar will remain the same.
  11. The science behind intermittent fasting weight loss is mostly about how the body produces its energy. When you eat, sugar is stored in the liver in form of glycogen. The body uses it to produce energy. When you eat a meal during breakfast, lunch and dinner, your body will never run out of glycogen to use for energy synthesis. There is therefore no time when it will turn to fat burning for energy.
  12. The only problem is, you want your body to burn fat so as to reduce it and lose weight. The only way to do this is wait until glycogen is depleted, then force the body to burn fat.
  13. Intermittent fasting does this. It takes about 8-12 hours, without further eating, for glycogen to run out. This is why it is recommended that any intermittent fasting method should not run for less than 12 hours. After 8-12 hours, the body turns to fat for its energy needs. To help in burning more fat, you can engage in exercises such as cardio workouts or weight lifting.
  14. With continued adherence to intermittent fasting, you can get to a point where the body adapts to using fat more than glycogen.
  15. you should get to a point where the last meal is at 8pm at night and the next full meal at noon the next day.
  16. To get the full benefits you have to also change your dietary components. Include more fruits and vegetables in your meals and do not forget to drink lots of water. Avoid highly processed foods and high sugar products like Soda and candy.
  17. Having a planned menu before you start ensures that you know what you are going to eat for each meal of the week.
  18. The best way to spend your fasting hour is by staying busy.
  19. To amplify the benefits of intermittent benefit, include regular workouts into your schedule.
  20. Simply because fasting for 15 hours has done wonders for you does not mean that 48 hours will too, in fact, it will damage your body. Prolonged fasting is what is referred to as starvation. Your muscles start to waste, metabolism rate drops and energy levels go down drastically. This kind of fasting is not helpful at all.
  21. Experts recommend the minimum fasting period to be 12 hours and the maximum period to be 20 hours.
  22. Do not fast blindly. Keep checking your health status to ensure that the fasting is not causing any health problems.
  23. Just eat healthy, do your exercises, lower stress and you will live a long healthy life.
  24. If you can manage 12-16 hours of fasting once every week or so, it will benefit you a lot.
  25. “It is not hard. Don’t you dare tell us this is hard. Quitting heroin is hard. Beating cancer is hard. Drinking your coffee black. Is. Not. Hard.”
  26. Improving your sleep, energy levels, mood, attention span, body composition, motivation, self-confidence, self-efficacy, and quality of life starts by changing the food you put on your plate.
  27. Yes, the Whole30 eliminates cravings, corrects hormonal imbalances, fixes digestive issues, improves medical conditions, and strengthens the immune system.
  28. Added sugar and artificial sweeteners. All alcohol. All grains (even whole grains). Legumes, including peanuts and soy. Nearly all forms of dairy.
  29. Added sugars, whether from table sugar, honey, agave nectar, or maple syrup, do not contain the vitamins, minerals, and phytochemicals that contribute to your overall health, but they do contain lots of empty calories.

Popular micro services patterns

Here are some popular Microservice design patterns that a programmer should know: Service Registry  pattern provides a  central location  fo...