This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from user_agent_parser import UserAgentParser | |
from syslogng.message import LogMessage | |
import pytest | |
@pytest.fixture | |
def no_config(): | |
return { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
def unwrap(message, address): | |
address = address.decode("utf-8") | |
result = re.search(r"\ASRS0=[^=]+=[^=]+=(?P<domain_name>[^=]+)=(?P<local_part>[^@]+)@", address) | |
if result == None: | |
result = re.search(r"\ASRS1=[^=]+=[^=]+==[^=]+=[^=]+=(?P<domain_name>[^=]+)=(?P<local_part>[^@]+)@", address) | |
if result == None: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plan aoc::day5 ( | |
Boolean $sample = false, | |
) { | |
$file = $sample ? { | |
false => 'aoc/2022/day5.txt', | |
true => 'aoc/2022/day5.sample.txt', | |
} | |
$lines = file($file).split('\n') | |
$separator = $lines.index |$value| { $value.empty } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plan aoc::day4 ( | |
Boolean $sample = false, | |
) { | |
$file = $sample ? { | |
false => 'aoc/2022/day4.txt', | |
true => 'aoc/2022/day4.sample.txt', | |
} | |
$data = file($file).split('\n').map |$line| { | |
$line.split(',').map |$part| { | |
$part.split('-').map |$n| { Integer($n) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function aoc::letter2number(String $n) >> Integer { | |
$offset = $n ? { | |
/[a-z]/ => 1, | |
/[A-Z]/ => 27, | |
} | |
'abcdefghijklmnopqrstuvwxyz'.index |$char| { $char == $n } + $offset | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$data = file('aoc/2022/day2.txt') | |
$rounds = $data.split('\n').map |$line| { [$line[0], $line[2]] } | |
$scores1 = $rounds.map |$round| { | |
$shape_score = $round[1] ? { | |
'X' => 1, | |
'Y' => 2, | |
'Z' => 3, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$each_elf_carry_as_string = file('aoc/day1.txt').split('\n\n') | |
$each_elf_carry_as_array_of_integers = $each_elf_carry_as_string.map |$value| { $value.split('\n').map |$value| { Integer($value) } } | |
$each_elf_total_carry = $each_elf_carry_as_array_of_integers.map |$carry| { $carry.reduce |$memo, $value| { $memo + $value } } | |
warning($each_elf_total_carry.max) | |
warning($each_elf_total_carry.sort[-3, -1].reduce |$memo, $value| { $memo + $value }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# /usr/local/bin/pulseaudio-pcm | |
set -x | |
/usr/bin/logger "$0 $*" | |
action=$1 | |
case $action in | |
attach) | |
pcm=$2 dsp=dsp${2#pcm} uaudio=$3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# site-modules/profile/manifests/base/linux.pp | |
class profile::base::linux { | |
# [...] | |
if fact('mountpoints').map |$mountpoint, $info| { $info['device'] }.any |$device| { $device =~ '^/dev/md' } { | |
@concat::fragment { 'riemann-wrapper-md': | |
target => '/etc/riemann-wrapper.yml', | |
order => '10', | |
content => @("CONFIG"), | |
- name: "md" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/opt/puppetlabs/puppet/bin/ruby | |
# Gather the value of a Riemann metric for each node in PupppetDB | |
require 'optparse' | |
require 'puppetdb' | |
require 'riemann' | |
usage = "usage: #{$PROGRAM_NAME} [metric]" |
NewerOlder