Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
# Experimentally checks bibtex database for warnings.
# latexmk and pdflatex required
require 'fileutils'
require 'ruby-progressbar'
raise 'Usage: inspectbibtex.rb BIBFILE [start_citation]' unless ARGV[0]
@theirix
theirix / check-latest-hg.rb
Created May 25, 2014 09:57
Check latest hg version for OS X 10.9
require 'open-uri'
require 'rkelly'
ast = RKelly::Parser.new.parse(open('http://mercurial.selenic.com/sources.js').read)
ast.pointcut(RKelly::Nodes::ArrayNode).matches[1..-1].each do |node|
elements = node.pointcut(RKelly::Nodes::StringNode).matches
if elements.any? { |v| v.value =~ /Mercurial.*MacOS.*10\.9/ }
puts elements[0].value[1...-1] + ' at ' + elements[2].value[1...-1]
end
end
@theirix
theirix / apt-majorchanges.py
Created July 5, 2014 11:57
Find upgradable debian packages with major version changes
#!/usr/bin/env python
"""
apt-majorchanges.py
Find upgradable debian packages with major version changes
"""
import apt
__author__ = "theirix"
@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
#!/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 / 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).
---
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 / listclosed.rb
Created December 4, 2010 15:45
Relocate rtorrent session file to another dl/watch location
#!/usr/bin/env ruby
require 'rubygems'
require 'xmlrpc/client'
require 'bencode'
require 'fileutils'
mode = :list if ARGV[0] == nil
if ARGV[0] == nil
mode = :list
import java.util.Collections;
import java.util.Iterator;
import java.util.Vector;
public class testClass {
public static void main(String[] args) {
System.out.println("Hello World");
weirdClass wc = new weirdClass();
@theirix
theirix / macsolutions-tracker.rb
Created May 19, 2011 15:34
Tracks a ticket in macsolutions.ru
#!/usr/bin/env ruby
require 'rubygems'
require 'mechanize'
require 'nokogiri'
unless ARGV.size == 2
STDERR.puts "$0 trackid last-four-phone-digits"
exit 1
end