Skip to content

Instantly share code, notes, and snippets.

@basinilya
basinilya / rrd-backup.txt
Created May 26, 2015 18:37
OpenWrt collectd survive reboot
cat <<'EOFFILE' >/usr/local/bin/rrd-backup
#!/bin/sh
set -e
mkdir -p /usr/local/share/rrd
cd /tmp
chsum_prev=`tar -cf - rrd | md5sum`
while true; do
chsum=`tar -cf - rrd | tee rrd.tar | md5sum`
@basinilya
basinilya / hugebuf.sh
Last active April 14, 2024 10:27
https://stackoverflow.com/q/68469752/447503 svnsync cannot recover from source idle disconnect
#!/bin/bash
# usage:
# socat TCP-LISTEN:3128,reuseaddr,fork EXEC:"./hugebuf.sh -p",nofork
set -e
proxymode=
case $1 in
@basinilya
basinilya / mxmoduleclean
Last active February 6, 2024 16:18
mxmoduleclean
#!/bin/bash
#
# delete *.Required* marker files belonging to a Mendix module and delete their
# *.jar files unused by other modules
#
# Usage:
# cd userlib
# # delete module:
# mxmoduleclean MODULE
# # delete everything except MODULE
#!/bin/bash
# print base64 UUIDs on command line as LDAP search filter of the form:
# (|(ObjectGuid=\xx\xx\xx\xx\xx\xx\xx\xx\xx\xx\xx\xx\xx\xx\xx\xx)...)
fn_base64_uuid_to_hexarray() {
# hexdump base64 valie in $2 to a new indexed array of hex values and name the array $1
# declare global array, not assigning a value for 2 reasons:
# - command substitution exit code would be discarded
# - declaring arrays with variable name require quoting the right side: $n='(1 2 3)'
@basinilya
basinilya / Unsecure.java
Last active March 2, 2023 06:44
Best effort to copy everything from a secured PDF to a new PDF
package org.foo.unsecure;
import java.io.FileOutputStream;
import java.util.HashMap;
import java.util.List;
import com.itextpdf.text.Document;
import com.itextpdf.text.pdf.PdfCopy;
import com.itextpdf.text.pdf.PdfDictionary;
import com.itextpdf.text.pdf.PdfName;
@basinilya
basinilya / aaa.jar
Last active September 28, 2022 06:41
Apache Ant loops and foreach without ant-contrib
@basinilya
basinilya / Makefile
Last active May 30, 2022 01:18
gcc precompiled header with proper Automake Dependency Tracking
COMPILE = gcc
DEPDIR = .deps
am__mv = mv
OBJECTS = foo.o bar.o
all: $(OBJECTS)
# The recipe for stdafx.uptodate ensures that the .gch file is up to date
$(OBJECTS): stdafx.uptodate
package org.foo.chainedlist;
import java.util.AbstractList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.RandomAccess;
import org.apache.commons.collections4.IterableUtils;
/// disable-pageview-api.js
// Based on: https://addons.mozilla.org/firefox/addon/disable-page-visibility/
// License: http://www.opensource.org/licenses/bsd-license.php
(function(){
// visibilitychange events are captured and stopped
document.addEventListener("visibilitychange", function(e) {
e.stopImmediatePropagation();
}, true);
// document.visibilityState always returns false
Object.defineProperty(Document.prototype, "hidden", {
package org.foo.testproxy;
import java.beans.BeanInfo;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;