Skip to content

Instantly share code, notes, and snippets.

View aramperes's full-sized avatar
:shipit:

Aram Peres aramperes

:shipit:
View GitHub Profile
@aramperes
aramperes / vector_http_amqp.yaml
Created March 11, 2025 00:27
Example Vector config to pipe HTTP JSON to AMQP, with a routing key
# Example: curl http://localhost:8000 --data '{"nested": {"flowID": "world"}, "data": "hello"}'
sources:
in:
type: http_server
address: 0.0.0.0:8000
codec: json
transforms:
remap:
@aramperes
aramperes / aoc_2024_d3_solve1.sh
Created December 20, 2024 02:28
Advent of Code 2024 Day 3 - Bash
#!/bin/bash
# cat input.txt | ./solve1.sh
grep -Po 'mul\(\d+,\d+\)' |
sed -r 's/^mul\(([0-9]+),([0-9]+)\)$/\1*\2/' |
xargs |
sed -e 's/\ /+/g' |
xargs -I @@ bash -c 'echo $((@@))'
@aramperes
aramperes / aoc_2024_d2_solve1.sh
Created December 20, 2024 01:27
Advent of Code 2024 Day 2 - Bash
#!/bin/bash
# cat input.txt | ./solve1.sh
while read -r rpt; do
echo "$rpt" |
sed 's/\s\+/\n/g' |
sort -n |
xargs |
while read -r srt; do
echo "$rpt" |
@aramperes
aramperes / aoc_2024_d1_solve1.sh
Last active December 20, 2024 01:25
Advent of Code 2024 Day 1 - Bash
#!/bin/bash
dbg="+x"
set "$dbg"
in="$1"
awk '{print $1}' "$in" |\
sort |\
nl -bt -nln |\
xargs -I '{}' bash $dbg -c "\\
@aramperes
aramperes / example.sh
Created June 3, 2023 19:43
A leaner __git_ps1 function (~50%) for slow systems
# Original __git_ps1
$ time orig__git_ps1 || 0
(my-branch)
real 0m1.102s
user 0m0.000s
sys 0m0.140s
# Lean function
$ time __git_ps1 || 0
(my-branch)
@aramperes
aramperes / vimnotes.md
Last active May 25, 2021 07:21
My personal notebook for day-to-day vim usage

vimnotes

My personal notebook for day-to-day vim usage.

Individual commands (normal mode)

  • i / [Insert] enters insert mode at current character
  • I enters insert mode at beginning of line
  • a enters insert mode at next character
  • A enters insert mode at end of line
  • $ goto end of line
@aramperes
aramperes / sorting.rs
Created January 22, 2020 06:01
Some sorting algorithms implemented in Rust, with tests
/// Some sorting algorithms written in Rust.
fn insertion_sort(vec: &mut Vec<i32>) {
let length: i32 = vec.len() as i32;
if length < 2 {
// Vector is already sorted if of length 0 or 1
return;
}
package tictactoegame.ui;
import javax.swing.*;
import java.awt.*;
public class SwingTicTacToe extends JFrame {
/**
* The font used for the buttons.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <limits.h>
#include <sys/mount.h>
extern char * ffmount(char *path)
{
int rc;
@aramperes
aramperes / road_navigation.py
Created June 17, 2018 01:01
My solution to the "Road navigation" edabit challenge
# coding=utf-8
import json
import os
def neighbours_of(edges, node):
neighbours = []
for edge in edges:
if node in edge:
neighbours.append(edge[0 if edge[1] == node else 1])