Skip to content

Instantly share code, notes, and snippets.

Warning: You may have installed MacGPG2 via the package installer.
Several other checks in this script will turn up problems, such as stray
dylibs in /usr/local and permissions issues with share and man in /usr/local/.
Warning: Unbrewed dylibs were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected dylibs:
/usr/local/lib/libmacfuse_i32.2.dylib /usr/local/lib/libmacfuse_i64.2.dylib /usr/local/lib/libosxfuse_i32.2.dylib /usr/local/lib/libosxfuse_i64.2.dylib
Warning: Unbrewed .la files were found in /usr/local/lib.
@theirix
theirix / check-git-update.rb
Created December 11, 2012 13:45
Checks for git update
#!/usr/bin/env ruby
require 'rubygems'
require "atom/feed"
require "open-uri"
feed = Atom::Feed.new "http://code.google.com/feeds/p/git-core/downloads/basic"
feed.update!
titles = feed.entries.first(5).map { |e| e.title.to_s.strip }
latest_versions = titles.map { |s| Gem::Version.new($1) if s =~ /git.*-([0-9\.rc]+)\./ }.
@theirix
theirix / patch-zz-vncaddress.patch
Created December 12, 2012 20:04
Patch for emulators/virtualbox-ose (4.1.22) on FreeBSD. Allows to specify a listen port for a VNC server.
--- src/VBox/Frontends/VBoxHeadless/VBoxHeadless.cpp.orig 2012-12-12 23:26:55.241729935 +0400
+++ src/VBox/Frontends/VBoxHeadless/VBoxHeadless.cpp 2012-12-12 23:23:46.365727984 +0400
@@ -476,6 +476,7 @@
#ifdef VBOX_WITH_VNC
" -n, --vnc Enable the built in VNC server\n"
" -m, --vncport <port> TCP port number to use for the VNC server\n"
+ " -q, --vncaddress <ipaddr> IP address or host name to use for the VNC server\n"
" -o, --vncpass <pw> Set the VNC server password\n"
#endif
" -v, -vrde, --vrde on|off|config Enable (default) or disable the VRDE\n"
@theirix
theirix / gist:5577672
Created May 14, 2013 17:10
bash minimal color
export GNU_COLORS='di=1;34:ln=36:so=33:pi=33:ex=32:bd=33:cd=33;40:su=32;41:sg=34;41:tw=1;34;42:ow=1;31;42:or=36;41:'
export PS1="$(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h'; else echo '\[\033[01;32m\]\u@\h'; fi)\[\033[01;34m\] \w \$([[ \$? != 0 ]] && echo \"\[\033[01;31m\]:(\[\033[01;34m\] \")\\$\[\033[00m\] "
alias ls="ls --color=auto"
alias grep="grep --color=auto"
@theirix
theirix / poll-iron-maiden.rb
Created May 17, 2013 18:31
Checks does a wonderful Iron Maiden song hit a 666'666 scrobble count
#!/usr/bin/env ruby
require 'net/http'
require 'json'
url = "http://ws.audioscrobbler.com/2.0/?method=track.getInfo&api_key=644aa4f87f12b4e2904cd495366cc6b5&" +
"artist=Iron+Maiden&track=Seventh+Son+Of+A+Seventh+Son&format=json"
puts JSON(Net::HTTP.get(URI.parse(url)))['track']['playcount']
#!/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 / 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'
@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