Skip to content

Instantly share code, notes, and snippets.

View Zejnilovic's full-sized avatar

Saša Zejnilović Zejnilovic

View GitHub Profile
@Zejnilovic
Zejnilovic / EMOJIS.md
Last active January 21, 2026 00:03
GitHub emoji list (auto-generated)

GitHub Emojis

This document is automatically generated from the GitHub Emoji API. Emoji categories are derived from the official Unicode emoji definitions. Emojis not defined by Unicode are listed under GitHub-Only.

GitHub-Only

Code Emoji Code Emoji
@Zejnilovic
Zejnilovic / pdf_splitter_generic.py
Created January 19, 2026 12:35
Generic PDF text splitter - organizes extracted PDFs into section files using configurable regex patterns
#!/usr/bin/env python3
"""
Generic PDF Text Splitter
Splits extracted PDF text into multiple files based on chapter/section patterns.
Usage:
python3 pdf_splitter.py --input input.txt --output ./sections --pattern "^(\d+)\.\s+(.+)$"
python3 pdf_splitter.py --input input.txt --output ./sections --pattern "^Chapter\s+(\d+):\s+(.+)$"
python3 pdf_splitter.py --input input.txt --output ./sections --pattern "^#+\s+(.+)$" # Markdown headers
"""
@Zejnilovic
Zejnilovic / github_ref.lua
Created January 5, 2026 10:34
A small Neovim helper that opens GitHub references under the cursor (or visual selection) in a browser. This is editor-native. No plugins, no API calls, no Tree-sitter, no LSP. Just Lua.
--[[
github_ref.lua
A small, editor-native Neovim helper for opening GitHub references found
under the cursor or in a visual selection.
This file intentionally avoids plugins, GitHub API calls, Tree-sitter,
LSP integration, or background jobs. It is designed to be fast, predictable,
and usable anywhere text appears (code, documentation, comments, or notes).
@Zejnilovic
Zejnilovic / activate_env.sh
Created November 12, 2023 09:15
Function to easily select venv if you have more then one.
function activate_env() {
# Get
local filtered_envs=($(find . -maxdepth 1 -type d -exec test -e '{}/bin/activate' \; -print))
# If no environments found
if [[ ${#filtered_envs[@]} -eq 0 ]]; then
echo "No suitable environments found."
return
fi
@Zejnilovic
Zejnilovic / SparkApp.scala
Created December 7, 2021 11:59
SPNEGO Auth in Scala / Java
import org.apache.spark.sql.SparkSession
import org.slf4j.LoggerFactory
import sun.security.krb5.internal.ktab.KeyTab
import org.springframework.security.kerberos.client.KerberosRestTemplate
object SparkApp {
def main(args: Array[String]) {
// Spark session is obsolete, but I needed it to test it as a spark app
val spark = SparkSession.builder.appName("KerberosTest Spark Job").getOrCreate()
val logger = LoggerFactory.getLogger(this.getClass)
@Zejnilovic
Zejnilovic / hadoop_remove_old_tmp.sh
Created August 17, 2020 16:30
Remove old files from Hadoop tmp
today=`date +'%s'` # date today
files=`hdfs dfs -ls /tmp | tail -n +2` # all files in tmp
granularity=$(( 24*60*60 )) # granularity of time. Now set to days
olderThan=7 # granularity times olderThan gives you what age files should be deleted
for line in $files; do
dir_date=$(echo ${line} | awk '{print $6}')
# difference=$(( ( ${today} - $(date -j -u -f "%Y-%m-%d %H:%M" ${dir_date} +%s) ) / ${granularity} )) # MacOS
difference=$(( ( ${today} - $(date -d ${dir_date} +%s) ) / ${granularity} )) # Linux
filePath=$(echo ${line} | awk '{print $8}')
@Zejnilovic
Zejnilovic / stupid_hdfs_backup.sh
Created April 27, 2020 08:48
A simple HDFS backup for local playing
#!/bin/bash
now=$(date +"%Y_%m_%d")
file=hadoop_backup_$now
cd ~
mkdir -p $file
hdfs dfs -ls / | grep "^[d-]"| awk '{print $8}' | while read line; do hdfs dfs -get $line $file ; done
zip -r $file.zip $file
@Zejnilovic
Zejnilovic / docker-compose.yaml
Last active February 6, 2020 13:35
Docker compose for menas
---
version: '3'
services:
arangodb:
image: arangodb:3.5.1
environment:
ARANGO_NO_AUTH: 1
volumes:
- /tmp/arangodb:/var/lib/arangodb3
@Zejnilovic
Zejnilovic / decismal_38_18_transformer.js
Last active July 29, 2019 14:10
Smart JSON Editor transformer for Decimal(38,18)
// https://github.com/SmartJSONEditor/PublicDocuments/wiki/ValueTransformers
var ValueTransformer = function () {
this.displayName = "Decimal(38,18)";
this.shortDescription = "https://spark.apache.org/docs/2.4.0/api/java/org/apache/spark/sql/types/Decimal.html"
this.transform = function (inputValue, jsonValue, arrayIndex, parameters, info) {
var result = '';
var characters = '0123456789';
var charactersLength = characters.length;
var precision = 38;
@Zejnilovic
Zejnilovic / ssh_to_any_server.sh
Created July 26, 2019 11:13
Connect to one of the servers
#!/bin/bash
# Switch this for the list of addresses you want to ssh to
ADDRESS=(127.0.0.1 localhost)
# Switch this for the name of the user you are sshing as
NAME=`echo $USER`
for i in $ADDRESS
do
echo "Trying to connect as $NAME to $i"