Skip to content

Instantly share code, notes, and snippets.

@marirs
marirs / rust-cross-compile-diesel-postgresql
Last active December 9, 2022 05:11
Rust Cross Compile Diesel-PostgreSQL for Linux on Mac M1
# Download the Source
```bash
cd /tmp/
wget https://ftp.postgresql.org/pub/source/v14.2/postgresql-14.2.tar.gz
tar xvf postgresql-14.2.tar.gz
cd postgresql-14.2
```
# Configure
# - with openssl
@marirs
marirs / rust-cross-compile-openssl
Last active April 4, 2024 05:04
Rust OpenSSL Cross Compile for Linux on Mac M1
# Install the toolchain
```bash
brew tap SergioBenitez/osxct
brew install x86_64-unknown-linux-gnu
```
# this should get installed in:
# /opt/homebrew/Cellar/x86_64-unknown-linux-gnu/
# Installing the macOS OpenSSL - if not already installed
#!/usr/bin/env python3
"""
Very simple HTTP server in python for logging requests including JSON BODY
Usage::
./server.py [<port>]
"""
from http.server import BaseHTTPRequestHandler, HTTPServer
import json
import logging
@marirs
marirs / dedupe_dates.py
Created August 3, 2020 12:18
Given a list of date objects - remove duplicates from that list
#!/usr/bin/env python
import datetime
import time
import calendar
from typing import List
def dedupe_dates(lst: list, precision: str="day", tz_aware: bool=False) -> List:
"""Dedupe a given list of dateobjects
:param lst: list of date objects
@marirs
marirs / csf2csv.py
Last active May 17, 2020 10:57
Python Script to convert CEF to CSV
try:
import re2 as re
except:
import re
import csv
from typing import List, Dict
__all__ = ["cef_to_csv"]
@marirs
marirs / get_domain.py
Last active January 2, 2020 05:31
Extract a Domain name from the url and also check if the domain was IP address or domain name
#!/usr/bin/env python3
from collections import namedtuple
from itertools import groupby
from fastnumbers import isint
from ipaddress import ip_address
def is_ip(test_string):
"""Checks whether a given string contains IP address or IP address with port
:param test_string: The string to test for IP
@marirs
marirs / tarbyYearAndMonth.sh
Created October 16, 2019 02:10
Bash script to Create tar archives by year and month. eg: 201710.tar.gz/201703.tar.gz
#!/bin/bash
# Script to tar all files within a given source directory aggregated by year and month
# generates files like:
# 201701.tar.gz 201805.tar.gz etc...
# Check to see if parallel command & pigz command is available
command -v parallel >/dev/null 2>&1 || { echo >&2 "I require Parallel but it's not installed. Aborting."; exit 1; }
command -v pigz >/dev/null 2>&1 || { echo >&2 "I require Pigz but it's not installed. Aborting."; exit 1; }