Skip to content

Instantly share code, notes, and snippets.

View sshaplygin's full-sized avatar
🎯
Focusing

Semen Shaplygin sshaplygin

🎯
Focusing
  • Belgrade, Republic of Serbia
  • 22:38 (UTC +02:00)
  • X @sshaplygin
View GitHub Profile
@sshaplygin
sshaplygin / main.py
Last active December 9, 2023 14:24
Adventofcode 2023 day 4
def get_text(is_test = False):
if is_test:
return [
'Card 1: 41 48 83 86 17 | 83 86 6 31 17 9 48 53',
'Card 2: 13 32 20 16 61 | 61 30 68 82 17 32 24 19',
'Card 3: 1 21 53 59 44 | 69 82 63 72 16 21 14 1',
'Card 4: 41 92 73 84 69 | 59 84 76 51 58 5 54 83',
'Card 5: 87 83 26 28 32 | 88 30 70 12 93 22 82 36',
'Card 6: 31 18 13 56 72 | 74 77 10 23 35 67 36 11',
]
@sshaplygin
sshaplygin / main.py
Last active December 9, 2023 11:54
Adventofcode 2023 day 2
def get_text(is_test = False):
if is_test:
return [
'Game 1: 3 blue, 4 red; 1 red, 2 green, 6 blue; 2 green',
'Game 2: 1 blue, 2 green; 3 green, 4 blue, 1 red; 1 green, 1 blue',
'Game 3: 8 green, 6 blue, 20 red; 5 blue, 4 red, 13 green; 5 green, 1 red',
'Game 4: 1 green, 3 red, 6 blue; 3 green, 6 red; 3 green, 15 blue, 14 red',
'Game 5: 6 red, 1 blue, 3 green; 2 blue, 1 red, 2 green',
]
@sshaplygin
sshaplygin / main.py
Last active December 7, 2023 15:18
Adventofcode 2023 day 3
def get_text(is_test = False):
if is_test:
return [
'467..114..',
'...*......',
'..35..633.',
'......#...',
'617*......',
'.....+.58.',
'..592.....',
@sshaplygin
sshaplygin / main.py
Last active December 4, 2023 08:05
Adventofcode 2023 day 1
def countCalibrationValue(text):
count = 0
for row in text:
i, j = 0, len(row)-1
while i <= j:
if row[i].isdigit() and row[j].isdigit():
count += int(row[i] + row[j])
break
if not row[i].isdigit():
i += 1
@sshaplygin
sshaplygin / trait.rs
Created July 4, 2023 14:31
Example usage vector with objects witch implemented common trait
trait Figure {
fn area(&self) -> f64;
}
struct Circle {
radius: f64,
}
struct Rectangle {
a: f64,
@sshaplygin
sshaplygin / create_user.sh
Created May 28, 2023 10:38
create new user for wireguar server
#!bin/bash
NEW_USER=$NEW_USER_NAME
LAST_IP=$LAST_LOCAL_IP_SERVER_CONFIGURE
cd /etc/wireguard && mkdir "${NEW_USER}"
wg genkey | tee /etc/wireguard/"${NEW_USER}"/privatekey | wg pubkey | tee /etc/wireguard/"${NEW_USER}"/publickey
echo "configured keys for new user:" "${NEW_USER}"
@sshaplygin
sshaplygin / change_name.sh
Created April 30, 2023 19:39
This script witch change git author 's name from commits
git filter-branch --env-filter '
WRONG_EMAIL="wrong@example.com"
NEW_NAME="New Name Value"
NEW_EMAIL="correct@example.com"
if [ "$GIT_COMMITTER_EMAIL" = "$WRONG_EMAIL" ]
then
export GIT_COMMITTER_NAME="$NEW_NAME"
export GIT_COMMITTER_EMAIL="$NEW_EMAIL"
fi
from mp4 to wav format `ffmpeg -i <infile> -ac 2 -f wav <outfile>`
join wav files `ffmpeg -i 1.wav -i 1.wav -i 1.wav -i 1.wav \
-filter_complex '[0:0][1:0][2:0][3:0]concat=n=4:v=0:a=1[out]' \
-map '[out]' output.wav`
@sshaplygin
sshaplygin / README.md
Last active April 5, 2023 20:00
How increase memory allocation by append to ints slice in golang

Plot Legend:

x - allocation number
y - diff allocated at iteration between old and new memory

“plot”

@sshaplygin
sshaplygin / README.MD
Last active July 17, 2022 17:09
Build and upload c/cpp code to Arduino microcontroller by avr-gcc, avr-objedump, avrdude

Scheme build and upload cpp code into Arduino:

Example by docs

Снимок экрана 2022-07-17 в 17 27 46

Usage

  • Install gcc, avr-gcc, avr-objcopy, avrdude
  • Use updaload.sh