Skip to content

Instantly share code, notes, and snippets.

View l1x's full-sized avatar
🏠
Working from home

Istvan l1x

🏠
Working from home
View GitHub Profile
Metric chronyd systemd-timesyncd Difference
PID 2561 344 -
RSS (Physical RAM) 1,188 KiB (~1.2 MB) 7,004 KiB (~6.8 MB) chronyd uses ~83% less RAM
VSZ (Virtual Memory) 8,956 KiB (~8.7 MB) 88,244 KiB (~86.1 MB) chronyd maps ~10x less memory
Command /usr/sbin/chronyd /usr/lib/systemd/systemd-timesyncd -

Alpine

@l1x
l1x / wizardry_8_save_game.txt
Created August 6, 2013 00:25
Wizardry 8 sav files
WIZARDRY 8 HEX-EDIT
By Zyvr (zyvrmaccom)
Steps:
1.Open your save file (/save/*.sav) with a hex-editor.
2.Locate the nick-name of your character.
3.The order of characters' attributes in the .sav is L1-R1-L2-R2-L3-R3.
Each charater takes 1866 bytes.
4.See below for the positions for the attributes. Take the byte which
represents the first letter of the nick name as relative byte 0000.
sp = [
[1, 2, 3],
[8, 9, 4],
[7, 6, 5]
]
def rot90(m):
return list(zip(*m))[::-1]
@l1x
l1x / readme.md
Last active December 12, 2024 14:11
Spiral printing a matrix in Erlang

Spiral printing a matrix in Erlang

This Erlang module implements a function that returns the elements of a 2D matrix (list of lists) in a spiral order. The spiral order starts from the top-left corner and proceeds in a spiral pattern, moving right across the top row, down the right column, left across the bottom row, and up the left column, and continues until all elements are traversed.

Module Overview

-module(spiral).
@l1x
l1x / consumer.js
Last active December 11, 2024 13:37
Reading and writing from/to Kafka with ZSTD compressed messages from Javascript
const { Kafka, logLevel, Partitioners, CompressionTypes, CompressionCodecs } =
require("kafkajs");
const ZstdCodec = require("@kafkajs/zstd");
const compressionParams = { level: 1 };
const decompressionParams = {};
CompressionCodecs[CompressionTypes.ZSTD] = ZstdCodec(
compressionParams,
decompressionParams,
);
@l1x
l1x / merge.parquet.py
Last active August 29, 2024 08:58
Merging Parquet files with Python
import os
import pyarrow.parquet as pq
#
# Warning!!!
# Suffers from the same problem as the parquet-tools merge function
#
#parquet-tools merge:
#Merges multiple Parquet files into one. The command doesn't merge row groups,
#just places one after the other. When used to merge many small files, the
@l1x
l1x / safari.history.md
Last active May 23, 2024 04:32
SQL structure of Safari's history tables
sqlite3 ~/Library/Safari/History.db
sqlite> .tables
history_client_versions  history_items            history_tombstones
history_event_listeners  history_items_to_tags    history_visits
history_events           history_tags             metadata
@l1x
l1x / partition.sql
Last active April 23, 2024 11:36
Creating PostgreSQL table partitions automatically based on the date field (type date as well) -- each day is a single partition
CREATE TABLE testing_partition(patent_id BIGINT, date DATE) WITH ( OIDS=FALSE);
CREATE OR REPLACE FUNCTION create_partition_and_insert() RETURNS trigger AS
$BODY$
DECLARE
partition_date TEXT;
partition TEXT;
BEGIN
partition_date := to_char(NEW.date,'YYYY_MM_DD');
partition := TG_TABLE_NAME || '_' || partition_date;
@l1x
l1x / install_gradle_version_with_homebrew.sh
Created June 17, 2015 19:24
Installing a specific version of Gradle with Homebrew
brew tap homebrew/versions
brew search gradle
brew install homebrew/versions/gradle112
gradle -version
brew link --overwrite gradle112
gradle -version
@l1x
l1x / ntp.erl
Last active March 1, 2023 08:14
NTP client in Erlang
-module(ntp).
-export([get_time/1, get_time/0]).
-define(NTP_PORT, 123). % udp
-define(SERVER_TIMEOUT, 5000). % ms
-define(EPOCH, 2208988800). % offset yr 1900 to unix epoch
ntp_servers() ->
[ "0.europe.pool.ntp.org",