Skip to content

Instantly share code, notes, and snippets.

View aseelye's full-sized avatar

aseelye

View GitHub Profile
@aseelye
aseelye / pointers.c
Created January 5, 2021 02:56
pointer inconsistency
#include <stdio.h>
void presto_changeo(char *msg, int *x) {
msg[0] = 'B';
*x += 1;
}
int main() {
int x = 0;
char msg[] = "Test message";
@aseelye
aseelye / 10_dev.py
Created December 10, 2020 18:23
Aoc Day 10 draft, choking on recursive
from copy import copy
import time
def find_list(in_list: list) -> type(None):
global good_lists
in_list = sorted(in_list)
if valid_list(in_list) and tuple(in_list) not in good_lists:
good_lists.add(tuple(in_list))
if len(good_lists) % 100 == 0:
@aseelye
aseelye / 09_timing.py
Created December 10, 2020 00:12
AoC day 9 with timing
from itertools import combinations, permutations
import sys
import time
def validate_xmas(validate_list: list, preamble_len: int = 5) -> int:
"""
takes list, returns the first item that doesn't fit, otherwise returns -1 for a valid list
:param validate_list:
:param preamble_len:
@aseelye
aseelye / 09.py
Created December 9, 2020 05:31
AoC day 09
from itertools import combinations
def validate_xmas(validate_list: list, preamble_len: int = 5) -> int:
"""
takes list, returns the first item that doesn't fit, otherwise returns -1 for a valid list
:param validate_list:
:param preamble_len:
:return:
"""
@aseelye
aseelye / 08.py
Created December 8, 2020 07:45
AoC Day 08
def run_instruction(line: str, score: int) -> tuple[int, int]:
global next_instruction
"""
reads instruction, returns tuple of score and next instruction relative to where it was.
:param line:
:return:
"""
inst, number = line.split()
number = int(number)
if inst == 'acc':
@aseelye
aseelye / 06.py
Created December 6, 2020 19:10
AoC Day 6
from collections import defaultdict
def group_score(group: str) -> int:
"""
return number of unique yes answers for a single group
:param group:
:return:
"""
answer_set = set()
@aseelye
aseelye / 05.py
Last active December 5, 2020 07:31
AoC 2020 day 05
import numpy as np
from typing import Tuple
def basic_decode(row_seat: str) -> Tuple[int, int]:
row = '0b' + row_seat[:7]
row = row.replace('F', '0').replace('B', '1')
row = int(row, 2)
seat = '0b' + row_seat[7:]
seat = seat.replace('L', '0').replace('R', '1')
@aseelye
aseelye / 03.py
Created December 3, 2020 16:37
AoC 2020 Day 3
from typing import Tuple
def check_collisions(r_move: int, d_move: int, hill: list[str], start: Tuple[int, int] = (0, 0)) -> int:
d_dist = len(hill)
r_dist = len(hill[0])
d_pos, r_pos = start
trees_hit = 0
while d_pos < d_dist:
if hill[d_pos][r_pos] == '#':
@aseelye
aseelye / debian-init.sh
Created July 16, 2019 17:41 — forked from andsens/debian-init.sh
This is a generic init-script, easily modifiable to suit your needs. It uses quite a lot of lsb init-functions and adheres to the lsb standards.
#!/bin/sh
### BEGIN INIT INFO
# Provides: generic-prog
# Required-Start: $local_fs $remote_fs $network
# Required-Stop: $local_fs $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Generic Program
# Description: Generic Program is a generic program to do generic things with
### END INIT INFO
<?xml version="1.0"?>
<scenario name="aaron1">
<pause milliseconds="1000"/>
<send retrans="500">
<![CDATA[
INVITE sip:[field0]@[remote_ip]:[remote_port] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: "sipp" <sip:sipp@[local_ip]:[local_port]>;tag=[call_number]
To: <sip:[service]@[remote_ip]:[remote_port]>
Call-ID: [call_id]