Skip to content

Instantly share code, notes, and snippets.

View santiagopoli's full-sized avatar

Santiago Ignacio Poli santiagopoli

View GitHub Profile
@santiagopoli
santiagopoli / listings.json
Last active September 27, 2016 02:39
Listings
[
{
"id": 8778879,
"name": "Majestic SC Panoramic w/Queen bed",
"typeText": "Entire home",
"instantBook": true,
"price": 79,
"starRating": 5,
"reviewsCount": 40,
"previewImageURL": "https://a0.muscache.com/im/pictures/a5d62823-d3bc-4f58-b946-f4898a3c519d.jpg?aki_policy=x_medium",
const FavoritesView = ({ favorites, onSelectFavorite }) =>
<View>
<FavoritesList favorites={favorites} onSelectFavorite={onSelectFavorite}/>
</View>
const FavoritesScreen = ({ navigation }) =>
<FavoritesView onSelectFavorite={favorite => navigation.push('FAVORITE', {{ favorite: favorite }})}/>
const NavigationStack = StackNavigator({
FAVORITES: FavoritesScreen,
const mapDispatchToProps = (dispatch, props) => ({
onSelectFavorite: (favorite) => {
props.onSelectFavorite(favorite);
dispatch(fetchFavoriteInfo(favorite.id));
}
})
const mapStateToProps = (state) => ({
favorites: state.favorites
})
const clear = (favoriteId) => state => ...
const fetching = (favoriteId) => state => ...
const finishFetching = (favoriteId, favorite) => state => ...
export default (state = {}, action) => {
switch (action.type) {
case 'CLEAR_FAVORITE':
return clear(action.favoriteId)(state);
case 'FETCHING_FAVORITE':
return fetching(action.favoriteId)(state);
const platformSpecific = ({ios, android}) => (Platform.OS == ‘ios’) ? ios : android
<View style={{ color: platformSpecific({ ios: 'black', android: 'white' }) }}/>
@santiagopoli
santiagopoli / bootstrap.tf
Last active March 18, 2018 21:55
Terraform Blue Green / Bootstrap
variable "infrastructure_version" {
default = "1"
}
provider "aws" {
region = "us-west-2"
}
terraform {
backend "s3" {
@santiagopoli
santiagopoli / vpc.tf
Last active March 18, 2018 21:40
Terraform Blue Green / VPC
variable "vpc_id" {
default = "yourvpcid"
}
@santiagopoli
santiagopoli / subnets.tf
Last active March 19, 2018 19:55
Terraform Blue Green / Subnets
locals {
subnet_count = 3
availability_zones = ["us-west-2a", "us-west-2b", "us-west-2c"]
}
resource "aws_subnet" "terraform-blue-green" {
count = "${local.subnet_count}"
vpc_id = "${var.vpc_id}"
availability_zone = "${element(local.availability_zones, count.index)}"
cidr_block = "10.0.${local.subnet_count * (var.infrastructure_version - 1) + count.index + 1}.0/24"
@santiagopoli
santiagopoli / keypairs.tf
Last active March 18, 2018 22:43
Terraform Blue Green / KeyPair
resource "aws_key_pair" "terraform-blue-green" {
key_name = "terraform-blue-green-v${var.infrastructure_version}"
public_key = "${file("keypairs/keypair.pub")}"
}
@santiagopoli
santiagopoli / instances.tf
Last active March 19, 2018 18:07
Terraform Blue Green / Instances
locals {
subnets = ["${aws_subnet.terraform-blue-green.*.id}"]
user_data = <<EOF
#cloud-config
runcmd:
- docker run -d -p 80:80 nginx:latest
EOF
}