Skip to content

Instantly share code, notes, and snippets.

View alexklibisz's full-sized avatar
:octocat:

Alex Klibisz alexklibisz

:octocat:
View GitHub Profile
@alexklibisz
alexklibisz / export-firefly-iii-transactions.sql
Created November 18, 2023 21:26
Export Transactions from Firefly-III Database
-- Export Transactions from Firefly-III Database
-- This query produces a reasonable CSV export of transactions from a Firefly-III database.
-- Adjust the user_id if you have multiple users.
-- Tested on Postgres.
select cast(tj.date as date) as date,
tj.description as description,
round(tcredit.amount, 2) as credit_amount,
acredit.name as credit_account,
round(tdebit.amount, 2) as debit_amount,
adebit.name as debit_account,

Benchmarks, tricky queries, etc.

@alexklibisz
alexklibisz / elastiknn-big-ann-benchmarks-setup.md
Last active October 15, 2021 16:06
Elastiknn / Big-ann-benchmarks Setup

This document describes how to run Elastiknn on the big-ann-benchmarks challenge. It's admittedly a little late in the game for this benchmarking challenge. IIRC the deadline is October 22, 2021, and I'm writing this on October 15. But hey, the neighbors aren't gonna find themselves. We can still use this as an opportunity to improve Elastiknn.

The setup is currently pretty experimental, so bring your elbow grease.

Part 1: Setup the Elastiknn project

  1. Clone the alexklibisz/elastiknn repo and checkout the elastiknn-278-lucene-benchmarks branch. That's where I've been working on the big-ann-benchmarks integration and improvements.
git clone git@github.com:alexklibisz/elastiknn.git
git fetch --all
@alexklibisz
alexklibisz / ShortMinHeap.java
Created August 29, 2021 21:22
Java Minheap based on Python standard library implementation
package com.klibisz.elastiknn.search;
/**
* Min heap where the values are shorts. Useful for tracking top counts for a query.
* Based on the Python std. lib. implementation: https://docs.python.org/3.8/library/heapq.html#module-heapq
*/
public class ShortMinHeap {
private short[] heap;
private int size;
private final int capacity;
@alexklibisz
alexklibisz / 1-readme.md
Last active June 26, 2021 16:46
PDCI Scala Implementation

This is a very rough first-pass Scala implementation of the PDCI algorithm for nearest neighbor search.

It's quite an interesting algorithm but I found it difficult to implement efficiently on the JVM. I'm pretty sure this will compile and run, but also I last touched this code in March 2019, so who knows :).

The build.sbt includes some unnecessary dependencies, as this was pulled out of a private repo containing other experiments which eventually became Elastiknn.

@alexklibisz
alexklibisz / 0-firefly-grafana-example.md
Last active October 30, 2022 12:12
Firefly + Grafana Example
@alexklibisz
alexklibisz / fixtransfers.py
Last active January 29, 2023 04:46
Python script for the Firefly-III personal finance app. Finds and merges equivalent Withdrawal/Deposit pairs into a single Transfer. See also: https://www.reddit.com/r/FireflyIII/comments/lwuzia/hide_certain_categories/
import os
import sys
import requests
from pprint import pprint
from datetime import datetime
from dataclasses import dataclass
from time import time
@dataclass
class Transaction:
------------------------------------------------------
_______ __ _____
/ ____(_)___ ____ _/ / / ___/_________ ________
/ /_ / / __ \/ __ `/ / \__ \/ ___/ __ \/ ___/ _ \
/ __/ / / / / / /_/ / / ___/ / /__/ /_/ / / / __/
@alexklibisz
alexklibisz / example.py
Created February 12, 2019 01:58
Using a threadpool to speedup S3 downloads in Python
from concurrent.futures.thread import ThreadPoolExecutor
from pprint import pprint
from time import time
import boto3
import os
import botocore
import shell as shell
@alexklibisz
alexklibisz / ec2-es-run.sh
Last active October 7, 2018 02:15
Elasticsearch Cluster Setup on AWS
# !/bin/sh
set -e
# Get the amount of available memory using some hacky python
MAXMEM=$(python -c "import os; print('%dg' % (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024 ** 3)))")
# Define the Elasticsearch java options
export ES_JAVA_OPTS="-Xms$MAXMEM -Xmx$MAXMEM"
# Increase memory setting for Elasticsearch.