Skip to content

Instantly share code, notes, and snippets.

View aaronpuchert's full-sized avatar

Aaron Puchert aaronpuchert

View GitHub Profile
@aaronpuchert
aaronpuchert / opensuse.db
Last active March 19, 2021 01:44
Generic Squid `store_id_program` for openSUSE mirrors
^http:\/\/.*\/([^:/]+\/(?:[^:/]+:\/)*(?:[^:/]+\/){3}[^/]+.rpm) http://opensuse.squid.internal/$1
@aaronpuchert
aaronpuchert / terminal-colors.sh
Created January 24, 2021 22:27
Testing terminal typesetting
#!/bin/bash
echo -e '\\e[1m \e[1mbold\e[21m \\e[21m'
echo -e '\\e[3m \e[3mitalic\e[23m \\e[23m'
echo -e '\\e[4m \e[4munderline\e[24m \\e[24m'
echo -e '\\e[5m \e[5mblinking\e[25m \\e[25m'
echo -e '\\e[9m \e[9mstrikethrough\e[29m \\e[29m'
echo -e '\\e[53m \e[53moverline\e[55m \\e[55m'
echo -e '\\e[XXm'
for i in $(seq 30 38)
@aaronpuchert
aaronpuchert / clean-ast
Last active April 10, 2021 21:07
Remove some clutter from Clang's AST dump
#!/usr/bin/sed -f
# Remove hard-coded typedefs in the beginning.
2,+13d
# Remove addresses from Stmts, Attrs, Comments.
s/\o033\[0m\o033\[0;1;35m\([A-Za-z]*\)\o033\[0m\o033\[0;33m 0x[0-9a-f]*/\o033[0m\o033[0;1;35m\1\o033[0m\o033[0;33m/g
s/\o033\[0m\o033\[0;1;34m\([A-Za-z]*\)\o033\[0m\o033\[0;33m 0x[0-9a-f]*/\o033[0m\o033[0;1;34m\1\o033[0m\o033[0;33m/g
s/\o033\[0m\o033\[0;34m\([A-Za-z]*\)\o033\[0m\o033\[0;33m 0x[0-9a-f]*/\o033[0m\o033[0;34m\1\o033[0m\o033[0;33m/g
# Remove source locations and ranges.
s/ <\o033\[0;33m[^\o033]*\o033\[0m>//g
s/ <\o033\[0;33m[^\o033]*\o033\[0m, \o033\[0;33m[^\o033]*\o033\[0m>//g
@aaronpuchert
aaronpuchert / CMakeLists.txt
Last active May 30, 2023 21:17
Build LLVM mono repository from root directory
add_subdirectory(llvm)
@aaronpuchert
aaronpuchert / sierpinksi.ps
Created January 6, 2016 18:36
Sierpinski triangle in PostScript
%!PS-Adobe-3.0
%%Creator: Aaron Puchert
%%Title: The Spierpinski triangle
%%Pages: 1
%%PageOrder: Ascend
%%BeginProlog
% PAGE SETTINGS
/pageset {
28.3464566 28.3464566 scale % set cm = 1
@aaronpuchert
aaronpuchert / .Rprofile.R
Last active December 21, 2015 23:09
Initialize "parallel" cluster on R startup
require("utils")
require("parallel")
# do not start in RStudio
if (Sys.getenv("RSTUDIO_USER_IDENTITY") == "" && !file.exists(".cluster")) {
cat(Sys.getpid(), file=".cluster")
Cluster <- makeCluster(detectCores())
}
.First <- function() source("src/main.r") # should load all other sources
@aaronpuchert
aaronpuchert / german.md
Last active November 20, 2022 00:10
Deutsche Wörter im Englischen Sprachgebrauch
@aaronpuchert
aaronpuchert / group_concat.sql
Created July 21, 2013 17:22
This is a group_concat(int) replacement for PostgreSQL.
CREATE OR REPLACE FUNCTION group_concat_iterate(_state INTEGER[], _value INTEGER)
RETURNS INTEGER[] AS
$BODY$
SELECT
CASE
WHEN $1 IS NULL THEN ARRAY[$2]
ELSE $1 || $2
END
$BODY$
LANGUAGE SQL VOLATILE;
@aaronpuchert
aaronpuchert / tree.sql
Created May 11, 2013 17:47
Recursive tree structure in SQLite allowing to get all descendants of an element via storing "intervals" for each node.
PRAGMA recursive_triggers=on;
CREATE TABLE nodes (
id INTEGER NOT NULL,
parent_id INTEGER,
interval_start REAL,
interval_end REAL,
name TEXT NOT NULL,
PRIMARY KEY (id ASC),
FOREIGN KEY (parent_id)
@aaronpuchert
aaronpuchert / alter.sql
Created May 11, 2013 17:27
Alter table in SQLite. This is not possible directly, we need a workaround. This keeps foreign key relations from other tables alive.
CREATE TABLE tab2 (
columns TEXT);
INSERT INTO tab2 (columns) SELECT columns from tab;
DROP TABLE tab;
ALTER TABLE tab2 RENAME TO tab;