07 January, 2019

TIL #7 - find the Git commit that introduced a string in any branch, hydration and some aws fun facts

Notes taken between: 07-11 January 2019

How to find the Git commit that introduced a string in any branch.

js>git log -S <insert here> --source --all
--all start from every branch
--source show which of those branches led to finding that commit. It's often useful to add -p to show the patches that each of those commits would introduce as well.

source: https://git-scm.com/docs/git-grep


Hydration appears to be the way in which one can choose the form of data which is the result of a query. Or in other words; refers to the process of filling an object with data. An object which has not yet been hydrated has been instantiated and represents an entity that does have data, but the data has not yet been loaded into the object. This is something that is done for performance reasons.

Additionally, the term hydration is used when discussing plans for loading data from databases or other data sources. Here are some examples: You could say that an object is partially hydrated when you have only loaded some of the fields into it, but not all of them. This can be done because those other fields are not necessary for your current operations. So there's no reason to waste bandwidth and CPU cycles loading, transferring, and setting this data when it's not going to be used.

Additionally, there are some ORM's, such as Doctrine, which do not hydrate objects when they are instantiated, but only when the data is accessed in that object. This is one method that helps to not load data which is not going to be used.


The way to partitioning one physical server into several virtual servers, or machines (called guests).
Used to create multiple machines using a single physical one.
EC2 or Elastic Compute Cloud
The commercial name for the virtual machine you can use in AWS cloud service.
AWS virtual machines
AWS virtual machines are called EC2 (Elastic Compute Cloud), like any VM, it needs an operating system. An EC2 machine needs also to run within a VPC (Virtual Private Cloud), which is a virtual network that isolate and secure your Cloud resources. To ensure that an EC2 instance can communicate with a resource over the Internet, you must also attach an Internet Gateway to your VPC. When you create an EC2 instance in a public subnet, AWS will give you a public IP. If you need a persistent IP address, you need to create an EIP (Elastic IP) and attach it to your EC2. If you create 2 or more instances, they will share things like the network, subnet, IAM role ..etc
EC2 Spot instance
Allows you to bid on spare Amazon EC2 computing capacity in order to reduce the cost of your running applications using the same budget. This type of instances run when your bid price exceeds the Spot price You can also choose which network to use for your EC2 instance. When you start a VM you should choose your Amazon Virtual Private Cloud (VPC). This VPC defines your machines IP addresses range, subnets, route tables, and network gateways.
A Subnet
Defines the range of IP addresses in your VPC that can be used to isolate different EC2 resources from each other or from the Internet. Each subnet resides in one Availability Zone. By default, your machine can be in a single subnet which is the most common use case: One network interface, one IP address. A subnet can be public (accessible by anyone) or private (accessible by only those who are authorized).

POODR (Sandi Metz) ch 7

Use of classical inheritance is always optional; every problem that it solves can be solved another way.

Because no design technique is free, creating the most cost-effective application requires making informed tradeoffs between the relative costs and likely benefits of alternatives.

Many object-oriented languages provide a way to define a named group of methods that are independent of class and can be mixed in to any object. In Ruby, these mix-ins are called modules. Methods can be defined in a module and then the module can be added to any object. Modules thus provide a perfect way to allow objects of different classes to play a common role using a single set of code.