Skip to content

Instantly share code, notes, and snippets.

View marekciupak's full-sized avatar

Marek Ciupak marekciupak

  • Krakow, Poland
View GitHub Profile
@marekciupak
marekciupak / testlist5
Last active September 13, 2023 07:55
test domains blocking
[Adblock Plus 2.0]
||cacaoda.com^
||onet.pl^$all
||wp.pl^
||interia.pl^
@marekciupak
marekciupak / coreos.ign
Last active November 9, 2022 16:24
Actual coreos.ign
{
"ignition": {
"version": "3.3.0"
},
"passwd": {
"users": [
{
"groups": [
"docker",
"sudo",
@marekciupak
marekciupak / coreos.ign
Last active November 9, 2022 15:48
coreos.ign
{
"ignition": {
"config": {
"replace": {
"source": "https://gist.githubusercontent.com/marekciupak/e47459ec0a5e9a93f5878b8e07424c6f/raw/coreos.ign"
}
},
"version": "3.3.0"
}
}
@marekciupak
marekciupak / .rubocop.yml
Last active January 28, 2022 17:17
.rubocop.yml
AllCops:
NewCops: enable
Exclude:
- 'db/schema.rb'
- 'vendor/**/*'
Layout/EndOfLine:
EnforcedStyle: lf
Layout/EmptyLineAfterGuardClause:
@marekciupak
marekciupak / validating_http_parameters.md
Last active March 18, 2024 17:53
Ruby on Rails: Validating HTTP parameters

Validating HTTP parameters

Let's say you need to handle the following action:

class UsersController < ApplicationController
  def update
    user = User.find(id)
    result = update_user(user, attrs)
    
@marekciupak
marekciupak / day18.exs
Created March 26, 2019 13:31
Day 18 - Advent of Code 2018
# https://adventofcode.com/2018/day/18
defmodule Day18 do
def parse_input(input) do
input
|> String.split("\n", trim: true)
|> Enum.reduce({%{}, 0}, fn line, {area, y} -> {parse_next_line(area, line, y), y + 1} end)
|> elem(0)
end
@marekciupak
marekciupak / 2017_day3_part1.exs
Last active January 28, 2019 21:50
Day 3 Part 1 - Advent of Code 2017
defmodule Day3 do
require Integer
def part1(location) do
width = width(location)
steps = steps(location, width)
distance(steps, width)
end
def width(location) do
@marekciupak
marekciupak / day15.exs
Created January 16, 2019 20:06
Day 15 - Advent of Code 2018
# https://adventofcode.com/2018/day/15
defmodule Day15 do
@default_attack_power 3
def parse_map(input) do
input
|> String.split("\n", trim: true)
|> Enum.reduce({0, %{}}, fn row, {y, map} ->
{y + 1, parse_row(map, row, y)}
@marekciupak
marekciupak / day13.exs
Created January 7, 2019 22:27
Advent of Code 2018 - Day 13
defmodule Day13 do
def parse(input) when is_binary(input) do
input
|> String.split("\n", trim: true)
|> parse
end
def parse(_rows, y \\ 0, acc \\ {%{}, []})
def parse([row | rest], y, {acc_map, acc_carts}) do