Skip to content

Instantly share code, notes, and snippets.

# http://adventofcode.com/2017/day/3
defmodule Day3 do
require Integer
def part1(square) do
final_point =
memory_points()
|> Stream.drop_while(&(&1.square != square))
|> Enum.take(1)
# http://adventofcode.com/2017/day/2
defmodule Day2 do
def checksum1(rows), do:
rows
|> Enum.map(&row_checksum1/1)
|> Enum.sum()
defp row_checksum1(row) do
{min, max} =
# http://adventofcode.com/2017/day/1
defmodule Day1 do
def sum1(digits), do:
digits
|> Stream.concat(Enum.take(digits, 1))
|> Stream.chunk_every(2, 1, :discard)
|> Stream.filter(&match?([el, el], &1))
|> Stream.map(&hd(&1))
|> Enum.sum()
@b1ackmartian
b1ackmartian / .travis.yml
Last active December 6, 2017 14:20
Travis CI Gigalixir Deploy
language: elixir
elixir: 1.5.2
otp_release: '19.0'
script:
- mix test && ./deploy.sh
# The decimal number, 585 = 10010010012 (binary), is palindromic in both bases.
# Find the sum of all numbers, less than one million, which are palindromic in base 10 and base 2.
# (Please note that the palindromic number, in either base, may not include leading 0's)
# Naive approach - TODO: needs to avoid checking both base 2 and base 10 if base 10 isn't pallindromic
def palindromic?(n, base = 10)
numbers = n.to_s(base).split("")
middle = numbers.length / 2.0
first_half = numbers.slice(0, middle.ceil)
second_half = numbers.slice(middle.floor, numbers.length)
@VladimirPal
VladimirPal / neomuttrc
Last active May 15, 2025 09:56
Minimal neomutt config for gmail imap
set imap_user="[email protected]"
set imap_pass=`/usr/bin/security find-generic-password -w -a '[email protected]' -s 'Gmail'`
set folder=imaps://imap.gmail.com/
set spoolfile=+INBOX
set record="+[Gmail]/Sent Mail"
set postponed="+[Gmail]/Drafts"
# https://www.neomutt.org/guide/reference search sleep_time for additional info
set sleep_time=0 # be faster
@antonbabenko
antonbabenko / README.md
Created October 31, 2017 08:45
Example of using terraform-aws-modules/vpc/aws module with Terragrunt

This is an example of how to use Terraform AWS registry modules with Terragrunt.

Notes:

  1. source has to be full git URL and not Terraform Registry open issue #311
  2. File main_providers.tf is named so, because it will be copied to another local directory and merged with module's code. If such file exists in the module already then it will overwrite the one provided by the module.
@boydm
boydm / map_difference.ex
Last active December 21, 2019 12:14
Elixir meyers_difference for Maps
defmodule Boydm.Utilities.Map do
#============================================================================
# similar to List.meyers_difference, the below code compares two maps
# and generates a list of actions that can be applied to the first map
# to transform it into the second map.
#--------------------------------------------------------
def difference(map_1, map_2) when is_map(map_1) and is_map(map_2) do
# remove any keys from map_1 that are simply not present (at all) in map_2
@tuannvm
tuannvm / 0.12.tf
Last active December 3, 2022 18:50
#terraform #hashicorp #cheatsheet #0.12
#### first class expresssion
variable "ami" {}
resource "aws_instance" "example" {
ami = var.ami
}
#### list & map
resource "aws_instance" "example" {
vpc_security_group_ids = var.security_group_id != "" ? [var.security_group_id] : []
}