Skip to content

Instantly share code, notes, and snippets.

@apetenchea
apetenchea / audiotext.py
Last active June 2, 2023 19:07
Text to speech in Python
# importing libraries
import pathlib
import sys
import speech_recognition as sr
import os
from pydub import AudioSegment
from pydub.silence import split_on_silence
# create a speech recognition object
r = sr.Recognizer()
@apetenchea
apetenchea / async-job.py
Last active May 19, 2023 18:37
Using async jobs in python-arango
import arango
import time
url = f"http://localhost:8530"
client = arango.ArangoClient(hosts=url)
db = client.db(name="_system")
print(db.version())
if not db.has_collection('x'):
db.create_collection('x')
@apetenchea
apetenchea / arangodb-cluster.md
Last active November 23, 2023 11:25
Starting an arangodb cluster using docker-compose

This is in response to issue #18900.
It shows how to set up an arangodb cluster with 3 agents, 2 coordinators and 3 db severs, using docker-compose. This is not the way I would set up a cluster in production, but it is ok for testing the cluster functionality. I recommend checking out the official documentation, especially Using the ArangoDB Starter.

docker-compose.yml

version: '3.7'
@apetenchea
apetenchea / mealplan.py
Created April 28, 2023 17:55
Mealplan parser
# Script for parsing mealplans and generating a shopping list
# python mealplan.py mealplan.txt > list.txt
import sys
import re
def get_lines(file):
names = ['Alex', 'Lucia']
@apetenchea
apetenchea / dumpall.sh
Created March 28, 2023 16:23
Generate core dumps for all arangod processes
#!/bin/bash
if [ $# -eq 0 ]; then
proc="$(ps aux | grep arangod | grep -v grep)"
else
proc="$(ps aux | grep arangod | grep -v grep | grep $1)"
fi
echo "$proc" > ps.txt
#!/bin/bash
# create build directory
mkdir -p build
# run cmake
(cd build && cmake \
-DCMAKE_CXX_COMPILER="clang++" \
-DCMAKE_C_COMPILER="clang" \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
# My own Dockerfile for building arangodb using gcc-11.2
# docker run -it -v /local/path/to/arangodb:/arangodb gcc-11.2 /bin/bash
FROM gcc:11.2.0
WORKDIR /arangodb
RUN apt-get -y update && apt-get install -y build-essential libssl-dev libjemalloc-dev python libldap2-dev ripgrep
RUN wget https://github.com/Kitware/CMake/releases/download/v3.23.3/cmake-3.23.3-Linux-x86_64.sh \
-q -O /tmp/cmake-install.sh \
&& chmod u+x /tmp/cmake-install.sh \
&& mkdir /usr/bin/cmake \
@apetenchea
apetenchea / permissions.sh
Created July 8, 2022 11:20
CLion remote editing fix
#!/bin/bash
# Fix file permissions after setting up remote development with CLion
# Run this in the root of your project folder
dir=$(pwd)
for f in $(rg -l "\#!")
do
echo "$f"
cd $(dirname "$f")
// Example of a constant being modified
// clang++ -Wall -std=c++17 -O2 -o modify_const modify_const.cpp
#include <iostream>
#include <string>
#include <sstream>
unsigned long long hex_to_dec(std::string str)
{
unsigned long long result = 0;
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.