Skip to content

Instantly share code, notes, and snippets.

@gizlu
gizlu / embed_sqlite_db.c
Created August 30, 2022 18:17
Example of readonly sqlite database embedded within c executable
#include <stdio.h>
#include <stdlib.h>
#include "sqlite3.h"
// example of readonly sqlite database embedded within c executable
// db_img array was produced by executing `xxd -i` on this simple db:
// CREATE TABLE foo (bar int);
// INSERT INTO foo (bar) VALUES (5),(2137),(44)
//
// gcc -lsqlite3 embed_sqlite_db.c
@gizlu
gizlu / rundeck_db_build.sh
Last active January 10, 2024 00:24
LoR database builder
#!/bin/sh
# hackish, unpolished shellscript that downloads LoR jsons and images, compresses
# pngs to verry lossy webps and pack that to single file sqlite database.
# It is practical usage example of sunzip-stout
# installation:
# - make sure you have curl, sqlite3 and cwebp in your system
# - build sunzip-stout and place it in your path: https://github.com/gizlu/sunzip-stout
#
# I have never played Legends of Runeterra and don't have any real usage for this
@gizlu
gizlu / kill-children.pl
Last active June 19, 2022 14:33
simple, "smart" child kiling scheme. Perl snippet copy pasted from 20120122 release of GNU parallel.
# Copyright (C) 2007,2008,2009,2010,2011,2012 Ole Tange and Free Software
# Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
@gizlu
gizlu / b64_lookup_gen.c
Last active June 4, 2022 13:45
script generating lookup table for base64 decoding
#include <stdint.h>
#include <stdio.h>
void pprint(uint8_t* arr, int size)
{
printf("uint8_t lookup[%d] = {", size);
for(int i = 0; i < size-1; ++i) {
printf("%u,", arr[i]);
}
printf("%u};\n", arr[size - 1]);
@gizlu
gizlu / screenshot.sh
Created January 3, 2022 22:30
simple screenshot shellscript that copy images to clipboard & saves them with timestamp in name. Deps: maim, xclip
#!/bin/sh
# Do screenshoot of selected area/current window/fullscreen.
# Copy it to clipboard and save on disk with current time as filename
# License: gizlu 2021, do what the heck you want
filename=~/Pictures/screeny/$(date +%F-%T).png
case $1 in
select)