Skip to content

Instantly share code, notes, and snippets.

@theirix
theirix / FixedGZIPInputStream.java
Created August 15, 2016 16:21
GZIPInputStream for Android without 2 GiB limitation
import android.support.annotation.NonNull;
import java.io.FilterInputStream;
import java.io.IOException;
import java.util.zip.GZIPInputStream;
/**
* GZIPInputStream that works correctly with files more than 2 GiB
* <p/>
* <p><b>Rationale</b>
@theirix
theirix / foo.cpp
Created July 26, 2016 10:53
Libasan failure on devtoolset-3
// test with:
// scl enable devtoolset-3 -- g++ -std=c++11 -g -O0 -fsanitize=address -static-libasan foo.cpp
#pragma pack(1)
struct TestStruct
{
};
#include <regex>
@theirix
theirix / gitcleanup.sh
Created March 3, 2016 17:10
Clean a git working copy
#!/bin/bash
if [ -d "$1" ] ; then
cd "$1"
fi
git gc -q
git repack -q -a -d --depth=250 --window=250
git prune
digraph test {
compound = true;
remincross = true;
subgraph cluster_g{
"node_g" [shape=point style=invis];
G;
};
subgraph cluster_h{
From a4e8b94c553940d1a741895a3e6a54deb1f03085 Mon Sep 17 00:00:00 2001
From: theirix <theirix@gmail.com>
Date: Sun, 3 May 2015 19:05:41 +0300
Subject: [PATCH] Autodetect correct TidyBodyOnly parameter type
Autodetect which version (Int or Bool) should be used.
TidyBodyOnly has different types in different versions
(tidy 20061031 on OS X and 20091223 on debian).
---
src/util.cpp | 22 +++++++++++++++++++++-
@theirix
theirix / 0001-Fixed-build-and-runtime-tidy-errors.patch
Created April 25, 2015 10:13
0001-Fixed-build-and-runtime-tidy-errors.patch
From 2aad6eb0337498fff3e411f514539218d686b8e5 Mon Sep 17 00:00:00 2001
From: theirix <theirix@gmail.com>
Date: Sat, 25 Apr 2015 13:01:47 +0300
Subject: [PATCH] Fixed build and runtime tidy errors
1. Replaced explicit TidyBuffer init with proper function call.
This prevents known error https://cl.ly/WwyM
2. Fixed runtime issue with Init/Bool tidy parameter
Tested with tidy 20090325 on OS X (debian uses 20091223).
---
@theirix
theirix / pstack-osx.sh
Created April 7, 2015 08:39
pstack for osx
#!/bin/sh
#
# Script prints gdb stack of the process with a specified pid
if [ -z $1 ]; then
echo "Usage: $0 pid"
exit 1
fi
PID=$1
#!/usr/bin/env ruby
#
# Classify homebrew formulas by origins
def repo f
STDERR.print '.'
`brew info #{f}`.split("\n").map(&:chomp).each do |s|
if s =~ /^From: (.*)/
return $1.gsub(/^https:\/\/github.com\/(.*)\/blob\/.*/, '\1')
end
@theirix
theirix / locate-stalled-etc-files.sh
Created October 12, 2014 12:31
Locate orphaned files in etc
#!/bin/bash
find /etc -type f | while IFS= read -r line ; do
[ $(echo "$line" | grep -E "^/etc/.git/") ] && continue
[ $(echo "$line" | grep -E "^/etc/selinux/") ] && continue
dlocate -S "$line" >/dev/null
if [ $? != 0 ] ; then
if [ "$(apt-file search -l \"$line\" | wc -l)" = "0" ] ; then
echo $line -- $(stat -c '%y' $line | cut -f1 -d' ')
else
echo $line -- dpkg miss, apt-file hit
@theirix
theirix / pre-receive.sh
Last active January 11, 2020 22:53
pre-receive git hook for checking bad unicode
#!/bin/bash
# pre-receive hook to check damaged unicode encoding of received text files
# Wonderful ASCII art is borrowed from the phabricator.com project and licensed by the Apache 2.0 license
RESULT=0
while read oldrev newrev refname
do
OLDIFS=$IFS
IFS=$'\n'